Sunday, July 15, 2012

Rudimentary snake game - simple analysis

This post analyzes a rudimentary c++ snake game that I found on youtube. A common asked question on several game developer fora is usually "where should I begin?". At the time, I was looking myself for some small and easy code that could show me opengl's useage in a game and get me going on the subject. Once I started to copy/implement/think about the snake code, I noticed what other interesting stuff where behind this code besides opengl.

E.g.: when you look at how the code has been put together, then you notice that the Field class actually contains all the objects that should be represented in the gameworld (snake blocks, fruit blocks and invisible blocks, all arranged in a 2 dimensional array of blocks). The Snake class on the other hand contains the code to actually manipulate and move all objects around in the gameworld. The Painter class knows how to draw and render the different objects. At last there is the Game class that manages all the events in the gameworld.

For now I' m still a bit naive concerning game engines, but I would definitely dare to see a parallel between a physics component of a game engine and the Snake class. Since the Snake class from this example also takes care of computing the next state of the different blocks in the gameworld.

If I would have to answer "where should I begin?", I would say: "Just do!". Nothing will give you more experience/insights/new questions then having a go at a challenge. During the process, don't be afraid of having a look at how others have solved several challenges before you...

I hope you enjoyed this second post.