How to display certain images on a conditional?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Gummysaur
Newbie
Posts: 2
Joined: Fri Oct 22, 2021 10:41 am
Contact:

How to display certain images on a conditional?

#1 Post by Gummysaur » Fri Oct 22, 2021 10:52 am

Hello, I have a game I'm making, and in the settings menu I give the player the option to control how the sprites look. So far I have an option to make the characters slightly transparent, and one to make them pixellated. Now, my question is, is there a good way to do this, instead of needing to do something like this *every* single time a character is displayed:

Code: Select all

if persistent.transparent == True:
        show ch_steven_neutral at center:
            alpha .9
    else:
        show ch_steven_neutral at center

    if persistent.transparent == True:
        show ch_niko_neutral at left with easeinleft:
                alpha .9
    else:
            show ch_niko_neutral at left with easeinleft

I was thinking of making a display character function which takes a character and emotion as an input and displays the correct image depending on which setting has been selected, but I'm not very skilled with Python or Ren'py itself and I'm not sure how that would work. Any help would be appreciated!

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: How to display certain images on a conditional?

#2 Post by Ocelot » Fri Oct 22, 2021 12:03 pm

Example of changing applied transform effects in-game:

Code: Select all

image steve = Placeholder("boy")

transform do_nothing:
    pass

transform ghost:
    alpha 0.5

default sprite_effects = do_nothing

label start:
    show steve at center, sprite_effects
    '....'
    $ sprite_effects = ghost
    show steve at center, sprite_effects
    ' ...  '
    return
Just assign whatever transform you need to the sprite_effects transform once on start (or when user changes preference) and just apply that transform to all images which need to be affected by it.
< < insert Rick Cook quote here > >

User avatar
Gummysaur
Newbie
Posts: 2
Joined: Fri Oct 22, 2021 10:41 am
Contact:

Re: How to display certain images on a conditional?

#3 Post by Gummysaur » Fri Oct 22, 2021 7:07 pm

Thank you!

bloobeary
Regular
Posts: 36
Joined: Fri Oct 04, 2019 3:02 pm
Deviantart: bloobeary
Soundcloud: user-212448702
Contact:

Re: How to display certain images on a conditional?

#4 Post by bloobeary » Sat Oct 23, 2021 2:15 pm

I was about to ask a similar question, but my question is about alternate character images depending on choices made by the player.

Basically, I have a character who is supposed to be wearing one of three outfits, depending on earlier player choices.

Rather than doing something like this:

Code: Select all

transform ghost:
    alpha 0.5
...how would I go about using different images for the character?

User avatar
HEXdidnt
Regular
Posts: 61
Joined: Tue Aug 11, 2020 1:25 pm
Projects: A Night at the Office, Embracing Christmas, The Masquerade Benefit
Deviantart: HEXdidnt
Location: Harrow, London, UK
Contact:

Re: How to display certain images on a conditional?

#5 Post by HEXdidnt » Sat Oct 23, 2021 3:43 pm

bloobeary wrote:
Sat Oct 23, 2021 2:15 pm
I was about to ask a similar question, but my question is about alternate character images depending on choices made by the player.

Basically, I have a character who is supposed to be wearing one of three outfits, depending on earlier player choices.
This may be overkill for what you're trying to achieve, but I found this thread super-useful in setting up a LayeredImage for outfits, etc.

It helped me set things up so that I can make multiple, small changes to both expression and appearance with very simple variable changes. These can then be defined as complete images in advance, or changes can be made on-the-fly. (My own thread, in case that's any use).

Other than that, there are a few 'Paper Doll'/'Dress-up' tutorial 'games' available for LayeredImage and ConditionSwitch, and sifting through their code can be very instructive.
As ever, dropping litter in the zen garden of your mind...

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: How to display certain images on a conditional?

#6 Post by Ocelot » Sat Oct 23, 2021 3:44 pm

bloobeary wrote:
Sat Oct 23, 2021 2:15 pm
I was about to ask a similar question, but my question is about alternate character images depending on choices made by the player.

Basically, I have a character who is supposed to be wearing one of three outfits, depending on earlier player choices.

Rather than doing something like this:

Code: Select all

transform ghost:
    alpha 0.5
...how would I go about using different images for the character?
https://www.renpy.org/doc/html/displaya ... tionSwitch
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Google [Bot]