[tutorial] Dress up game
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.
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.
-
- Eileen-Class Veteran
- Posts: 1261
- Joined: Fri Mar 16, 2012 11:38 am
- Projects: Rika
- Organization: Solo (for now)
- IRC Nick: Trick
- Location: Tokyo, Japan
- Contact:
Re: [tutorial] Dress up game
I didn't get the meaning fully before, but now I do. Damn that's useful.
"We must teach them through the tools with which they are comfortable."
The #renpy IRC channel is a great place to chat with other devs. Due to the nature of IRC and timezone differences, people probably won't reply right away.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
Re: [tutorial] Dress up game
Recently, it was mentioned in another thread that exporting the character from Ren'Py to a PNG file might be interesting. Here's one way to do this...
First, we'll import some modules and redefine the draw_char() functions for our purpose:Basically, we store the image in a variable each time the player modifies the dress up selection. We also use the im.Composite manipulator instead of LiveComposite because the resulting image has a load() method that will be handy later.
The variable that controls if the image is flipped will be set in the start label:
Of course, we need to add some buttons:
Finally, inside the dressup label, we'll put the code to flip the image and export the character as a PNG file:
Edit 12/31/2012 : added some code to flip the image.
First, we'll import some modules and redefine the draw_char() functions for our purpose:
Code: Select all
import os, time, pygame
def draw_char(st, at): # combine the dressup items into one displayable
globals()["doll"] = im.Composite(
(361, 702), # image size
(0, 0), "base.png",
(0, 0), "glasses%d.png"%glasses, # (0, 0) is the position of a dressup item. Because these images are saved with spacing around them, we don't need to position them.
(0, 0), "hair%d.png"%hair,
(0, 0), "shirt%d.png"%shirt,
(0, 0), "tie%d.png"%tie,
(0, 0), "pants%d.png"%pants
)
if globals()["direction"] == -1:
globals()["doll"] = im.Flip(globals()["doll"], horizontal=True)
return globals()["doll"],.1
def draw_char_side(st, at):
return LiveComposite((361,702), (10,550), im.FactorScale(globals()["doll"], .45)),.1
The variable that controls if the image is flipped will be set in the start label:
Code: Select all
label start:
$direction = 1
Code: Select all
ui.textbutton("Flip", clicked=ui.returns("flip"), ypos=0, xpos=150)
ui.textbutton("Save as PNG", clicked=ui.returns("capture"), ypos=0, xpos=300)
Code: Select all
if picked == "flip":
$direction = -direction
if picked == "capture":
$pygame.image.save(doll.load(), os.path.join(config.basedir, "c%s.png") %(str(time.time()).replace(".", ""))) # The player can create many images successively, each of them will get a unique name.
return # This return is optional. Instead, we could play a sound and/or display the filepath.
Last edited by Another on Mon Dec 31, 2012 12:19 pm, edited 2 times in total.
- leon
- Miko-Class Veteran
- Posts: 554
- Joined: Sun Oct 09, 2011 11:15 pm
- Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
- Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
- Organization: Team ANARKY
- Contact:
Re: [tutorial] Dress up game
Wow, that could be very useful. Nice work!
Now we need a method for auto posting the image to Facebook, so people can spam their friends.
Re: [tutorial] Dress up game
Ooh, this could be handy!
-
- Regular
- Posts: 142
- Joined: Sat May 28, 2011 1:15 am
- Projects: Bliss Stage, Orbital Knights
- Contact:
Re: [tutorial] Dress up game
Well here's what I thought of..(now if only I could find a more efficient way to tint layered sprites lol)
Make some hues using the im.matrix objects. Name them, doesn't really matter what because...
Code: Select all
hue1 = im.matrix([ 1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0.85, 0.7, 1, 0, 0,
0, 0, 0, 1, 0 ])
Code: Select all
huearray = [hue1,hue2,hue3,hue4,hue5,hue6,hue7]
Code: Select all
dressup_show = False
dressup_button_show = False
hair, glasses, tie, vest, skirt, hue = 1, 1, 1, 1, 1, 0 # default dressup items
hair_styles_num, glasses_styles_num, tie_styles_num, vest_styles_num, skirt_styles_num, hue_styles_num = 8, 3, 6, 3, 3, 6 # number of styles (files) for each dressup item
Notice how I started at 0 and ended at 6? That's an array thing, it wants to count from 0, this one of the only two places we'll have to care.
Now we change the layer we want to use the matrix we have...
Code: Select all
def draw_girl(st, at): # combine the dressup items into one displayable
return LiveComposite(
(64, 64), # image size
(100, 100), "human_f.png",
(100, 100), im.MatrixColor("hair%d.png"%hair, huearray[hue])
Code: Select all
hue_n = hue + 1 # if next hair is chosen
hue_p= hue - 1 # if previous hair is chosen
if hue_p < 0: # making sure we don't get out of index range (index -1 is not allowed)
hue_p = hue_styles_num
if hue_n > hue_styles_num: # making sure we don't get out of index range (index musn't be bigger than hair_styles_num)
hue_n = 0
Code: Select all
y += 80
ui.imagebutton("frame.png", "frame.png", clicked=SetVariable("hue", hue_p), ypos=y, xpos=50)
ui.imagebutton("frame.png", "frame.png", clicked=SetVariable("hue", hue_n), ypos=y, xpos=250)
- kuzai
- Regular
- Posts: 85
- Joined: Sat May 12, 2012 8:15 pm
- Projects: Custom Lover, PuppyShipping DWH, Yu-Gi-Oh!: Chat
- Location: Canada
- Contact:
Re: [tutorial] Dress up game
so is there any way you can make the created character show up in big event scenes as well as in the game in normal ways? I hope i am wording this right.
I forgive and forget. Because I have a good heart and terrible memory
- leon
- Miko-Class Veteran
- Posts: 554
- Joined: Sun Oct 09, 2011 11:15 pm
- Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
- Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
- Organization: Team ANARKY
- Contact:
Re: [tutorial] Dress up game
Of course, you just use "show girl", assuming you are using the original version ironically I used a guy sprite in the sample.
To use facial expressions (well one way to do it) you can copy paste the function "draw_girl" and add expressions to each copy, then add definitions like
To use facial expressions (well one way to do it) you can copy paste the function "draw_girl" and add expressions to each copy, then add definitions like
Code: Select all
image girl happy = DynamicDisplayable(draw_girl_happy)
- kuzai
- Regular
- Posts: 85
- Joined: Sat May 12, 2012 8:15 pm
- Projects: Custom Lover, PuppyShipping DWH, Yu-Gi-Oh!: Chat
- Location: Canada
- Contact:
Re: [tutorial] Dress up game
and this works for event scenes as well? Like I don't mean just showing up as they normally do. Like in event scenes such as this
I forgive and forget. Because I have a good heart and terrible memory
- leon
- Miko-Class Veteran
- Posts: 554
- Joined: Sun Oct 09, 2011 11:15 pm
- Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
- Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
- Organization: Team ANARKY
- Contact:
Re: [tutorial] Dress up game
Oh, sorry. Didn't get what you meant before... We call these CGs around here because we are fancy like that.
Yes, it's pretty much the same concept. Just make sure to save each article of clothing/accessories from the layers with (transparent) spacing around them so you won't need to position them programmatically when using LiveComposite.
Yes, it's pretty much the same concept. Just make sure to save each article of clothing/accessories from the layers with (transparent) spacing around them so you won't need to position them programmatically when using LiveComposite.
- kuzai
- Regular
- Posts: 85
- Joined: Sat May 12, 2012 8:15 pm
- Projects: Custom Lover, PuppyShipping DWH, Yu-Gi-Oh!: Chat
- Location: Canada
- Contact:
Re: [tutorial] Dress up game
leon wrote:Oh, sorry. Didn't get what you meant before... We call these CGs around herebecause we are fancy like that.
Yes, it's pretty much the same concept. Just make sure to save each article of clothing/accessories from the layers with (transparent) spacing around them so you won't need to position them programmatically when using LiveComposite.
hmm I might need a script example of it. Because you pretty much lost me xD
I forgive and forget. Because I have a good heart and terrible memory
-
- Eileen-Class Veteran
- Posts: 1261
- Joined: Fri Mar 16, 2012 11:38 am
- Projects: Rika
- Organization: Solo (for now)
- IRC Nick: Trick
- Location: Tokyo, Japan
- Contact:
Re: [tutorial] Dress up game
If the body layer is 400x600, then make the clothing layer 400x600 too. That way you can position them perfectly in photoshop, and they'll line up nicely in renpy.
"We must teach them through the tools with which they are comfortable."
The #renpy IRC channel is a great place to chat with other devs. Due to the nature of IRC and timezone differences, people probably won't reply right away.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
- kuzai
- Regular
- Posts: 85
- Joined: Sat May 12, 2012 8:15 pm
- Projects: Custom Lover, PuppyShipping DWH, Yu-Gi-Oh!: Chat
- Location: Canada
- Contact:
Re: [tutorial] Dress up game
Hmm not exactly what I was asking but it's still helpful. Sorry for being a pest but How would one be able to make a character creator where you can choose the gender of the character?
I forgive and forget. Because I have a good heart and terrible memory
- leon
- Miko-Class Veteran
- Posts: 554
- Joined: Sun Oct 09, 2011 11:15 pm
- Completed: Visual Novel Tycoon, Night at the Hospital, Time Labyrinth, The Buried Moon, Left of Center, Super Otome Quest
- Projects: Lemon Project, Porcelain Heart, Dream's Dénouement
- Organization: Team ANARKY
- Contact:
Re: [tutorial] Dress up game
Example. It doesn't include a CG, but there really isn't any difference between a character showing normally or in a CG.kuzai wrote:hmm I might need a script example of it. Because you pretty much lost me xD
A very simple way to do it would be to use two base images (like base1.png and base2.png for male and female versions) and then use them as if they were dressup items. However, if you don't want to end up with guys wearing skirts and pink ribbons in their hair, you'll need to make quite a few changes to the code...kuzai wrote:How would one be able to make a character creator where you can choose the gender of the character?
Another very simple solution would be to have a choice to select the gender before the character creator and create one version for the character creator for each gender.
- kuzai
- Regular
- Posts: 85
- Joined: Sat May 12, 2012 8:15 pm
- Projects: Custom Lover, PuppyShipping DWH, Yu-Gi-Oh!: Chat
- Location: Canada
- Contact:
Re: [tutorial] Dress up game
ah thank you very much. I believe all of my questions are answered now. Again thank you
I forgive and forget. Because I have a good heart and terrible memory
- noeinan
- Eileen-Class Veteran
- Posts: 1153
- Joined: Sun Apr 04, 2010 10:10 pm
- Projects: Ren'Py QuickStart, Crimson Rue
- Organization: Statistically Unlikely Games
- Deviantart: noeinan
- Github: noeinan
- Location: Washington State, USA
- Contact:
Re: [tutorial] Dress up game
Hello, I am trying to fit all the code discussed here into one game file since I thought it was super cool!
I was able to add the "save as .pdf" section without any errors, although I couldn't tell where the file was saved or what it was named. Is there a default location, or did I need to add extra code to make it work?
Also, when putting in the hue code into the script, I suddenly get an error message:
If anyone could tell me what I am doing wrong, that would be greatly appreciated! Thank you. I have attached two game folders-- one before I put the hue code in and one after I put the hue code in.
I was able to add the "save as .pdf" section without any errors, although I couldn't tell where the file was saved or what it was named. Is there a default location, or did I need to add extra code to make it work?
Also, when putting in the hue code into the script, I suddenly get an error message:
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
File "game/script.rpy", line 42: is not terminated with a newline. (Check strings and parenthesis.)
return LiveComposite(
Ren'Py Version: Ren'Py 6.16.0.395
- Attachments
-
- Save PNG.rar
- (991.21 KiB) Downloaded 81 times
-
- Hue Error.rar
- (973.79 KiB) Downloaded 77 times
Who is online
Users browsing this forum: Google [Bot], Zahdernia