i found an awesome code in the cookbook changed it up just the slightest and the problem is i cant figure out how to keep going.
heres the link to the code: viewtopic.php?f=51&t=14559
my problem is that i would like the sprite to be able to emote, and someone in the topic actually posted about how to do that but i have no idea how to read this.
this is how i TRY to use the code and the expressions dont workpyopyon wrote:Yep! I asked this question earlier in another thread, so I'll leave it here.
qirien wrote:OK, this is actually simpler than I though, but involves using python, not Ren'Py. Unfortunately, we can't do what Asceai suggested because we are using a DynamicDisplayable, and im.FactorScale only works on images...
But, what you can do is add the following function in your code (I put it right before the draw_char):Now we need to have your draw_char functions call this one, like this:Code: Select all
def get_expression(): if (pov_expr == "default"): return "default.png" else: return "%s.png"%pov_expr
Now the only thing left to do is modify pov_expr whenever we want the character to change their expression. For example, in your code, you would put something like this:Code: Select all
def draw_char_side(st, at): # same thing as above, just scaled and positioned for the sideimage; there's probably more elegant solution than this... return LiveComposite( (384, 674), (0, 375), im.FactorScale("base.png", .45, .45), (0, 375), im.FactorScale("skin%d.png"%skin, .45, .45), (0, 375), im.FactorScale(get_expression(), .45, .45), (0, 375), im.FactorScale("eyes%d.png"%eyes, .45, .45), (0, 375), im.FactorScale("other%d.png"%other, .45, .45), (0, 375), im.FactorScale("pants%d.png"%pants, .45, .45), (0, 375), im.FactorScale("shirt%d.png"%shirt, .45, .45), (0, 375), im.FactorScale("jacket%d.png"%jacket, .45, .45), (0, 375), im.FactorScale("hair%d.png"%hair, .45, .45) ),.1
Basically, whatever filename you want it to use for the expression, set pov_expr to that without the ".png".Code: Select all
# Expression One $ pov_expr = "frown" char "Seriously, I'm super dissatisfied right now!" char "Go get me chocolate!" # Expression Two $ pov_expr = "happy" char "Aww- you got me chocolate?" char "You're so nice!! I didn't expect it at all!" # Expression Three $ pov_expr = "blawk" char "W-what do you mean you got it because I was cute?!" char "Don't joke so much!"
Code: Select all
init python:
dressup_button_show = False
hair, glasses, tie, shirt, pants = 1, 1, 1, 1, 1 # default dressup items
hair_styles_num, glasses_styles_num, tie_styles_num, shirt_styles_num, pants_styles_num = 7, 4, 4, 3, 3 # number of styles (files) for each dressup item
# define images as:
# "base.png" for the base image
# "hair1.png", "hair2.png", "hair3.png", ... - start with 1 and end with (hair_styles_num)
# "glasses1.png", "glasses2.png", "glasses3.png", ... "tie1.png", "tie2.png", ... "shirt1.png", "shirt2.png", ... "shirt1.png", "pants2.png", ...
def get_expression():
if (pov_expr == "default"):
return "default.png"
else:
return "%s.png"%pov_expr
def draw_char(st, at): # combine the dressup items into one displayable
return LiveComposite(
(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
),.1
def draw_char_side(st, at): # same thing as above, just scaled and positioned for the sideimage; there's probably more elegant solution than this...
return LiveComposite(
(361, 702),
(10, 550), im.FactorScale("base.png", .45, .45),
(0, 375), im.FactorScale(get_expression(), .45, .45),
(10, 550), im.FactorScale("glasses%d.png"%glasses, .45, .45),
(10, 550), im.FactorScale("hair%d.png"%hair, .45, .45),
(10, 550), im.FactorScale("shirt%d.png"%shirt, .45, .45),
(10, 550), im.FactorScale("tie%d.png"%tie, .45, .45),
(10, 550), im.FactorScale("pants%d.png"%pants, .45, .45)
),.1
init:
image wojo = DynamicDisplayable(draw_char) # using DynamicDisplayable ensures that any changes are visible immedietly
$ wojo = Character('Wojtek', color="#c8ffc8", window_left_padding=180)
label start:
"It's a beautiful day when you finally wake up at almost 2PM."
"The sun is peeking into your room and birds are signing."
"Your plan for the day is meeting your girlfriend and actually spending time outside for once."
"You better hurry as your head is a literal bird's nest and you should be meeting her in an hour."
show wojo
wojo "dang i gotta do something with my hair."
show screen dressup_button
$ dressup_button_show = True
label cont:
wojo "La, la, la!"
jump um
screen dressup_button: # a button to call the dressup game
if dressup_button_show:
vbox xalign 0.01 yalign 0.01:
textbutton "Change look." action ui.callsinnewcontext("dressup")
label dressup:
show wojo
python:
# display the arrows for changing the dress:
y = 50
ui.imagebutton("arrowL.png", "arrowL.png", clicked=ui.returns("hairL"), ypos=y, xpos=400)
ui.imagebutton("arrowR.png", "arrowR.png", clicked=ui.returns("hairR"), ypos=y, xpos=800)
y += 80
ui.imagebutton("arrowL.png", "arrowL.png", clicked=ui.returns("glassesL"), ypos=y, xpos=400)
ui.imagebutton("arrowR.png", "arrowR.png", clicked=ui.returns("glassesR"), ypos=y, xpos=800)
y += 80
ui.imagebutton("arrowL.png", "arrowL.png", clicked=ui.returns("tieL"), ypos=y, xpos=400)
ui.imagebutton("arrowR.png", "arrowR.png", clicked=ui.returns("tieR"), ypos=y, xpos=800)
y += 80
ui.imagebutton("arrowL.png", "arrowL.png", clicked=ui.returns("shirtL"), ypos=y+80, xpos=400)
ui.imagebutton("arrowR.png", "arrowR.png", clicked=ui.returns("shirtR"), ypos=y+80, xpos=800)
y += 80
ui.imagebutton("arrowL.png", "arrowL.png", clicked=ui.returns("pantsL"), ypos=y+160, xpos=400)
ui.imagebutton("arrowR.png", "arrowR.png", clicked=ui.returns("pantsR"), ypos=y+160, xpos=800)
ui.textbutton("Return", clicked=ui.returns("goback")) # image button version: ui.imagebutton("return.png", "return_hover.png", clicked=ui.returns("goback"), ypos=0, xpos=0)
$ picked = ui.interact()
# based on the selection, we increase or decrease the index of the appropriate dress up item
if picked == "hairL":
$ hair -= 1 # previous hair
if picked == "hairR":
$ hair += 1 # next hair
if hair < 1: # making sure we don't get out of index range (index 0 is not allowed)
$ hair = hair_styles_num
if hair > hair_styles_num: # making sure we don't get out of index range (index musn't be bigger than hair_styles_num)
$ hair = 1
if picked == "glassesL":
$ glasses -= 1
if picked == "glassesR":
$ glasses += 1
if glasses < 1:
$ glasses = glasses_styles_num
if glasses > glasses_styles_num:
$ glasses = 1
if picked == "tieL":
$ tie -= 1
if picked == "tieR":
$ tie += 1
if tie < 1:
$ tie = tie_styles_num
if tie > tie_styles_num:
$ tie = 1
if picked == "shirtL":
$ shirt -= 1
if picked == "shirtR":
$ shirt += 1
if shirt < 1:
$ shirt = shirt_styles_num
if shirt > shirt_styles_num:
$ shirt = 1
if picked == "pantsL":
$ pants -= 1
if picked == "pantsR":
$ pants += 1
if pants < 1:
$ pants = pants_styles_num
if pants > pants_styles_num:
$ pants = 1
if picked == "goback":
return
jump dressup # we don't want to return on every click, this jump loops until we click on "back" button
label um:
"hope this works"
$ pov_expr = "3"
wojo "god darn it"
$ pov_expr = "angry"
those are the faces i tried making