Page 1 of 1

Flipping screens horizontally

Posted: Mon Dec 24, 2018 11:12 am
by Exiscoming
So I know it's possible to flip images horizontally with

Code: Select all

define bob= im.Flip("bob.png", horizontal=True)
However, is this also possible for screens?

For example:

Code: Select all

screen bob:
    add "bob.png"
    
    if bobHat == True:
	    add "bob_hat.png"
How would you flip the above screen I made for bob horizontally?

I've considered making it a layered image where it should be possible, but so far I find it much more convoluted and difficult to use.

Re: Flipping screens horizontally

Posted: Mon Dec 24, 2018 12:57 pm
by Kia
try

Code: Select all

transform flip:
    xzoom -1
screen flip_test:
    frame:
        at flip
        add "gui/window_icon.png"

Re: Flipping screens horizontally

Posted: Mon Dec 24, 2018 1:27 pm
by Exiscoming
Kia wrote: Mon Dec 24, 2018 12:57 pm try

Code: Select all

transform flip:
    xzoom -1
screen flip_test:
    frame:
        at flip
        add "gui/window_icon.png"
Oh that's really interesting. I works, BUT, it doesn't maintain its transparency, causing a large white background to be added to the image.
Example:
Image

Re: Flipping screens horizontally

Posted: Mon Dec 24, 2018 1:41 pm
by trooper6
looking at what you are doing...where you want to layer images on top of each other...you should just use a layered image. That is what they are there for!

Re: Flipping screens horizontally

Posted: Mon Dec 24, 2018 2:38 pm
by Exiscoming
trooper6 wrote: Mon Dec 24, 2018 1:41 pm looking at what you are doing...where you want to layer images on top of each other...you should just use a layered image. That is what they are there for!
Hi there trooper, yeah you're right, but it's something new and I'm still trying to figure out how it works exactly...
Maybe you'd be able to help me. For example:

Code: Select all

layeredimage character:
    always:
        "baseModel.png"
    
    if activeCharacter == 1:
        "outfit1.png"
    if activeCharacter == 1:
        "hair.png"
    if activeCharacter == 1:
        "face.png"
This seems so over the top. Is there a way for me to just make it into a single if statement?
I tried

Code: Select all

    if activeCharacter == 1:
        "outfit1.png"
        "hair.png"
        "face.png"
But that returns an error.

Re: Flipping screens horizontally

Posted: Mon Dec 24, 2018 3:23 pm
by thebackup
Exiscoming wrote: Mon Dec 24, 2018 2:38 pm This seems so over the top. Is there a way for me to just make it into a single if statement?
I tried

Code: Select all

if activeCharacter == 1:
"outfit1.png"
"hair.png"
"face.png"

But that returns an error.
What does the error message say?

Re: Flipping screens horizontally

Posted: Mon Dec 24, 2018 3:46 pm
by Exiscoming
thebackup wrote: Mon Dec 24, 2018 3:23 pm What does the error message say?
"A condition can only have one displayable, two found."

Re: Flipping screens horizontally

Posted: Mon Dec 24, 2018 7:11 pm
by thebackup
Try this:
Rename your base, outfit, hair and face files to something like for example (will allow for automatic image attributes):
chara_base.png
chara_outfit_casual.png <- replace "casual" with the name of outfit
chara_hair_normal.png <- replace "normal" with name of hairstyle
chara_face_neutral.png <- ditto

Then write your code to something like this:

Code: Select all

layeredimage chara:
    always "chara_base" # don't add extension
    
    group outfit auto # auto define any outfits you have, in this example it will find "chara_outfit_casual"
    group hair auto # auto define any hairstyles you have
    group face auto # ditto
That's probably as simple as it gets (the "if" statement seemingly doesn't allow more than 1 displayable). I hope that meets your needs!

Re: Flipping screens horizontally

Posted: Mon Dec 24, 2018 8:18 pm
by Exiscoming
thebackup wrote: Mon Dec 24, 2018 7:11 pm Try this:
Rename your base, outfit, hair and face files to something like for example (will allow for automatic image attributes):
chara_base.png
chara_outfit_casual.png <- replace "casual" with the name of outfit
chara_hair_normal.png <- replace "normal" with name of hairstyle
chara_face_neutral.png <- ditto

Then write your code to something like this:

Code: Select all

layeredimage chara:
    always "chara_base" # don't add extension
    
    group outfit auto # auto define any outfits you have, in this example it will find "chara_outfit_casual"
    group hair auto # auto define any hairstyles you have
    group face auto # ditto
That's probably as simple as it gets (the "if" statement seemingly doesn't allow more than 1 displayable). I hope that meets your needs!
Thank you thebackup,

It ended up being too difficult to make work, so I've just added mirrored pngs (shame on me I know), but I'll try again tomorrow!
Merry Christmas and thank you all for your help!

Re: Flipping screens horizontally

Posted: Mon Dec 24, 2018 10:43 pm
by trooper6
Exiscoming wrote: Mon Dec 24, 2018 2:38 pm
trooper6 wrote: Mon Dec 24, 2018 1:41 pm looking at what you are doing...where you want to layer images on top of each other...you should just use a layered image. That is what they are there for!
Hi there trooper, yeah you're right, but it's something new and I'm still trying to figure out how it works exactly...
Maybe you'd be able to help me. For example:

Code: Select all

layeredimage character:
    always:
        "baseModel.png"
    
    if activeCharacter == 1:
        "outfit1.png"
    if activeCharacter == 1:
        "hair.png"
    if activeCharacter == 1:
        "face.png"
This seems so over the top. Is there a way for me to just make it into a single if statement?
I tried

Code: Select all

    if activeCharacter == 1:
        "outfit1.png"
        "hair.png"
        "face.png"
But that returns an error.
For me to help, I need to understand a bit more about how your images are put together.
You have a character that has a base model.
If activeCharacter is 1, then she has outfit #1, and she has hair and and a face. What happens if active character isn't 1? Then the character has no face and no hair? She has not outfit? I thought the only difference you were dealing with was if the character had a baseball cap on or not.
What are the layers you plan on having? What variations are you dealing with?
Can you explain your image layers a bit more?

Re: Flipping screens horizontally

Posted: Tue Dec 25, 2018 4:52 pm
by Exiscoming
Hey there trooper6, sorry for the late reply.
Okay, so it's actually part of a much larger thing I'm putting together.

I'm hoping to create a dungeon crawler that the player can move through.
First I need a random background.
Then the random background will figure out what props will be located in the room.
Then your character is loaded. You can play 1 of 3 characters, all with the same base body.
You navigate through the room by clicking on cover, for which I'm using imagebuttons (click on the crate and your character jumps there.)

So far it's going relatively well, but I am struggling with some things. For example, for a character to move from point A to point B, I'd like an animation to play.
However, animations are done as an image, and thus show up 'underneath' the screens (I'm unaware of any ways to have movies play on top of screens).

I didn't want to use layered images because you can't have more than one image per if statement. It's complicated and I know I'm in way over my head, but I feel like I should push myself to get this to work somehow.

Re: Flipping screens horizontally

Posted: Tue Dec 25, 2018 9:47 pm
by philat
The entire point of layered images is NOT using conditionals. You're supposed to name the files with the relevant attributes and use the attributes (not conditions) to control the image. That said, it's perfectly fine to simply use ConditionSwitches or other methods if that is easier for you to understand/implement.

The actual answer to your question is simply xzoom -1 (as demonstrated above). The white in the image you added is probably just the frame background, not the image -- xzoom -1 does not inherently change the image in any way other than flipping it. You can also apply xzoom -1 to any individual element rather than the container (i.e., you could simply write add "bob_hat.png" at flip).