How to display a CG based on a customized character?

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
ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

How to display a CG based on a customized character?

#1 Post by ArizaLuca »

The main character of my game is customizable (sort of? You can choose the gender and ethnicity), and they're in a few CGs. How can you display a CG (computer graphic) image depending on the character? I've got an 'if' statement at the moment, but I don't know if that's correct.

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

Re: How to display a CG based on a customized character?

#2 Post by Ocelot »

You can do a ConditionSwitch or DynamicImage:

Code: Select all

image cg event1 = "cg/event1_[gender]_[ethnicity].png"
# . . .
$ gender = "female"
$ ethnicity = "caucasian"
show cg event1 # shows cg/event1_female_caucasian.png image

# . . .

image event2_male = ConditionSwitch(
    "ethnicity == 'caucasian'", "cg/event1_male_caucasian.png",
    "ethnicity == 'hispanic'", "cg/event1_male_hispanic.png",
)
image event2_female = ConditionSwitch(
    "ethnicity == 'caucasian'", "cg/event1_female_caucasian.png",
    "ethnicity == 'hispanic'", "cg/event1_female_hispanic.png",
)

image event2_female = ConditionSwitch(
    "gender == 'male'", event2_male,
    "gender == 'female'", event2_female,
)

# . . .
$ gender = "male"
$ ethnicity = "hispanic"
show cg event2 # shows cg/event2_male_hispanic.png image
< < insert Rick Cook quote here > >

ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

Re: How to display a CG based on a customized character?

#3 Post by ArizaLuca »

Would that switch out the entire image, or only aspects of said image?

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

Re: How to display a CG based on a customized character?

#4 Post by Ocelot »

CG usually imply prerendered image, so it would switch whole image. If your CG is built dynamically, like LiveComposite, you can apply my solution only to part you need to change.
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Google [Bot]