[SOLVED] Separate hair style and hair color for custom MC

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
chesarty
Regular
Posts: 108
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

[SOLVED] Separate hair style and hair color for custom MC

#1 Post by chesarty » Thu Jan 07, 2021 3:07 pm

I've created a dressup-type of game where the player can customize their appearance and everything is going splendid. The only thing I'd like to change about it is the way you choose your hair.
The way it currently works is that you have to scroll through all the hair colors for that specific style before you get to the next one. Instead, I would like there to be two separate pickers, one for style and one for color.
So let's say you want hairstyle 3 in color 5. Instead of having to scroll through 2 hairstyles in 7 colors + 4 colors in your desired one before you get to the correct one, you can just click to hairstyle 3 and then look at the different color options separately.

How would one go about doing that? I've been following two tutorials to create the game, https://bit.ly/35iyYwr and https://bit.ly/3bmGSbN. Here is my code so far:

Code: Select all

# The script of the game goes in this file.

# Declare characters used by this game. The color argument colorizes the
# name of the character.

define e = Character("MC")

#begin sideimage
image side avatar = LayeredImageProxy("mc", Transform(crop=(0, 0, 1000, 1000), zoom=0.6, xoffset=950, yoffset=200))
#end sideimage

#begin sideimage_name
define a = Character("Main Character", image="avatar")
#end sideimage_name

default skin = 1
default hair = 1
default haircolor = 1
default highlights = 1
default eyes = 1
default brows = 1
default mouth = 1

layeredimage mc:

    if skin == 1:
        "/images/dressup/avatar_skin1.png"
    elif skin == 2:
        "/images/dressup/avatar_skin2.png"
    elif skin == 3:
        "/images/dressup/avatar_skin3.png"
    elif skin == 4:
        "/images/dressup/avatar_skin4.png"
        
    if eyes == 1:
        "/images/dressup/avatar_eyes1.png"
    elif eyes == 2:
        "/images/dressup/avatar_eyes2.png"
    elif eyes == 3:
        "/images/dressup/avatar_eyes3.png"
    elif eyes == 4:
        "/images/dressup/avatar_eyes4.png"
    elif eyes == 5:
        "/images/dressup/avatar_eyes5.png"
    elif eyes == 6:
        "/images/dressup/avatar_eyes6.png"
    elif eyes == 7:
        "/images/dressup/avatar_eyes7.png"



    if highlights == 1:
        "/images/dressup/avatar_highlights1.png"
    elif highlights == 2:
        "/images/dressup/avatar_highlights2.png"
    elif highlights == 3:
        "/images/dressup/avatar_highlights3.png"
    elif highlights == 4:
        "/images/dressup/avatar_highlights4.png"

    if brows == 1:
        "/images/dressup/avatar_brow1.png"
    elif brows == 2:
        "/images/dressup/avatar_brow2.png"
    elif brows == 3:
        "/images/dressup/avatar_brow3.png"
    elif brows == 4:
        "/images/dressup/avatar_brow4.png"
        
    if hair == 1:
        "/images/dressup/avatar_hair1.png"
    elif hair == 2:
        "/images/dressup/avatar_hair2.png"
    elif hair == 3:
        "/images/dressup/avatar_hair3.png"
    elif hair == 4:
        "/images/dressup/avatar_hair4.png"
    elif hair == 5:
        "/images/dressup/avatar_hair5.png"
    elif hair == 6:
        "/images/dressup/avatar_hair6.png"
    elif hair == 7:
        "/images/dressup/avatar_hair7.png"
    elif hair == 8:
        "/images/dressup/avatar_hair8.png"
    elif hair == 9:
        "/images/dressup/avatar_hair9.png"
    elif hair == 10:
        "/images/dressup/avatar_hair10.png"

        
    if mouth == 1:
        "/images/dressup/avatar_mouth1.png"
    elif mouth == 2:
        "/images/dressup/avatar_mouth2.png"
    elif mouth == 3:
        "/images/dressup/avatar_mouth3.png"
    elif mouth == 4:
        "/images/dressup/avatar_mouth4.png"
        


screen dollmaker():
    hbox:
        yalign 0.5
        xalign 0.5
        spacing 100
        
        vbox:

            text "hair"
            
            hbox:
                textbutton "Prev" action Function(change_mc, "hair", "-")
                textbutton "Next" action Function(change_mc, "hair", "+")



            text "brows"
            
            hbox:
                textbutton "Prev" action Function(change_mc, "brows", "-")
                textbutton "Next" action Function(change_mc, "brows", "+")

            text "mouth"
            
            hbox:
                textbutton "Prev" action Function(change_mc, "mouth", "-")
                textbutton "Next" action Function(change_mc, "mouth", "+")
                
            text "highlights"
            
            hbox:
                textbutton "Prev" action Function(change_mc, "highlights", "-")
                textbutton "Next" action Function(change_mc, "highlights", "+")
                
            text "eyes"
            
            hbox:
                textbutton "Prev" action Function(change_mc, "eyes", "-")
                textbutton "Next" action Function(change_mc, "eyes", "+")

            text "skin"
            
            hbox:
                textbutton "Prev" action Function(change_mc, "skin", "-")
                textbutton "Next" action Function(change_mc, "skin", "+")
        
        add "mc"
        
        textbutton "Done" action Return()
    
init python:
    def change_mc(aspect, way):
        global hair
        global skin
        global eyes
        global brows
        global mouth
        global highlights
            
        if aspect == "hair":
            if way == "+":
                hair += 1
            if way == "-":
                hair -= 1
            
        if hair > 10:
            hair = 1
        if hair < 1:
            hair = 10
        
            
        if aspect == "eyes":
            if way == "+":
                eyes += 1
            if way == "-":
                eyes -= 1
            
        if eyes > 7:
            eyes = 1
        if eyes < 1:
            eyes = 7
            
        if aspect == "brows":
            if way == "+":
                brows += 1
            if way == "-":
                brows -= 1
            
        if brows > 4:
            brows = 1
        if brows < 1:
            brows = 4

        if aspect == "mouth":
            if way == "+":
                mouth += 1
            if way == "-":
                mouth -= 1
            
        if mouth > 4:
            mouth = 1
        if mouth < 1:
            mouth = 4
            
        if aspect == "skin":
            if way == "+":
                skin += 1
            if way == "-":
                skin -= 1
            
        if skin > 4:
            skin = 1
        if skin < 1:
            skin = 4
            
        if aspect == "highlights":
            if way == "+":
                highlights += 1
            if way == "-":
                highlights -= 1
            
        if highlights > 4:
            highlights = 1
        if highlights < 1:
            highlights = 4
# The game starts here.

label start:

    # Show a background. This uses a placeholder by default, but you can
    # add a file (named either "bg room.png" or "bg room.jpg") to the
    # images directory to show it.

    call screen dollmaker

    # This shows a character sprite. A placeholder is used, but you can
    # replace it by adding a file named "eileen happy.png" to the images
    # directory.

    show eileen
    # These display lines of dialogue.

    e "You've created a new Ren'Py game."

    a"Once you add a story, pictures, and music, you can release it to the world!"

    # This ends the game.

    return
Last edited by chesarty on Fri Jan 08, 2021 1:33 pm, edited 1 time in total.

User avatar
chesarty
Regular
Posts: 108
Joined: Sat Aug 25, 2018 3:07 am
Completed: 0
Contact:

Re: Separate hair style and hair color for custom MC

#2 Post by chesarty » Fri Jan 08, 2021 11:26 am

Hello all! I'm just here to update that I came up with a solution, and it was pretty simple. I'll just post this here in case anyone wants it for themselves :)

All you need to do is add this to every hairstyle you want:

Code: Select all

    if hair == 1 and haircolor == 1:
        "/images/dressup/avatar_hair1_1.png"
    elif hair == 1 and haircolor == 2:
        "/images/dressup/avatar_hair1_2.png"
    elif hair == 1 and haircolor == 3:
        "/images/dressup/avatar_hair1_3.png"
    elif hair == 1 and haircolor == 4:
        "/images/dressup/avatar_hair1_4.png"

Code: Select all

            text "haircolor"
            
            hbox:
                textbutton "Prev" action Function(change_mc, "haircolor", "-")
                textbutton "Next" action Function(change_mc, "haircolor", "+")

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Voz