Customizable player character? Layering images?

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
inkbrush
Regular
Posts: 60
Joined: Tue Jul 08, 2014 3:28 am
Contact:

Customizable player character? Layering images?

#1 Post by inkbrush »

Okay Lemmasoftians,

I have no idea what I'm doing right now.

I was trying to test something out and figure out the code on my own but it just made me confused and frustrated so I decided to ask for help because there's nothing wrong with that, right?

So, I was trying to figure out if/how I could layer images and such. You see, the player character in my game is customizable. Skin, eye color, hair color, etc. And to try to save a little bit of time, I was hoping that I could just layer the different eyes over the body and the different hairs over that, etc. So that I wouldn't have to create images for each possible combination. Sounds like something I can (or at least should) be able to do.

So, I've been looking at LiveComposite, ConditionSwitch, and leon's Dress Up Game code. But, as a result, I've just gotten very confused by all of this.

So, basically, what I was trying to do was just trying to put in two menus (one for hair and one for eyes) with minimal options, and after you go through the menus, you get the image of the character. (Essentially just so I could see that it was working) And I know that I can just get an answer now if it's possible or not but I still want to see this done now because . . . Some strange sense of accomplishment? I don't know, to be honest.


But, if I could get some help on how I would go about putting this together, that would be amazing! Thank you in advance to everyone that helps--

User avatar
Steamgirl
Veteran
Posts: 322
Joined: Sat Jul 28, 2012 4:39 am
Completed: My Cup of Coffee, Queen at Arms (co-wrote a battle scene)
Projects: Stranded Hearts, Emma: A Lady's Maid
Deviantart: steamgirlgame
Contact:

Re: Customizable player character? Layering images?

#2 Post by Steamgirl »

Hi inkbrush,

What you'd like to do is entirely possible!

Here's a code rinrin posted in a different thread

Code: Select all

    image protagonist composite = LiveComposite((453, 600),
                                        (0, 0), "characters/body.png",
                                        (0, 0), "characters/face.png",
                                        (0, 0), ConditionSwitch(
                                            "hair_length == 'short-a'", "characters/hair-short-a.png", 
                                            "hair_length == 'short-b'", "characters/hair-short-b.png", 
                                            "hair_length == 'middle-a'", "characters/hair-middle-a.png",
                                            "hair_length == 'middle-b'", "characters/hair-middle-b.png",
                                            "hair_length == 'long-a'", "characters/hair-long-a.png",
                                            "hair_length == 'long-b'", "characters/hair-long-b.png",
                                            ),
                                        (0, 0), ConditionSwitch(
                                            "clothes == 'uniform'", "characters/uniform.png", 
                                            "clothes == 'pajamas'", "characters/pajamas.png",
                                            ),
                                        )
Here's the result
http://lemmasoft.renai.us/forums/viewto ... =16&t=6223

I'd be happy to offer further (more specific) help if that is still too confusing. :)

User avatar
inkbrush
Regular
Posts: 60
Joined: Tue Jul 08, 2014 3:28 am
Contact:

Re: Customizable player character? Layering images?

#3 Post by inkbrush »

Thank you for responding!

So, I entered the code you gave me (along with the edits I needed to do, haha). I'm still not sure how you would mark it to remember that you've chosen a certain hair/face/etc. though. I thought originally that I would just need to do insert the following:

Code: Select all

menu:
    "What hair color?"
    
    "Black":
        $ 'black-hair' = True
        
        "You chose black hair!"
        
        jump eye_color
But, that didn't work. So, how do I define that??

Also, I have a feeling that I might be doing something wrong, so I'll post everything that I have of my code here just to make sure that I've got everything right, lol.

Code: Select all

init:
    image heroine composite = LiveComposite((453, 600),
                                    (0, 0), "Base_skin1.png",
                                    (0, 0), ConditionSwitch(
                                        "face_eyecolor == 'pink-eyes'", "Face_eyes1_pink.png"
                                        "face_eyecolor == 'gray-eyes'", "Face_eyes2_gray.png"
                                        ),
                                    (0, 0), ConditionSwitch(
                                        "hair_style == 'black-hair'", "Hair_style4_color1_black.png"
                                        "hair_style == 'blue-hair'", "Hair_style4_color2_blue.png"
                                        ),
                                    )

define player = Character('You', color="#c8ffc8")


# The game starts here.
label start:

menu:
    "What hair color?"
    
    "Black":
        $ 'black-hair' = True
        
        "You chose black hair!"
        
        jump eye_color
    
    "Blue":
        $ 'blue-hair' = True
        
        "You chose blue hair!"
        
        jump eye_color
        
label eye_color:
    
menu:
    "Now, what eye color?"
    
    "Pink":
        $ 'pink-eyes' = True
        
        "You chose pink eyes!"
        
        jump player_result
    
    "Gray":
        $ 'gray-eyes' = True
        
        "You chose gray eyes!"
        
        jump player_result
        
label player_result:
    
    "Now you're done!"
    
    "Let's see if this worked, now."
    
    show heroine
    
    "Is this correct?"

    return

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Customizable player character? Layering images?

#4 Post by philat »

It should be

$ hair-color = "black-hair"

not "black-hair" = True

User avatar
inkbrush
Regular
Posts: 60
Joined: Tue Jul 08, 2014 3:28 am
Contact:

Re: Customizable player character? Layering images?

#5 Post by inkbrush »

Okay, I got everything working now, thank you!!

User avatar
Steamgirl
Veteran
Posts: 322
Joined: Sat Jul 28, 2012 4:39 am
Completed: My Cup of Coffee, Queen at Arms (co-wrote a battle scene)
Projects: Stranded Hearts, Emma: A Lady's Maid
Deviantart: steamgirlgame
Contact:

Re: Customizable player character? Layering images?

#6 Post by Steamgirl »

Yay! Glad to hear it! I love customising my character in a game - so look forward to playing the end result one day! ^_^

Post Reply

Who is online

Users browsing this forum: elcharlo