Examples Snake


This is a reproduction of a type of arcade game called Snake. The first Snake game was Blockade, released in 1976, and many games use the same structure. In Snake games, the player controls the movements of a snake, represented in this example by a green line. The player’s goal is to collide the snake with a fruit, represented by a red dot. Each time the snake collides with a fruit, the snake grows longer. The player’s goal is grow the snake as long as possible without colliding the snake into itself or into the edges of the play area.

This example uses an array of vectors to store the positions of each of the segments of the snake. The arrow keys control the snake’s movement.