If we have configured properly Code::Blocks, installed the libraries and copied the file tileset.png on the same folder we should get that screen:
Finally we made it run! with the left mouse button we can add more cells to the map and with the right mouse button we pause /continue the game.
Obviously the project is very simple:
(The italic comments are things we are going to change in the following tutorials to upgrade the program)
- Initialize an instance of the (simple) engine class
- Set the graphics mode 800x600x32bpp (Set any graphics mode and Full Screen /Windowed mode)
- Load the tileset image(Load any tileset image)
- Define an array to store the cells(Load a world map)
- Process input > cell logic > Drawing
- The drawing process has those steps:
- Fill the backuffer with a colour (clear screen)
- Draw the cells (cellmap array)
- Draw the mouse
- Flip backbuffer to the screen
If you have read the code from the tutorials, and the previous posts now you should be able to create a new project with code::blocks and you should have an idea about using the sdl library: Initializing a graphic mode, loading images to surfaces, blitting those surfaces to the screen..
I don't want to get deeper into those topics because other people have already made very good tutorials about that (links in the sidebar), what i really want is to play with the pieces that will build later the game , we should have learned how to build a map with an array and how to draw the map on the screen.
In the next tutorial we will go a step beyond: Draw our "hero" on the screen in a multi-layered map using keyboard to move it, controlling the obstacles in the terrain, and drawing stats on the screen (drawing), now it should look like a top-down rpg.
Feel free to play with the Life Game code before starting with the next tutorial: Change screen resolution, activate the intermediate state drawing on the screen, use bigger maps... the best way to learn is to play with the code.