Dynamic Dress Up Framework

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.
Message
Author
Pippin123
Regular
Posts: 52
Joined: Sat Jan 31, 2015 7:33 pm
Contact:

Dynamic Dress Up Framework

#1 Post by Pippin123 » Mon Feb 23, 2015 1:10 pm

Here's a bit of code I made to handle character customisation and "dress up" minigames with the minimum of art assets and flexibiliy

Basic Structure:

A character class to handle "body specific" information like skin color, haircut, hair color etc, and an "inventory" that contains every clothing item the char is wearing.

Code: Select all

class PCstats(renpy.store.object):
        def __init__(self, name):
            self.name=name
            self.haircut="short"
            self.haircolor="white"
            self.skin="pale"
            self.lipstick="nude"
            self.wearing=[]
            
        def remove(self,clothes):
            if clothes in self.wearing:
                self.wearing.remove(clothes)
            return
        
        def wear(self,clothes):
            self.wearing.append(clothes)
            return
        
        def remove_all(self):
            list = [item for item in self.wearing if item.can_strip]
            if list!=[]:
                for item in list:
                    self.wearing.remove(item)
            return


A "clothing" class, that contains the name of the object, the path to the .png file, and it's drawing priority in compositing, so that you can add clothing in any order, and the vest will still draw over the t-shirt, etc...

Code: Select all

 class clothing(renpy.store.object):
        def __init__(self, name,pic,priority=10,can_strip=True):
            self.name=name
            self.pic=pic
            self.priority=priority
            self.can_strip=can_strip 
You can also create some "SFX" clothing items that cannot be removed normally ("can_strip=False"): e.g. scars, tatoos, wounds, blood...

For facial expression, eyes and mouth are stored separetly in transparent layers :
e.g. " eyes_angry_look right" or "mouth_smile" etc...

We can now define char image with associated tags:

Code: Select all

 $ seraphim = PCstats("Seraphim")
    
    image seraphim normal = DynamicDisplayable(draw_clothing,character=seraphim,art_path="seraphim/seraphim",mouth="normal",eyes="normal_straight")
    image seraphim angry = DynamicDisplayable(draw_clothing,character=seraphim,art_path="seraphim/seraphim",mouth="grit",eyes="angry_straight")
    image seraphim angry blushing = DynamicDisplayable(draw_clothing,character=seraphim,art_path="seraphim/seraphim",mouth="grit",eyes="angry_straight",blushing="light")

    image side seraphim normal = LiveCrop((102,41,150,150),"seraphim normal")
    image side seraphim angry = LiveCrop((102,41,150,150),"seraphim angry")
    image side seraphim angry blushing = LiveCrop((102,41,150,150),"seraphim angry blushing")

    define ser = Character(seraphim.name, color="#c8ffc8",image="seraphim",window_left_padding=150)
It's probably overkill if you don't plan to have a lot of different clothings options, facial expressions, but otherwise it allows a lot of flexibility:

- During your story, player and NPCs can "get a tan" , dye their hair, by simply changing a property
- Defining clothes as independent items allows for layering and transparency effects
- You can make some clothing items unlockable/buyable by mixing this system with a classic shop/inventory
- Face expressions are not tied to clothing.

Here's a full code with some art assets and exemple of use:
Dress Up - Cookbook.rar
(997.57 KiB) Downloaded 713 times
Hope it can be useful to someone

PS: The art assets are on the "skimpy" side, sorry...

edit: some people had trouble with the RAR archive, here's a zip.
Dress Up - Cookbook.zip
(1.1 MiB) Downloaded 335 times
Last edited by Pippin123 on Wed Jun 22, 2016 3:06 am, edited 2 times in total.

User avatar
Ryuushiro
Regular
Posts: 64
Joined: Fri Jun 29, 2012 8:24 pm
Completed: Artist for "Maid With Perfection", Artist for "Love and Romance: a study of intimacy", art for "Sleepier & Sleepier", Backgrounds for "Panzer Hearts", Sketch backgrounds for "Caramel Mokaccino DEMO
Projects: "Hunting Fable"
Tumblr: wafflemeido
Deviantart: WaffleMeido
Skype: wafflemeido
Location: Brazil
Contact:

Re: Dynamic Dress Up Framework

#2 Post by Ryuushiro » Mon Feb 23, 2015 5:46 pm

I just tested it and it works WONDERFULLY, Pippin123! :o

Thank you for your hard work~
________________

VISIT MY WEBSITE FOR COMMISSIONS: { HERE }
DeviantartPatreon
________________

Image

qilin
Newbie
Posts: 2
Joined: Sun Apr 05, 2015 5:41 pm
Contact:

Re: Dynamic Dress Up Framework

#3 Post by qilin » Sun Apr 05, 2015 6:16 pm

Thanks for sharing!! I love that powerarmor, awesome:)

By the way, do you have any use of terms on this recipe?

User avatar
qirien
Miko-Class Veteran
Posts: 510
Joined: Thu Jul 31, 2003 10:06 pm
Organization: Metasepia Games
Deviantart: qirien
Github: qirien
itch: qirien
Location: New Mexico, USA
Contact:

Re: Dynamic Dress Up Framework

#4 Post by qirien » Wed Apr 08, 2015 3:17 pm

Hey, this is really cool! We want to do something similar for our upcoming game, so we may adapt your code for it. :-)

I was thinking it would be even cooler if hair/skin color could be applied with filters...? It would allow the player a lot more choices, but maybe that would look funny. Might try it out!
Finished games:
Image
Image
Image
In progress: Our Personal Space 2: Space to Grow

Pippin123
Regular
Posts: 52
Joined: Sat Jan 31, 2015 7:33 pm
Contact:

Re: Dynamic Dress Up Framework

#5 Post by Pippin123 » Thu Apr 09, 2015 7:24 am

Yes, the color swap can apparently be done with functions through Hue and the like (im.Matrix I believe).
But then it's more a problem of me not being enough of a photoshop/Gimp artist to use it properly.

That would probably means separating the image layers between "base color" , "highlights" and "shadows" ...

Pippin123
Regular
Posts: 52
Joined: Sat Jan 31, 2015 7:33 pm
Contact:

Re: Dynamic Dress Up Framework

#6 Post by Pippin123 » Thu Apr 09, 2015 7:31 am

qilin wrote:Thanks for sharing!! I love that powerarmor, awesome:)

By the way, do you have any use of terms on this recipe?
Feel free to use it.

The Adeptas Sororitas power armor is part of a Warhammer40K game I have in mind.

Brother O'Fart
Newbie
Posts: 10
Joined: Thu Feb 19, 2015 10:55 am
Contact:

Re: Dynamic Dress Up Framework

#7 Post by Brother O'Fart » Wed Apr 15, 2015 6:17 am

Perhaps this is an unnecessary, even stupid question, but my curiosity is going to win this anyway: is it possible to have the kind of dress, etc. have any influence on the story line? For example: you're wearing a summer dress during the winter. As a result you get sick.

Pippin123
Regular
Posts: 52
Joined: Sat Jan 31, 2015 7:33 pm
Contact:

Re: Dynamic Dress Up Framework

#8 Post by Pippin123 » Wed Apr 15, 2015 11:13 am

Brother O'Fart wrote:Perhaps this is an unnecessary, even stupid question, but my curiosity is going to win this anyway: is it possible to have the kind of dress, etc. have any influence on the story line? For example: you're wearing a summer dress during the winter. As a result you get sick.
That would be easy, it just require a bit of advance planning.

You could :
-add a property to the clothes class (including a default value, to speed things up):

Code: Select all

class clothing(renpy.store.object):
        def __init__(self, name,pic,priority=10,can_strip=True,warm=True):
            self.name=name
            self.pic=pic
            self.priority=priority
            self.can_strip=can_strip 
            self.warm=warm
you would then define:

Code: Select all

$ winter_coat=clothing("Warm Coat","winter_coat.png")
$ summer_dress=clothing("Summer Dress","dress.png",10,True,False)
then you test if the item that char is wearing have the property warm.

Code: Select all

label winter_is_coming:
   python: 
       freezing=False
       for item in char.wearing:
            if not item.warm:
                 freezing=True
   if freezing:
        jump label_cold
   else:
        jump label_warm
There's probably some other way, with lists of "suitable clothings". The basic idea is that you test what's in the char.wearing list.

Brother O'Fart
Newbie
Posts: 10
Joined: Thu Feb 19, 2015 10:55 am
Contact:

Re: Dynamic Dress Up Framework

#9 Post by Brother O'Fart » Thu Apr 16, 2015 11:38 am

Thank you! I can only look with awe to your wisdom.

*Bows.*

:wink:

User avatar
stwkun
Regular
Posts: 73
Joined: Wed Jan 02, 2013 7:57 pm
Organization: Stw Projects
Contact:

Re: Dynamic Dress Up Framework

#10 Post by stwkun » Thu Apr 16, 2015 1:42 pm

Thanks for sharing :D
Visit my projects published in the different platforms
__________________________________________________________________________________

Image Image

Image Image

User avatar
Katta
Veteran
Posts: 499
Joined: Sat May 04, 2013 11:18 am
Tumblr: gamesbykatta
Deviantart: katjama
Contact:

Re: Dynamic Dress Up Framework

#11 Post by Katta » Thu Aug 06, 2015 6:02 pm

Sorry, I'm a noob, but what would the code be if I don't have a base and clothing/hair, but three different sprite images with their own sets of emotions and I want to choose between the three based on the choice?
(solved by ConditionSwitch)

Pippin123
Regular
Posts: 52
Joined: Sat Jan 31, 2015 7:33 pm
Contact:

Re: Dynamic Dress Up Framework

#12 Post by Pippin123 » Wed Aug 12, 2015 10:05 am

I'm not sure I understand fully what you want

You have a char that can be 3 possible sprites ?

Something like char1, char 2 char 3 and associated jpg char1_happy.jpg, char1_sad.jpg etc ?

In that case, defining your images with condition switch sounds indeed the simplest solution.

Code: Select all

$ char_choice=1
image char happy = ConditionSwitch(char_choice==1,"char1_happy.jpg",char_choice==2,"char2_happy.jpg",char_choice==3,"char3_happy.jpg")
Or were you asking for something else?

Pippin123
Regular
Posts: 52
Joined: Sat Jan 31, 2015 7:33 pm
Contact:

Re: Dynamic Dress Up Framework

#13 Post by Pippin123 » Wed Jun 22, 2016 3:07 am

I added a .zip version of the file due to request.
The .rar SHOULD work for everyone, but you never know

User avatar
screamingpenguin
Regular
Posts: 32
Joined: Mon Dec 11, 2017 5:11 am
Projects: DICE VN
Tumblr: screaming--penguin
Deviantart: screaming-penguin
Contact:

Re: Dynamic Dress Up Framework

#14 Post by screamingpenguin » Sun Feb 24, 2019 6:24 am

Hey! I'm sorry to bump an old thread, but this code is perfect for what I need!
However, one major problem;
When saving and exiting the game the character always resets to the defaults.. I've spent three very long days trying to figure out a workaround, but I'm not super experienced with coding so I've met countless dead ends..
Any advice on what to do to? ^^;

User avatar
Alex
Lemma-Class Veteran
Posts: 2515
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Dynamic Dress Up Framework

#15 Post by Alex » Sun Feb 24, 2019 7:41 am

screamingpenguin wrote:
Sun Feb 24, 2019 6:24 am
...When saving and exiting the game the character always resets to the defaults.. ...
The problem might be in a way you store your variables and all.
Check this links if not yet:
https://www.renpy.org/doc/html/save_load_rollback.html
https://www.renpy.org/doc/html/python.h ... -statement

Post Reply

Who is online

Users browsing this forum: No registered users