Frankly speaking, following and understanding the tutorial is nothing difficult. Getting all dll and header files in place is thrilling. I should say, until today GUI has been so advance, there is still such thing which is totally not user friendly. I start to admire Gamesalad and Scratch.
Now it is just a black dot moving around a tiled map with keyboard control and collision detection. I can start replacing the tile with something more appealing.
This tutorial of SDL is actually written quite practically (well at least to my experience). The tile is an external sprite sheet which I can edit with imaging software. The map is designed in an external txt file (which here is a .map file) which I can edit very easily. And all there will be loaded dynamically as the program initiates.
the sprite looks like this:
So I will just edit and replace it will this:
It is always good to know how it works and when I look at how it is actually coded, the code look exactly like what is in my mind. And the point is I can understand it very quickly and I do not need to code it myself.
So the code will manipulate the position of the image according to what the type a tile should be. It is similar to writing code to crop the file dynamically.
In the following function, the program import the .map file. I use a same name as the tutorial, the lazy.map, just to avoid any trouble if I change the name. The code is surprisingly simple. Just: std::ifsteam map(“lazy.map”); A bit like in flash. A lot simpler than those I use to look at when I am dealing with iOS app.
It looks like below when it runs again: