Character select screen using imagebuttons

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
arlj11
Regular
Posts: 28
Joined: Mon Jan 06, 2020 12:30 pm
Projects: 4Wins
Deviantart: arlj11
Github: arlj11
Contact:

Character select screen using imagebuttons

#1 Post by arlj11 »

I saw an older post for making a character select screen using image maps. I made one using imagebuttons that might be better and more flexible in the long run.

Here is the code for the main screen

Code: Select all

screen CharacterSelect():
    tag CharSelection
    label "Choose your Character" xalign 0.5
    hbox:
        yalign 0.70
        xalign 0.5
        imagebutton auto "Eileen %s" yalign 1.0 action Call("EileenDes")
        imagebutton auto "Sylvie %s" yalign 1.0 action Call("SylvieDes")
Here is the code for the confirmation screen

Code: Select all

screen CharacterProfile(pic, name, gender, orientation, description):
    tag CharSelection
    style_prefix "CharProfile"
    default Pronoun = "Her"
    if gender == "Male":
        $ Pronoun = "Him"

    hbox:
        yalign 0.5
        xalign 0.5
        spacing 40

        add pic
        vbox:
            yalign 0.25
            xmaximum 0.25
            grid 2 3:
                text "Name:"
                text name
                text "Gender:"
                text gender
                text "Orientation:"
                text orientation
            text "Description: [description]"
            text "Do you want to choose [Pronoun]?"
            hbox:
                textbutton "Yes" action Return()
                textbutton "No" action Jump("Selection")
Here is the code for the images

Code: Select all

layeredimage Eileen:
	<Insert image data>

image Eileen idle = At("Eileen", darken)
image Eileen hover = "Eileen"

layeredimage Sylvie:
	<Insert image data>

image Sylvie idle = At("Sylvie", darken)
image Sylvie hover = "Sylvie"
Here is the code for the variables for each character.

Code: Select all

define EileenName = "Eileen"
define EileenGender = "Female"
define EileenOrientation = "Unknown"
define EileenDescription = "Ren'py's Mascot."

define SylvieName = "Sylvie"
define SylvieGender = "Female"
define SylvieOrientation = "Unknown"
define SylvieDescription = "a girl from The Question."
And this the code you need to add to your main script.

Code: Select all

label Selection:

    $ show_quick_menu = False
    call screen CharacterSelect
    jump 

label EileenDes:
    $ show_quick_menu = True
    hide screen CharacterSelect
    call screen CharacterProfile("Eileen", EileenName, EileenGender, EileenOrientation, EileenDescription)
    $ Playing = "Eileen"
    jump objectives

label SylvieDes:
    $ show_quick_menu = True
    hide screen CharacterSelect
    call screen CharacterProfile("Sylvie", SylvieName, SylvieGender, SylvieOrientation, SylvieDescription)
    $ Playing = "Sylvie"
    jump objectives

label objectives:
    hide screen CharacterProfile

    if Playing == "Eileen":
        show Eileen
        "Eileen's goal is to show you how to make a VN."
    elif Playing == "Sylvie":
        show Sylvie
        "Sylvie's goal is to be an artist for a VN."
    return
Feedback is always appreciated.

Post Reply

Who is online

Users browsing this forum: No registered users