Technological Thoughts by Jerome Kehrli

Snake ! 0.2-alpha-0.1

by Jerome Kehrli

Posted on Tuesday Feb 23, 2010 at 11:40PM in OpenGL

Snake is a little C++/OpenGL project which shows a snake eating apples on a two dimensional board. It really is very much like the famous Nokia phone game except the snake finds its way on its own.

No nice textures, no sweet drawings yet. The world elements are mostly simple spheres. Trivial OpenGL features such as fog, lightning and shadows are implemented though.
Oh, and the snake it quite stupid at the moment. I wrote the path finding algorithm in an hour or so and I really need to come up with something smarter.

Snake screenshot

It still is a game as the "user" can at any moment deactivate the auto-pilot and take the control of the snake himself. This is a bit tricky though as the camera rotation makes it sometimes difficult to guess the directions mapping. (See hint at end of the post)

The project is open-source'd under GNU LGPL license and if you're interested in OpenGL, (soft-)realtime C++ programming or simple algorithms you might very well enjoy having a look at the source code provided here.

I'm not providing any pre-built executable yet, only the source code :

This project is provided as a standard *nix project and has a makefile (no configure script). To build it, just go in the root folder and type make.
The project needs the following libraries :,,,,

One can still compile it under windows with the help of the cygwin project. Take care of selecting the above libraries at the package selection step of the cygwin installation process.

User manual :

s - start/stop the camera rotation
o - turns the auto-pilot engine on/off
When auto-pilot is turned off, one can use u, h, j, k to control the snake

Hint :When controlling the snake manually, the snake always starts by going up. This is useful in order to know where the camera (point of view) stands and to let the camera do its rotation until you actually see the snake going up. You can then stop the camera rotation (using 's') and control the snake.

Happy snaking !

No one has commented yet.

Leave a Comment

HTML Syntax: Allowed