GL Snake is a three dimensional variant of the old game nibbles, known also as snake for the diffusion of a similar version of the game on the first generation of nokia mobile phones. The game is composed by two applications. The fist one, called 'Player' is the actual game part which allows you to lead the snake inside each level trying to pick up all the items you will meet along your way. The player supplies two game modes, a classical one and a training mode. The classical game mode lets you advance your game along the various levels in a predefined sequence, from simple ones with very few obstacles, to more and more difficul levels, with the aim to obtain an high score. The training mode allows you to improve your skill in a particual level, and also to test your custom levels. Note that you cannot get an high score in training mode. The editor lets you create your own custom levels by adding walls, special items, specifying textures and so on. Custom levels needs to be saved inside the predefined "Levels" folder in order to make the player able to actually have visibility of them.
Let's look closer at the two applications.
The editor is certainly the more complex beetween the two applications. It uses Microsoft MFC libraries, for the window graphics interface, and OpenGL for the three dimensional context that shows the level scene.
Here you can see a view of how the application looks when at startup.

The main window is divided into four views through an MFC object of type CSplitterWnd with two rows and two columns. The upmost views have both an OpenGL context and hinerit from the same class, which handles tasks common for the both views ('setting' of the pixelFormat, create the OpenGL RC, properly manage the window resizing and distruction, etc..). Bottom views are instead simple CFormView objects.
The small pink cone at the center of the level floor represents the starting position of the snake, as other objects this element can be moved and rotated at our will.Now I'm going to describe more accurately each single view.
The upper left view is an editing view. It is inside this view that the majority of the interaction beetween the user and the scene takes place. The view offers an orthogonal projection of the scene, that doesn't deceive the user about the real proportions among objects. In this window, the user can select objects, erase the currently selected objects, or drag them from a position to another. Some of these operations are available also in the view beside, whilst other ones (as the dragging of objects) are peculiar to this view. A message in the status bar (the one on the bottom) keeps us always up to date about the execution of the action currently being executed. Pressing and holding down the middle mouse button on the edit view allows you to pan the current portion of the scene to access to further areas of the level, during panning a message on the status bar will inform about the current position of the center of projection. Zooming in and out is accessible via the mouseweel.
Some images:
![]()
Using the entries under the Options and Insert menu (or alternatively usint the corresponding three toolbar buttons), you can access to the three interaction mode with the window: selection, wall creation, and item insertion (after the insertion of an item the status comes back to selection mode).
Let's enumerate now the different modalities, togheter with the key combinations used to access them. Here are some images.
before selection:

after selection:

before button down:

after button release:

before item insertion:

after item insertion:

The upper right view allows you to have a preview of the final result you'll get. Here we have a perspective view of the level, together with the visualization of the textues applied above the objects, animations. The scene can be viewed from all angles using the trackball. Main operations available on this view are:
The bottom left view lets you specify the main options of the level, such as:
Texture parameters can be set in a small dialog window, accessible via the 'Texture properties' button, and showed here:

Talking about cubemaps usage, these ones will have actually effect only when the specified file follows the naming convention 'filename_XXXX.ext', where XXXX is one of the following strings: negx, negy, negz, posx, posy, posz, and if all the six image files, one for each cube side, lye in the same folder. To specify the cubemap you have only to select one of those files, the other five will be deduced by the common name suffix and extension.
Among game options, it is possible to set the number of 'classical' items that will be in the level at the same time, the rotation angle that the snake turns every time he does a turn (default value is 90 degrees), togheter with initial speed and length of the snake. Classical items have the same behaviour of items in the original game, they appear in ramdom position of the level and, each time the snake pick one of them, you gain more points, but in the meantime snake's lenght increases.
The last view (the bottom right one), refers to the current selection. According to the selected object (whose type is constangly showed in the upper side of this window), some groups of controls will be enabled or not. For walls, as an example, here will be available the controls concerning the texture, the group of controls regulating dimensions and rotation angle. For special Items, instead, only the last control will be enabled, this control will specify the type of the Item. Special Items are items with a particular behaviour, they appear always in the same position and at regular time intervals (the respawn time). In addition, when visible, if not picked during a certain time interval (TTL), these items disappear (till their next respawn). Special Items can have either positive than negative effects on the snake, they can increase or reduce lenght, increase or reduce snake speed, give extra lives, etc..). It will be to level designer's ability to put positive items in areas difficult to reach, and negative ones in those portions of the level that are prone to frequent transit of the snake (as fixed courses).
A small note about the editor functioning: it is important to consider that the editor doesn't execute any validity check on created levels. In particular, nothing prohibits the user for inserting walls and items outside the perimeter of the floor, and the same occurs for the starting position of the snake (represented by the small pink cone you can see in the panoramic view shown before).
Let's face a small step by step tutorial on the common tasks you will have to follow when creating your custom levels.
When we start the editor, we will see something similar to the first image seen in this description.
We start with clicking on the 'create wall' button![]()
Now the editor is in 'create wall' mode.
Now we click left mouse button on a point inside the level, on the EditGLView, and drag the mouse, with the button still pressed. At this point we should see a rectangle starting to form, when we are satisfied with the size of the wall we can release the mouse button. Here we can see a possible scenario of what will look the scene at this point:

We can see that the final corner of the rectangle is not in a perfect correspondence with the actual mouse position, this because by default the editor operates with a snap to grid option with a default value of the snap of 1. According to our preferences we can disable this function, or select different values for the snap. All these options can be accessed cam be accessed in the 'Grid' menu.
Now we try to change the texture of the floor:
Select the browse button ('...') on the bottom left view:

At this point a small popup dialog will be shown. This dialog will allow us to select the desired image file to apply to the floor, then we can click the ok button. Here we choiced a texture depicting some wood planks. The updated scene is now the following:

errr..the texture is being repeated too much times. No problems, let's click on the 'Texture properties' button and change the values corresponding to texture scaling, in our case we choice scaling factors of (0,1) horizontally and (0,2) vertically, here it is what we get:

Now we select the wall we created by clicking on it, as we can see, in the bottom right window, some controls are now enabled. Among these ones we will utilize the ones specifying the texture and proceed as done with the level floor. We can repeat the same operations with other walls. If we become aware that the size of a wall we created results not being suited for what we want to obtain, we can resize the wall selecting it and changing the width and height values accessible on the bottom right view. If we would delete it suffices to select it and press the 'Del' key. After some wall insertions the scene could look like this:

To insert the cubemap we have to add a tick on the proper check box int the bottom left view, at this point a default cubemap will be loaded. To select a specific cubemap we have to click on the browse button ('...') to select a file observing the gidelines described before, then click on the ok button.

Item insertion is quite simple, you only have to select the proper toolbar button and click on the desired point of the floor. After this you can specify the type of the item and its paramenters on the bottom right view.
The player is realized using the GLUT toolkit. When the game starts you can see the main menu. You can navigate among menu entries either by mouse or arrow keys. The player supplies two game modes, a classical one and a training mode. The classical game mode lets you advance your game along the various levels in a predefined sequence, from simple ones with very few obstacles, to more and more difficul levels, with the aim to obtain an high score. The training mode allows you to improve your skill in a particual level, and also to test your custom levels. You can move the snake by using the LEFT and RIGHT keys, whilst you can move the camera with the W A S D keys. F1 goes toggles beetween wireframe and solid modes, F2 toggles beetween classical bird's eye view and third person one. F4 toggles beetween fullscreen/windowed mode.
Snake's movement is quite different from the one of the original game. First of all I deliberately avoided that the game would carry out over a simple discrete grid, then I opted for a more realistic solution for the head movement. This choice prejudices a bit the gameplay, making items which appear very near to walls being more difficult to pick, but has a nice visual effect.
A video sample:
Let's look at some screenshot:
Starting menu (I know, quite a minimalistic one...):

here we can have a closer look at the main character of the game:

random levels:



documentation (PDF version of this page)
