Traditionally, Snake has been played on a 2-D plane. My project will expand the gameplay by extending it into 3-D.
As with the classic snake games, the player must avoid the boundary, obstacles, and the snake's own tail while searching for and eating apples. Each apple consumed increases the length of the tail of the snake, increasing the challenge.
The project will be programmed in C++ and will use the OpenGL and GLUT libraries.
Snake is a semi-popular video game that originally came out in the late 1970s. In the game, the player controls a long, thin "snake" that continuously moves along the screen. The goal is to eat food items scattered around the field. Each time a food item is consumed, the snake's tail grows longer. The game ends if the snake collides with the boundary, an obstacle, or its own tail.
The main concept behind Snake has been around for a long time, and many versions and variants of the game exist. However, although there exist quite a few "3-D" Snake games, these games only render the snake as a three dimensional object (as opposed to a two dimensional sprite) but keep the snake's movement bounded on a 2-D plane. My project will attempt to break this limitation and allow the snake movement in a 3-D grid.
Since the movement is expanded into 3-D, the task of displaying the game properly is more important than ever. SnakeWorld offers two camera modes: "World View" and "Snake View." In the World View mode, the camera is placed outside of the game grid and looks inwards towards the center. But since it would be impossible to discern depth if the camera is stationary, the player is given partial control of the camera. The player controls the camera to move around in a spherical zone around the game grid. In the Snake View mode, the camera is attached to the head of the snake, so that the player virtually "sees" from the snake's perspective. In this mode, the camera keys make the snake look around (but without actually turning).
Another issue with expanding the game into 3-D is the controls. In either mode, there are four keys (wasd keys)to manipulate the camera. But actually controlling the snake is a bit more complicated. SnakeWorld offers two control schemes: "Absolute" and "Snake Relative." With the Absolute control scheme, each key corresponds to turning the snake towards a particular wall, no matter what orientation the camera is in. The keys 'i', 'j', 'k', and 'l' turn the snake towards the north, west, south, and east walls, respectively. 'u' (or 'o' works as well) turns the snake straight up (towards the sky blue wall) and 'm' (or ',' works too) turns the snake straight down (towards the grass green wall). The Snake Relative control scheme offers the same mobility, but uses fewer keys. The four arrow keys turn the snake up, down, left, or right relative to the head's facing and sense of "up." Some people may find this a more natural way to control the snake. Although possible to use in World View, these controls are better suited to be used in Snake View.
Another feature SnakeWorld provides is the option of turning on "smart" gridlines. When this option is on ('g' toggles this option on/off), three sets of gridlines are drawn, one for each of the three coordinate planes. Only the three coordinate planes that pass through the head of the snake are drawn, so they can be used to align and plan movement.
The mathematical basis for my project will mostly be on manipulating the "camera". The player will have a limited control of the camera; in World View, the camera will be able to move in a circle around the grid while looking directly into the center. The camera will also be able to move up and down in an arc. The complete movement of the camera is described as a sphere. In Snake View, the camera can be used to look around the snake. It's field of vision is described by a cone spanning 45 degrees from the horizontal with the camera being at the vertex.
"Snake (video game)." Wikipedia. http://en.wikipedia.org/wiki/Snake_(video_game).
"GLUT Tutorial." Lighthouse 3D. http://www.lighthouse3d.com/opengl/glut/.
"Basic Camera." CodeColony. http://www.codecolony.de/OpenGL/
Make sure all the files are in the same folder and use the provided Makefile to compile the game.
Guide the snake into the apples scattered around the grid to eat them. As you consume more apples, your snake grows larger and the game speed increases. The controls are as follows: