- Miko-Class Veteran
- Posts: 636
- Joined: Thu May 14, 2009 8:15 pm
- Projects: Castle of Arhannia
well to start with, I should mention that all the things that can be clicked on were placed in a list of things to be displayed, which was then changed based on what the player clicks on. this is how I got the game to work like a point and click game instead of a vn. if you're going to use puzzles as well, you'll need to think of some way of presenting it as well.
that said, the main things needed for the light puzzles were
1. colored square images
2. an sl screen to display them, and
3. something to keep track of the current state.
number 1 can be made in paint by choosing an arbitrary size, making a boundary, and making a version for each color. number.
for number 3, I like using nested lists. python's lists are really flexible so I never need to worry about anything complex going wrong. I also like using the arbitrary letters a and b when accessing them, though that's just random preference.
number 2 requires you to know a bit about python and sl, though not too deeply. sl is convenient enough to allow for loops, which makes going through lists really easy. besides that, you need to know how to check the state using if statements and how to use the most basic sl actions. the way it works is you check the state of each light and display an imagebutton with the right color (or a drag if you need the drag and drop functionality). the imagebuttons also need to jump to a label that changes the light's color and checks if the solution is correct
here's what each would look like, isolated from the rest of the system, using the two colors yellow and blue:
Code: Select all
label start: $ lightpositions = [[b, b, b, b, b], [b, b, b, b, b], [b, b, b, b, b], [b, b, b, b, b], [b, b, b, b, b]] $ position =  label lightchange: $ lightposition[position][position] = position if lightposition == [[b, b, b, b, b], [b, w, b, w, b], [b, w, b, w, b], [w, b, b, b, w], [b, w, w, w, b]]: jump win else: jump LabelForShowingPuzzle screen lightpuzzle: for a in range(len(lightpositions)): for b in range(len(lightpositions[a])): if lightposition[a][b] == "w": imagebutton: idle "lightw.png" hover "lightw.png" action [SetVariable('position', [a, b, 'b']), Jump('lightchange')] xpos (b * WIDTH) ypos (a * HEIGHT) if lightposition[a][b] == "b": imagebutton: idle "lightb.png" hover "lightb.png" action [SetVariable('position', [a, b, 'w']), Jump('lightchange')] xpos (b * WIDTH) ypos (a * HEIGHT)
the reason for using both idle and hover for the imagebuttons is because those are the minimal requirements for using imagebuttons.