Selectable side image? [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
Kokoro Hane
Eileen-Class Veteran
Posts: 1241
Joined: Thu Oct 27, 2011 6:51 pm
Completed: 30 Kilowatt Hours Left, The Only One Girl { First Quarter }, An Encounter ~In The Rain~, A Piece of Sweetness, Since When Did I Have a Combat Butler?!, Piece by Piece, +many more
Projects: Fateful Encounter, Operation: Magic Hero
Organization: Tofu Sheets Visual
Deviantart: kokoro-hane
itch: tofu-sheets-visual
Contact:

Selectable side image? [SOLVED]

#1 Post by Kokoro Hane »

Hello!

This is something I want to try out for a game in the future, but I have no idea how to do it. I like to have side images for my MCs, but I'd like the side image to be determined by choosing male or female version of the MC. So if male, you see the male sprite, if female, you see the female sprite. How would you go about coding this? Thanks in advance!
Last edited by Kokoro Hane on Sat Mar 12, 2022 12:04 pm, edited 1 time in total.
PROJECTS:
Operation: Magic Hero [WiP]
Piece By Piece [COMPLETE][Spooktober VN '20]
RE/COUNT RE:VERSE [COMPLETE][RPG]
Since When Did I Have a Combat Butler?! [COMPLETE][NaNoRenO2020+]
Crystal Captor: Memory Chronicle Finale [COMPLETE][RPG][#1 in So Bad It's Good jam '17]

But dear God, You're the only North Star I would follow this far
Owl City "Galaxies"

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Selectable side image?

#2 Post by Per K Grok »

Kokoro Hane wrote: Fri Mar 11, 2022 11:00 pm Hello!

This is something I want to try out for a game in the future, but I have no idea how to do it. I like to have side images for my MCs, but I'd like the side image to be determined by choosing male or female version of the MC. So if male, you see the male sprite, if female, you see the female sprite. How would you go about coding this? Thanks in advance!
You could do something like this

Code: Select all

define Andy = Character("Andy", image="andy")

image side andy male =  "side_andy_male.png"
image side andy female = "side_andy_female.png"

default andygender= 0


label start:

    call talk(andygender, "Hello 1")

    $ andygender=1

    call talk(andygender, "Hello 2")
    

label talk(a,b):
    if a==0:
        Andy male "[b]"
    elif a==1:
        Andy female "[b]"

    return

User avatar
Alex
Lemma-Class Veteran
Posts: 3097
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Selectable side image?

#3 Post by Alex »

Kokoro Hane wrote: Fri Mar 11, 2022 11:00 pm ...How would you go about coding this? ...
Depends of how you gonna make your story. If gender affects it too much this might be easier to make two separate stories (for male and female) and jump to one or another at the start of the game. In this case you could define two characters and use them for different stories.
But if it will be one story with some checks for players gender, you could use this code sample with Lucy - https://www.renpy.org/doc/html/statemen ... l#dialogue

User avatar
Kokoro Hane
Eileen-Class Veteran
Posts: 1241
Joined: Thu Oct 27, 2011 6:51 pm
Completed: 30 Kilowatt Hours Left, The Only One Girl { First Quarter }, An Encounter ~In The Rain~, A Piece of Sweetness, Since When Did I Have a Combat Butler?!, Piece by Piece, +many more
Projects: Fateful Encounter, Operation: Magic Hero
Organization: Tofu Sheets Visual
Deviantart: kokoro-hane
itch: tofu-sheets-visual
Contact:

Re: Selectable side image?

#4 Post by Kokoro Hane »

Per K Grok wrote: Sat Mar 12, 2022 4:50 am You could do something like this
Hmmm that one is a little tedious. I already know I can use a lot of "if" statements, but since majority of the dialogue will be exactly the same I am looking for a solution where one variable could be used depending on which one you chose. So say you have a side image for variable "sprite", so depending on which you choose, "sprite" will bring up a different image. (Off topic, but I did love how your example uses "Andy" since one of my projects I do have a character "Andy" that can be male or female lol... that one uses no side images though so it was easy to configure).
Alex wrote: Sat Mar 12, 2022 5:18 am
Depends of how you gonna make your story. If gender affects it too much this might be easier to make two separate stories (for male and female) and jump to one or another at the start of the game. In this case you could define two characters and use them for different stories.
But if it will be one story with some checks for players gender, you could use this code sample with Lucy - https://www.renpy.org/doc/html/statemen ... l#dialogue
This code could definitely work! I was looking for a code that the variable brings up a different image depending on your choice, and this could work. This one shows for dialogue, but I will try to put the side image code within it and see if that works! Yes, the idea is the dialogue would mostly be the same, I'd only need to use "if" statements in some places. EDIT: It worked !!! ! Thank you!!!

I'll be editing my top post later with what I did with the code so it may help other people later!
PROJECTS:
Operation: Magic Hero [WiP]
Piece By Piece [COMPLETE][Spooktober VN '20]
RE/COUNT RE:VERSE [COMPLETE][RPG]
Since When Did I Have a Combat Butler?! [COMPLETE][NaNoRenO2020+]
Crystal Captor: Memory Chronicle Finale [COMPLETE][RPG][#1 in So Bad It's Good jam '17]

But dear God, You're the only North Star I would follow this far
Owl City "Galaxies"

Post Reply

Who is online

Users browsing this forum: Bing [Bot]