This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:comporg:spring2024:projects:mpg0 [2024/02/07 20:12] – [Handling motion] dwhite26 | notes:comporg:spring2024:projects:mpg0 [2024/02/08 02:32] (current) – [Game loop] rspringe | ||
---|---|---|---|
Line 7: | Line 7: | ||
====Game loop==== | ====Game loop==== | ||
+ | For this project, you will be making a Snake game. | ||
+ | The game loop for Snake is simple: you will control a snake around the screen to eat pieces of food. Once a piece of food has been eaten, your score will increase, and the snake will get longer. | ||
+ | |||
+ | The game ends when the head of the snake runs into either a wall, or another part of its body. | ||
====Sprites==== | ====Sprites==== | ||
Line 54: | Line 58: | ||
<code bash> | <code bash> | ||
if( var == 1 ) { | if( var == 1 ) { | ||
- | Snake.X -= PlayerSpeed; | + | Snake[0].X -= PlayerSpeed; |
} | } | ||
</ | </ | ||
Line 83: | Line 87: | ||
====Handling motion==== | ====Handling motion==== | ||
To handle motion you could do: | To handle motion you could do: | ||
- | <code/n> | + | < |
+ | int SnakeX; | ||
+ | |||
+ | |||
+ | if( Right) | ||
+ | { | ||
+ | |||
+ | SnakeX = SnakeX + 20; | ||
+ | |||
+ | |||
+ | } | ||
+ | </code> | ||
====Score Display==== | ====Score Display==== | ||