An option to switch sprites out?

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
Pockets
Newbie
Posts: 20
Joined: Wed Jan 31, 2018 8:28 pm
Deviantart: tsunayoshi86
Contact:

An option to switch sprites out?

#1 Post by Pockets »

So I don't quite know how to word this question in a way that I can search it. But, in short I want to know if there's a way to switch sprites in the options (And some of the text). I was thinking, why not make a game that you can swap the genders of love interests. I mean it's not particularly important, but I thought it might've been a fun idea as I think it allows for the opposite gender to be more comfortable with playing the game, and it sells better >.>. (And honestly I don't spend much time on the sprites to begin with, so making a new set of sprites for a few characters isn't too bad.) Especially since there concept remains very much the same. Anyhow enough of me babbling lol.

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: An option to switch sprites out?

#2 Post by mitoky »

I am a bit unsure if it would work (and didnt tested, if anything is wrong pelase correct me!) but this might work.

First, you have to set a variable with the gender:

Code: Select all

default genre = male
and each sprite (main happy, main sad etc) with a condition switch:

Code: Select all

image main happy = ConditionSwitch(
        "genre == 'male'", "male_main_happy.png",
        "genre == 'female'", "female_main_happy.png",
        )
Afterwards you only have to let the player decide. For this you can simply ask them at the start of the game:

Code: Select all

label start:
    "Are you male or female??"

    menu:
        "male":
            $ genre = male
        
        "female:
            $ genre = female
Once done, you can simply show your sprite in game:

Code: Select all

show main happy
and the gender chosen should show up!

As for text, you can use if statements.

Code: Select all

if gender == male:
    "I think you are a super handsome guy!"
        
else:
    "I think you are a super cute girl!"
Last edited by mitoky on Thu Feb 15, 2018 7:18 am, edited 2 times in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: An option to switch sprites out?

#3 Post by Imperf3kt »

^ a minor problem with using persistent in that way, is that if a player saves a game as say, female, and starts a new game as male, when they go back to what they think is the 'female' save game, it'll be male now.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
mitoky
Veteran
Posts: 316
Joined: Sat Feb 07, 2015 9:12 pm
Projects: The Purring Demon's Love, circus eterie
Contact:

Re: An option to switch sprites out?

#4 Post by mitoky »

Imperf3kt wrote: Thu Feb 15, 2018 3:26 am ^ a minor problem with using persistent in that way, is that if a player saves a game as say, female, and starts a new game as male, when they go back to what they think is the 'female' save game, it'll be male now.
Whoops, you are right! Changed it, thanks for pointing that out! (:

Pockets
Newbie
Posts: 20
Joined: Wed Jan 31, 2018 8:28 pm
Deviantart: tsunayoshi86
Contact:

Re: An option to switch sprites out?

#5 Post by Pockets »

Thanks for the info, I'm gonna test it... sooner or later >.>

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot]