Snake Game With Queues
The classic game of Snake. Move a "snake" (line of sprites) along a 2D grid attempting to run over a randomly placed objects (apple, bombs) to help it grow or shrink.
If the snake runs into itself the game is over and the player has lost.
The objective of the game is to make the snake as big as possible.
Learning Goals
- Loops, Conditionals and minimally struct/classes
- Linked lists
- Queues (to change the snake size)
- Detect collisions
Programming
Tasks
- Initialize a 2D array the size of your game grid.
- Initialize the NamedColors of your background, snake, and object.
- Create a function that makes the snake move continuously forward (4 possible directions),
and controls the snake's body insuring it trails along behind its head.
- Functions to locate and detect objects in the grid (apple, bomb).
- Functions to grow or shrink the snake size
- Implement a condition which triggers a game over if the snakes head collides
with its body.
More Details to Get You Started
###Key Press Events - NonBlocking Games
- keyUp()
- keyDown()
- keyLeft()
- keyRight()
###Variables, Colors, and Sprite Symbols
- NamedSymbol.symbolname;
- NamedColor.colorname;
- drawObject(column, row, NamedSymbol, NamedColor);
- setBGColor(column, row, NamedColor);
###Important Functions
- The gameLoop() function loops until the game is over.
- quit() stops the game.
- start() starts the game and calls the initialize() function once before it starts the gameLoop() function.
- render() sends your updated game grid to the server once. This is a blocking game function.
Help
For Java
NamedSymbols
NamedColors
NonBlockingGame
For C++
NamedColor
NamedSymbol
NonBlockingGame documentation
For Python
NamedColor
NamedSymbol
NonBlockingGame documentation