How to Change Sprites Based on Chosen Gender (Solved)

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
Lucy1212
Regular
Posts: 39
Joined: Sat Sep 13, 2014 7:15 pm
Completed: None, yet
Projects: The Roses are Covered in Blood, Her Dolls, Where the Wind Travels
Contact:

How to Change Sprites Based on Chosen Gender (Solved)

#1 Post by Lucy1212 »

I want to let the character choose their gender. This would also change the sprite. Originally I thought I would do something like...

Code: Select all

if gender ==0
   image mc = "mc_girl"

if gender ==1
   image mc = "mc_guy"
But that always gives me a guy sprite, regardless of the gender I choose. Help?
Last edited by Lucy1212 on Tue Sep 16, 2014 6:27 pm, edited 1 time in total.
I'm a wordsmith baby~

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: How to Change Sprites Based on Chosen Gender

#2 Post by SundownKid »

Try something like:

Code: Select all

image side maincharacter:
    ConditionSwitch(
        "mc_gender == 1", ImageReference ("male_mc"),
        "mc_gender == 2", ImageReference ("female_mc"),
        )
With "male_mc" being the male image and "female_mc" being the female image.

User avatar
Lucy1212
Regular
Posts: 39
Joined: Sat Sep 13, 2014 7:15 pm
Completed: None, yet
Projects: The Roses are Covered in Blood, Her Dolls, Where the Wind Travels
Contact:

Re: How to Change Sprites Based on Chosen Gender

#3 Post by Lucy1212 »

Okay, now it says I'm missing the image. Here is the code.

Code: Select all

image side mc:
    ConditionSwitch (
        "gender ==0", ImageReference ("mc_guy.png"),
        "gender ==1", ImageReference ("mc_girl.png"),
        )
It's pretty much the same as yours, right?
I'm a wordsmith baby~

mjshi
Regular
Posts: 179
Joined: Wed Mar 13, 2013 9:55 pm
Completed: MazeSite01, Ponderings of Time
Contact:

Re: How to Change Sprites Based on Chosen Gender

#4 Post by mjshi »

Just a small error with your original code (that code could still probably work ^.^ although conditionswitch is usually used):

Code: Select all

if gender ==0
   image mc = "mc_girl"

if gender ==1
   image mc = "mc_guy"
I recommend you to change the second "if" to "elif", which means "else, if the above is not true, then":

Code: Select all

if gender ==0
   image mc = "mc_girl"

elif gender ==1
   image mc = "mc_guy"

User avatar
Lucy1212
Regular
Posts: 39
Joined: Sat Sep 13, 2014 7:15 pm
Completed: None, yet
Projects: The Roses are Covered in Blood, Her Dolls, Where the Wind Travels
Contact:

Re: How to Change Sprites Based on Chosen Gender

#5 Post by Lucy1212 »

Now when I try you're code, it always gives me a guy again.
I'm a wordsmith baby~

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1779
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: How to Change Sprites Based on Chosen Gender

#6 Post by OokamiKasumi »

In my game Trap! I set up gender choice and naming this way:

in script.rpy

Code: Select all

init:
    $ e = DynamicCharacter("pc_name", 
        color="#ffffcc",
        outlines = [(1, "#333300", 0, 0)],
        drop_shadow = (2, 2,),
        what_prefix="\"",
        what_suffix="\"",
        show_two_window = True,)

label start:
    $ gender = "Male" 
    # One of the genders needs to be preset or the game will throw an error on restart. 
    # It doesn't matter which you set because it will change with the player's selection. 

#################################################
    scene bg_02
    show gal at right
    show guy at left 
    with fade
    
    menu:
        "Would you like a Male Lead character?":
            $ gender = 'male'
            hide gal with dissolve
            show guy at center with move

        "Or a Female Lead character?":
            $ gender = 'female'
            hide guy with dissolve
            show gal at center with move
            
label name:
    #This is where the player chooses a name for their character -- with instructions. 
    $ pc_name = renpy.input("What would you like to name your character? \n{i}{color=#cccc99} -- Backspace to erase the current name. When you're done, hit Enter.{/color}{/i}\n", "Chris", length=15)
    $ pc_name = pc_name.strip()

    scene black with fade    
Then in a whole new tab I called xLiveComposite.rpy I set up the image coding for each gender's expressions with a ConditionSwitch. :

Code: Select all

init-1:
    image pc = "ch/male/mConR.png" 
    #This is yet another preset to keep from getting an error. 

# ----------------------------------------------------
    image pc neuR = ConditionSwitch(
        "gender == 'female' ", Image ("ch/fem/fNeuR.png"),
        "gender == 'male' ", Image ("ch/male/mNeuR.png"),
        "True", Image ("ch/male/mNeuR.png"),
        )

    image pc neuL = ConditionSwitch(
        "gender == 'female' ", Image ("ch/fem/fNeuL.png"),
        "gender == 'male' ", Image ("ch/male/mNeuL.png"),
        "True", Image ("ch/male/mNeuL.png"),
        )
Each gender has three expressions in Left and Right, so six expressions total. This is Neutral Left and Right.

It looks like this:
t_ss02.jpg
t_ss03.jpg
Last edited by OokamiKasumi on Wed Sep 17, 2014 4:45 pm, edited 2 times in total.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

User avatar
Lucy1212
Regular
Posts: 39
Joined: Sat Sep 13, 2014 7:15 pm
Completed: None, yet
Projects: The Roses are Covered in Blood, Her Dolls, Where the Wind Travels
Contact:

Re: How to Change Sprites Based on Chosen Gender

#7 Post by Lucy1212 »

It's finally working! Thanks so much!
I'm a wordsmith baby~

Post Reply

Who is online

Users browsing this forum: Bing [Bot]