{code} Imagemap character selection screen!

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
User avatar
chungy
Regular
Posts: 26
Joined: Sun Sep 23, 2018 9:07 pm
Contact:

{code} Imagemap character selection screen!

#1 Post by chungy »

Hello, here's the code on how to make a character selection screen (either for displaying images based on who the player chooses/certain dialogue)
Finished product will look like this;
1.PNG
2.PNG
(mouse hovered over first one)
3.PNG
things you need to have in your folder before hand:
-ground image for imagemap (purple above)
-idle image for imagemap (black above
-hover image for imagemap (white above)

Here's the code in script:

Code: Select all

label start:
    #these are your points, rename them to what you are selecting! you van have as many of these as you'd like
    $malePoints = 0
    $femalePoints = 0

screen characterselectscreen:

    imagemap:
        #these are your images
        ground "sprite ground"
        idle "sprite idle"
        hover "sprite hover"
        #these are your hotspots, alter them to fit your screen and however you want it to look. Add one every time you create a new point.
        hotspot (1310, 0, 567, 1080) action SetVariable("malePoints", malePoints + 1), Return()
        hotspot (687, 0, 595, 1080) action SetVariable("femalePoints", femalePoints + 1), Return()

label chrsel:
    "Narrator" "Choose your character"
    $ renpy.call_screen("characterselectscreen")
    if malePoints ==1:
        "Boy" "I am a boy" 
        #this onward is for names, you don't need to have this in your game at all, it's just after character selection for me.
        $ player_name = renpy.input("My name is...")
        $ player_name = player_name.strip()
        #this is if a player leaves their name as blank.
        if player_name == "":
            $ player_name="MC male"

    if femalePoints == 1:
        "girl" "I am a girl"
        #this onward is for names, you don't need to have this in your game at all, it's just after character selection for me.
        $ player_name = renpy.input("My name is...")
        $ player_name = player_name.strip()
        #this is if a player leaves their name as blank
        if player_name == "":
            $ player_name="MC female"     

    "narrator" "that was the end of character selection screen, %(player_name)s."    

    # This ends the game.

    return
Feel free to ask any questions if I was too vague. ^__^
https://gutrotz.itch.io/
Check out my itch.io!

viewtopic.php?f=62&t=52002&p=496592#p496592
Sprite commissions closed!

Post Reply

Who is online

Users browsing this forum: No registered users