Conway's Game of life
We have a few objectives to accomplish with the tutorial:
- Use Code::Blocks to create projects, add classes, configure libraries, etc.
- Setting up SDL with Code::Blocks
- Creating a simplistic game engine.
- Loading and displaying a image tile set on the screen.
- Basic use of mouse, keyboard, timing.
Our prerequisite for the tutorial is a simple tile set image:
I have made it using Gimp, we have 5 different tiles, from left to right: empty cell, living cell, new born cell, death cell and the mouse cursor.
Conway's Game of Life is a simulation of "living" cells, let's suppose our world is a big 2D grid, now let's suppose again that each cell in the grid can have 4 different states :
- 0 > Empty cell , a void in the map.
- 1 > A living cell.
- 2 > A new born cell.
- 3 > A dying cell.
Notice i have written a few lines of code with red color, I'm going to create a c++ class to encapsulate a simple engine so many SDL functions will be integrated in it, making easier the process to write programs; i have removed too code from the program to make it more readable, I will show the complete code later.
On the next post, our first Code::Blocks c++ project!