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 01:31] – [Gamepad input] gsalce | 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 82: | Line 86: | ||
The screen on vircon32 is 640 by 360, however, you do not have to type these out every time you make a game in vircon32 as they are stored in the screen_width and screen_height variables respectively. One way of bounds checking is to see where you are about to spawn the snake' | The screen on vircon32 is 640 by 360, however, you do not have to type these out every time you make a game in vircon32 as they are stored in the screen_width and screen_height variables respectively. One way of bounds checking is to see where you are about to spawn the snake' | ||
====Handling motion==== | ====Handling motion==== | ||
+ | To handle motion you could do: | ||
+ | <code c> | ||
+ | int SnakeX; | ||
+ | |||
+ | if( Right) | ||
+ | { | ||
+ | |||
+ | SnakeX = SnakeX + 20; | ||
+ | |||
+ | |||
+ | } | ||
+ | </ | ||
====Score Display==== | ====Score Display==== | ||