Snake 3D

OpenGL 3D Sanke Game
OpenGL 3D Sanke Game

This is a customized and 3D version of classic well-known game so called SNAKE, which was very popular specially by the handheld game consoles and Nokia cell phones. The player should maneuver the snake through obstacles and eat as much fruits or bugs to the required threshold score to become eligible of passing to the next level within a cretin period of time. Different fruits could have different values and also a clock sometimes appeared to help the player increase the time limitation through eating it. While the player passes the required score threshold, a golden key will be available within the environment and when the snake eats that golden key the gate will be opened to let the snake pass to the next level. The snake’s length will increase while eating fruits to gain more scores. The snake’s body is considered as a primary obstacle that makes the game much more difficult as the player progress through it.

The game is developed with pure C/C++ programming language. The only library used is OpenGL and freeglut/glut. It is possible to compile the game for different platforms from Microsoft windows to Linux and Mac OS. Even you could compile it for smartphones and WINRT devices as well.

The basic development of the game backs to my BS.c. studies in University where my knowledge of C++ programming and Computer Graphics were insufficient. So, if you find some weird and outdated design pattern or programming issues please, overlook and leave me a comment. I would try to fix them as soon as possible.

Since, the game was developed with a simple logic, I decided to share the source code in Github so, that it could be useful for novice developers or learners of OpenGL and Computer Graphics. Before uploading the game, I have changed many obsolete codes from the old one, which the development dates were back to about 10 years ago. Unfortunately, I do not have the time to review the entire source codes and make the necessary changes. In order to make the compilation much easier I have provided Makefile and Qt Project file as well. So any one could easily compile the source using g++ or Qt. I have also included binaries for Linux (deb distro) and Windows in case you want to give it a try before compiling the source code. Following, I am going to summarize some of the features used within games and give some hints for those interested in the source code.

You can download the per-compiled binaries (executable files) for windows x86/x64 and Linux Debian x64 from the links below. Follow the instructions for each platform to run the game.

Instructions for MS Windows (x86/x64, XP and later):

  1. Right click on the zip file and click “Extract files …” from the context menu
  2. Run the file: GL3DSnake.exe
  3. (Note: The only requirement for windows is freeglut.dll which is included with the zip file you already downloaded. But if you want you can download a new one from this link. I recommend you choose the one built with MSVC. The zip file name may start with the pattern freeglut-MSVC. Extract the zip file and copy freeglut.dll  to the same folder of the game executable or in a place reachable by windows path environment variable.)

Instructions for Linux Debian (Ubuntu, Mint & …):

  1. Extract the files: $ tar xvf
  2. Install freeglut: $ sudo apt-get update;sudo apt-get install freeglut3
  3. Give the binary en executable permision: $ sudo chmod +x ./GL3DSnake
  4. Run the file: ./GL3DSnake






BSD License.


Parts of this code were written in collaboration with my labmate in bachelor Alireze Sokhandan.

Add a Comment

Your email address will not be published. Required fields are marked *

Spelling error report

The following text will be sent to our editors: