You are on page 1of 3

init python:

dressup_show = False
dressup_button_show = False
hair, glasses, tie, vest, skirt = 1, 1, 1, 1, 1 # default dressup items
hair_styles_num, glasses_styles_num, tie_styles_num, vest_styles_num,
skirt_styles_num = 8, 3, 6, 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", ...
"vest1.png", "vest2.png", ... "skirt1.png", "skirt2.png", ...
def draw_girl(st, at): # combine the dressup items into one displayable
return LiveComposite(
(257, 560), # image size
(0, 0), "base.png",
(0, 0), "hair%d.png"%hair, # (0, 0) is the position of each dressup item.
Because these images are saved with spacing around them, we don't need to
position them.
(0, 0), "glasses%d.png"%glasses,
(0, 0), "tie%d.png"%tie,
(0, 0), "vest%d.png"%vest,
(0, 0), "skirt%d.png"%skirt
),.1
def draw_girl_side(st, at): # same thing as above, just scaled and positioned
for the sideimage; there's probably more elegant solution than this...
return LiveComposite(
(257, 560),
(10, 400), im.FactorScale("base.png", .45, .45),
(10, 400), im.FactorScale("hair%d.png"%hair, .45, .45),
(10, 400), im.FactorScale("glasses%d.png"%glasses, .45, .45),
(10, 400), im.FactorScale("tie%d.png"%tie, .45, .45),
(10, 400), im.FactorScale("vest%d.png"%vest, .45, .45),
(10, 400), im.FactorScale("skirt%d.png"%skirt, .45, .45)
),.1
init:
image girl = DynamicDisplayable(draw_girl) # using DynamicDisplayable
ensures that any changes are visible immedietly
$ girl = Character('Girl', color="#c8ffc8", window_left_padding=120,
show_side_image=DynamicDisplayable(draw_girl_side))
screen dressup_button: # a button to call the dressup game
if dressup_button_show and not dressup_show:
vbox xalign 0.01 yalign 0.01:

textbutton "Change look." action SetVariable("dressup_show", True)


screen dressup:
if dressup_show:
add "girl" xalign 0 yalign 0 xpos 60
python:
# set all the values to change styles to previous / next version:
hair_n = hair + 1 # if next hair is chosen
hair_p = hair - 1 # if previous hair is chosen
if hair_p < 1: # making sure we don't get out of index range (index 0 is not
allowed)
hair_p = hair_styles_num
if hair_n > hair_styles_num: # making sure we don't get out of index range
(index musn't be bigger than hair_styles_num)
hair_n = 1
glasses_n = glasses + 1
glasses_p = glasses - 1
if glasses_p < 1:
glasses_p = glasses_styles_num
if glasses_n > glasses_styles_num:
glasses_n = 1
tie_n = tie + 1
tie_p = tie - 1
if tie_p < 1:
tie_p = tie_styles_num
if tie_n > tie_styles_num:
tie_n = 1
vest_n = vest + 1
vest_p = vest - 1
if vest_p < 1:
vest_p = vest_styles_num
if vest_n > vest_styles_num:
vest_n = 1
skirt_n = skirt + 1
skirt_p = skirt - 1
if skirt_p < 1:
skirt_p = skirt_styles_num
if skirt_n > skirt_styles_num:
skirt_n = 1
# display the arrows for changing the dress (we could also use one
imagemap, instead of a bunch of imagebuttons):
y = 50

ui.imagebutton("arrowL.png", "arrowL.png", clicked=SetVariable("hair",


hair_p), ypos=y, xpos=50)
ui.imagebutton("arrowR.png", "arrowR.png", clicked=SetVariable("hair",
hair_n), ypos=y, xpos=250)
y += 80
ui.imagebutton("arrowL.png", "arrowL.png", clicked=SetVariable("glasses",
glasses_p), ypos=y, xpos=50)
ui.imagebutton("arrowR.png", "arrowR.png", clicked=SetVariable("glasses",
glasses_n), ypos=y, xpos=250)
y += 80
ui.imagebutton("arrowL.png", "arrowL.png", clicked=SetVariable("tie",
tie_p), ypos=y, xpos=50)
ui.imagebutton("arrowR.png", "arrowR.png", clicked=SetVariable("tie",
tie_n), ypos=y, xpos=250)
y += 80
ui.imagebutton("arrowL.png", "arrowL.png", clicked=SetVariable("vest",
vest_p), ypos=y, xpos=50)
ui.imagebutton("arrowR.png", "arrowR.png", clicked=SetVariable("vest",
vest_n), ypos=y, xpos=250)
y += 80
ui.imagebutton("arrowL.png", "arrowL.png", clicked=SetVariable("skirt",
skirt_p), ypos=y, xpos=50)
ui.imagebutton("arrowR.png", "arrowR.png", clicked=SetVariable("skirt",
skirt_n), ypos=y, xpos=250)
ui.textbutton("Return", clicked=SetVariable("dressup_show", False))
label start:
show screen dressup_button
show screen dressup
$ dressup_button_show = True
$ dressup_show = False
label cont:
girl "La, la, la!"
girl "La, la, la."
jump cont
return

You might also like