Sunday, October 5, 2008
Squeak Lab
Working with the program of Squeak over the next two weeks, I would like to try my hand at creating the classic game of Sammy the Snake. For this game, the user must be able to control Sammy with the 4 arrow keys. Sammy must be able to 'grow' when he eats the randomly appearing food. Whenever Sammy eats, the game must be able to keep track of the food eaten via a score board.
To build this game, key sensitive connections need to develop for user control. I forget which function this is, but it will need to connect to the arrows, which each change the direction of Sammy to 0°/90°/180°/270° (up/left/down/right). If Sammy "sees" his color (meaning, if he hits himself) or the wall, than the game is over. So there needs to be scripts that allows for this and a Game Over function. This also means there should be a Start Game script that is activated by any key stroke (or the space bar).
The thing I believe will be most challenging and requiring the need of a TA, will be programming the randomly placed 'food'. I think this will be similar to the function of the pong ball going in a random direction.
Any thoughts and assistance will be much appreciated.
Subscribe to:
Post Comments (Atom)
2 comments:
Great idea, I think the random placement of food won't be too difficult, I'll be talking a bit about how to create objects through scripts tomorrow. What I'm concerned about and haven't exactly figured out the details of is how to get the snake to "grow". My guess is that we can use the pen trails feature (leaves a line where the object goes) and have an object that sits at the end of the line which erases the line. When the snake is supposed to grow, you would have to pause the eraser object.
Scripting
Sammy: Home
Sammy's x=0
Sammy's y=-247
Sammy's heading toward 0 (up)
Sammy: Start Script "start"
Sammy: Start
Test World's lastKeystoke = [space]
If yes: Sammy: Start script "move" and Stop script "start"
Sammy: Move
Test Sammy's Sees Color (wall/green). If yes, Sammy goes "home"
Test Sammy's Sees Color (self/yellow). If yes, Sammy goes "home"
Sammy: Navigation
Test World's lastKeystroke = w. If yes, Sammy's heading "0"
Test World's lastKeystroke = d. If yes, Sammy's heading "90"
Test World's lastKeystroke = a. If yes, Sammy's heading "-90"
Test World's lastKeystroke = s. If yes, Sammy's heading "180"
World's lastKeystroke = qwert
Next Goals:
Sammy aims to collect food.
When Sammy eats food, Sammy gets longer and food relocates. Score increases.
If Sammy sees self or wall, Game Over. So need to connect "home" function to a Game Over function.
Post a Comment