Been working on a character creation system with the following vision: A series of pre-drawn characters from which the player can select using left/right arrows to cycle between the available characters.
My implementation strategy: create a list of image files for each of the characters, a function to cycle between those files, left and right buttons on a screen that activate the cycle function, and wrap all of that in a loop.
Python initialization part:
Code: Select all
init python:
# Hold all of the character images in a list
char_list = ["dummy_char_yellow.png","dummy_char_green.png","dummy_char_orange.png","dummy_char_blue.png"]
# As well as a position in the list that we are looking at
char_list_pos = 0
char = char_list[char_list_pos]
# simple cycling function to move through a list without falling off
def cycle(dir, clp, cl):
return (clp + dir)%len(cl)
Code: Select all
screen cycle_character_screen():
frame:
xalign 0.1 ypos 20
vbox:
text "Select a character image:"
grid 2 1:
textbutton "<":
clicked [SetVariable("char_list_pos", cycle(-1, char_list_pos, char_list)),
SetVariable("char", char_list[cycle(-1, char_list_pos, char_list)]),
Jump("stage_1")]
textbutton ">":
clicked [SetVariable("char_list_pos", cycle(1, char_list_pos, char_list)),
SetVariable("char", char_list[cycle(1, char_list_pos, char_list)]),
Jump("stage_1")]
Code: Select all
label stage_1:
image c = Image(char, xalign = 0.1)
show c
# if char:
# hide c
# with dissolve
# show c
# with dissolve
show screen cycle_character_screen
"Create your character! Begin by selecting an appearance and your preferred pronouns. currently on model [char]. \n\nWhen you are satisfied, press \"Confirm\" to proceed."
Issue: Currently, the image does not update even though the filename saved to "char" is being updated. What am I missing? Is there a smoother way to build this?
Thanks,
Kuma-sensei