Trying to create a character select screen

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
arlj11
Regular
Posts: 30
Joined: Mon Jan 06, 2020 12:30 pm
Projects: 4Wins
Deviantart: arlj11
Github: arlj11
Contact:

Trying to create a character select screen

#1 Post by arlj11 »

As the title says, I'm trying to create a character select screen where when the player selects a character, they read a little bit about the character. They can confirm their selection or go back to the selection screen.

My goal is to have it appear with a pixelated transition. It would then pixelate out to show the selected character as they pixelate in.

I have a variable to hold which character is selected. I also have a label that holds all the characters' descriptions controlled by if else function.

My first problem is that if I do show screen, the script moves to the confirmation menu before the player can select a character. If I do it as a call screen, the transition don't work.

Second problem is that if I make the button just define the character that is selected. It doesn't show the description.

I've managed a workaround by making four different labels that hold the description and the code to set the selected character. But I would like to use one label if possible.

Here is the code. The commented sections are my old code for reference. I also removed anything irrelevant to the problems.

The Selection label

Code: Select all

label Selection:

    scene AllSeer Expanded
    with fade

    call screen CharacterSelect with Digital
    with Digital
    # show Lu:
    #     xalign 0.2 yalign 1.0
    # show Ka:
    #     xalign 0.4 yalign 1.0
    # show Tom:
    #     xalign 0.6 yalign 1.0
    # show Ro:
    #     xalign 0.8 yalign 1.0
    # with Digital
    #
    # menu:
    #     narrator "Choose your Character:"
    #
    #     "Luna":
    #         $ Playing = "Luna"
    #     "Kaat":
    #         $ Playing = "Kaat"
    #     "Thomas":
    #         $ Playing = "Tom"
    #     "Roxie":
    #         $ Playing = "Roxie"
    # jump CharacterDes
The new selection screen

Code: Select all

screen CharacterSelect:
    label "Choose your Character" xalign 0.5
    hbox:
        yalign 0.70
        xalign 0.5
        imagebutton idle "images/Sprites/LunaBase.png" yalign 1.0 action Jump("LunaDes")
        imagebutton idle "images/Sprites/KaatBase.png" yalign 1.0 action Jump("KaatDes")
        imagebutton idle "images/Sprites/ThomasBase.png" yalign 1.0 action Jump("ThomasDes")
        imagebutton idle "images/Sprites/RoxieBase.png" yalign 1.0 action Jump("RoxieDes")

return
The old description label

Code: Select all

# label CharacterDes:
#     scene AllSeer Expanded
#
#     if Playing == "Luna":
#         show Lu with Digital
#         AS "Description text"
#         AS "Do you want to choose her?"
#     elif Playing == "Kaat":
#         show Ka with Digital
#         AS "Description text"
#         AS "Do you want to choose her?"
#     elif Playing == "Tom":
#         show Tom with Digital
#         AS "Description text"
#         AS "Do you want to choose him?"
#     elif Playing == "Roxie":
#         show Ro with Digital
#         AS "Description text"
#         AS "Do you want to choose her?"
#
#     jump SelectChar
The new description labels

Code: Select all

label LunaDes:
    hide screen CharacterSelect with Digital
    $ Playing = "Luna"
    show Lu with Digital
    AS "Description text"
    AS "Do you want to choose her?"
    jump SelectChar

label KaatDes:
    hide screen CharacterSelect with Digital
    $ Playing = "Kaat"
    show Ka with Digital
    AS "Description text"
    AS "Do you want to choose her?"
    jump SelectChar

label ThomasDes:
    hide screen CharacterSelect with Digital
    $ Playing = "Tom"
    show Tom with Digital
    AS "Description text"
    AS "Do you want to choose him?"
    jump SelectChar

label RoxieDes:
    hide screen CharacterSelect with Digital
    $ Playing = "Roxie"
    show Ro with Digital
    AS "Description text"
    AS "Do you want to choose her?"
    jump SelectChar
Also, is there a way to use a defined image in an imagebutton? I want to use layered images later and find that I can also use some of the built in image functions to try to keep my file size down. Figured it out on my own.

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: Trying to create a character select screen

#2 Post by Per K Grok »

arlj11 wrote: Thu Dec 30, 2021 12:19 pm As the title says, I'm trying to create a character select screen where when the player selects a character, they read a little bit about the character. They can confirm their selection or go back to the selection screen.

My goal is to have it appear with a pixelated transition. It would then pixelate out to show the selected character as they pixelate in.

I have a variable to hold which character is selected. I also have a label that holds all the characters' descriptions controlled by if else function.

My first problem is that if I do show screen, the script moves to the confirmation menu before the player can select a character. If I do it as a call screen, the transition don't work.

Second problem is that if I make the button just define the character that is selected. It doesn't show the description.

I've managed a workaround by making four different labels that hold the description and the code to set the selected character. But I would like to use one label if possible.

-------

I'm not sure I have understood exactly what you want. Also there could be different ways of doing a select screen. This could be one way

Code: Select all

default Playing="None"


screen CharacterSelect2:

    vbox:
        xalign 0.5
        label "Choose your Character" xalign 0.5
        hbox:
            spacing 20
            vbox:
                add "images/Sprites/LunaBase.png"
                text "Luna"
                text "description text description text qwerty description text" xmaximum 200
                textbutton "Choose Luna" action [SetVariable("Playing", "Luna"), Jump("SelectChar")]

            vbox:
                add "images/Sprites/KaatBase.png"
                text "Kaat"
                text "description text description text qwerty description text" xmaximum 200
                textbutton "Choose Kaat" action [SetVariable("Playing", "Kaat"), Jump("SelectChar")]

            vbox:
                add "images/Sprites/ThomasBase.png"
                text "Tom"
                text "description text description text qwerty description text" xmaximum 200
                textbutton "Choose Tom" action [SetVariable("Playing", "Tom"), Jump("SelectChar")]

            vbox:
                add "images/Sprites/RoxieBase.png"
                text "Roxie"
                text "description text description text qwerty description text" xmaximum 200
                textbutton "Choose Roxie" action [SetVariable("Playing", "Roxie"), Jump("SelectChar")]




label start:

    scene AllSeer Expanded
    with fade

    show screen CharacterSelect2 with pixellate
    $ renpy.pause (hard=True)



label SelectChar:
    hide screen CharacterSelect2 with pixellate
    AS "You have selected [Playing]"
    AS "Do you want to change your mind?"
    menu:
        "Yes":
            jump start
        "No":
            jump go_on

User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: Trying to create a character select screen

#3 Post by zmook »

arlj11 wrote: Thu Dec 30, 2021 12:19 pm My first problem is that if I do show screen, the script moves to the confirmation menu before the player can select a character. If I do it as a call screen, the transition don't work.
I suspect you *do* want to call this screen, assuming you want it to work kind of like a menu and take over control of the game while the player is choosing a character, and not just sort of hover there while the player can keep clicking and moving ahead through dialog. At least, you need something that starts an interaction with the player, and calling creates an interaction while showing does not.

The docs say "In a call screen statement, the with clause causes a transition to occur when the screen is shown", so I'm not sure why you're not getting your transition to appear. Maybe someone else here can answer that, or it might help if you share more of your code (such as, what's the definition of your Digital transition?)
Second problem is that if I make the button just define the character that is selected. It doesn't show the description.
The simple answer to this is that if you want your screen to do that, you just have to code the screen so that it does. You don't want the buttons to have a simple "Jump" action -- you want to use SetScreenVariable or a Function so that clicking on the small portrait causes a bigger one to appear along with some text, and then clicking a different Confirm button actually makes the selection. Or you could use the tooltip facility to have the description text appear just by hovering over a character choice. Does that help enough for you to figure it out? I could code it up later when I get a chance if it's not clear yet.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

arlj11
Regular
Posts: 30
Joined: Mon Jan 06, 2020 12:30 pm
Projects: 4Wins
Deviantart: arlj11
Github: arlj11
Contact:

Re: Trying to create a character select screen

#4 Post by arlj11 »

Thank you both for your replies.

@Per K Grok

I kind of like where you were going. but the sprites are full body and the description text is three lines long. So I would have to have the text overlap the image. I also want to have different effects for the idle and hover states. (Ex: shaded out while idle and lit up with a spotlight on the character when hoovered overed.)

@zmook

Code is always good. I agree that I do want it to act as a menu and stop the game until a character is selected. I have had difficulties in the past with call statements. (I created one that would skip a section still under development to save the player time, not realizing that the return to send the player back to the main menu returned them to where the call was and have them go through the whole game again.) So I want to make sure that I exit the call before moving on so I don't have any problems.

I'm thinking of making a second screen to show the description. Like, have the sprite on the left and the description on the right with a yes/no below it. I think I can do that with parameters.

arlj11
Regular
Posts: 30
Joined: Mon Jan 06, 2020 12:30 pm
Projects: 4Wins
Deviantart: arlj11
Github: arlj11
Contact:

Re: Trying to create a character select screen

#5 Post by arlj11 »

I've been working on the character select screen for a bit and have come across more problems.

Here is an updated version of my first character select screen.

Code: Select all

screen CharacterSelect():
    tag CharSelection
    label "Choose your Character" xalign 0.5
    hbox:
        yalign 0.70
        xalign 0.5
        imagebutton auto "Lu %s" yalign 1.0 action Call("LunaDes")
        imagebutton auto "Ka %s" yalign 1.0 action Call("KaatDes")
        imagebutton auto "Tom %s" yalign 1.0 action Call("ThomasDes")
        imagebutton auto "Ro %s" yalign 1.0 action Call("RoxieDes")
Here is a new screen I've built:

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")

style CharProfile__hbox:
        spacing 40

# style CharProfile_text:
What I wanted to do is directly move to the second screen after the first character select screen. But it would give me an error when I changed the button's action from a Jump() to a show(). It also wouldn't update the Playing variable when I put it in the screen or tried to make it part of the Yes textbutton.

So this is the workaround I came up with. Any improvements would be helpful.

Code: Select all

label LunaDes:
    $ show_quick_menu = True
    hide screen CharacterSelect
    call screen CharacterProfile("Lu", LuName, LuGender, LuOrientation, LuDescription) with Digital
    $ Playing = "Luna"
    jump objectives

label KaatDes:
    $ show_quick_menu = True
    hide screen CharacterSelect
    call screen CharacterProfile("Ka", KaName, KaGender, KaOrientation, KaDescription) with Digital
    $ Playing = "Kaat"
    jump objectives

label ThomasDes:
    $ show_quick_menu = True
    hide screen CharacterSelect
    call screen CharacterProfile("Tom", TomName, TomGender, TomOrientation, TomDescription) with Digital
    $ Playing = "Thomas"
    jump objectives

label RoxieDes:
    $ show_quick_menu = True
    hide screen CharacterSelect
    call screen CharacterProfile("Ro", RoName, RoGender, RoOrientation, RoDescription) with Digital
    $ Playing = "Roxie"
    jump objectives
I'm also having problems styling the screen. I would like to give the text boxes a solid background color with some opacity to help with reading. I just can't find out how.

I'm thinking of adding it to the cookbook once I get it to work.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]