Clothing

god for images
http://webcache.googleusercontent.com/search?q=cache:8OpidJS\_ytoJ:lemmasoft.renai.us/forums/viewtopic.php%3Ff%3D51%26t%3D16604+&cd=9&hl=sv&ct=clnk&gl=dk

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\_girlnor(st, at): # combine the dressup items into one displayable
        return LiveComposite(
            (257, 560), # image size
            (0, 0), "base.png",

```
           (0, 0), "face1.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_girlhap(st, at): # combine the dressup items into one displayable
       return LiveComposite(
           (257, 560), # image size
           (0, 0), "base.png",
           (0, 0), "face2.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 normal = DynamicDisplayable(draw\_girlnor) # using DynamicDisplayable ensures that any changes are visible immedietly

```
   image girl happy = DynamicDisplayable(draw_girlhap)

```

    $ 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)

    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

```
```

            tie\_p = tie\_styles\_num
        if tie\_n > tie\_styles\_num:
            tie\_n = 1

```
               tie_p = tie_styles_num+10
           if tie_n > tie_styles_num+10:
               tie_n = 11

```

```
      button, when pressed:
          if color == "other color"
              tie = tie + 10
              color = "button color"
          elif color == "other color2"
              tie = tie +20
              color = "button color"
          elif color == "same color
              pass

```

        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))

```
 elif armup_show:
   add "girl" xalign 0 yalign 0 xpos 60
   python:

```

```
       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