l3crafteur wrote:The first part
Still kinda vague. Maybe you can post the part of the code that seems unclear to you ?
But, read the tutorial carefully, as it is very detailled, IMHO.
Try the samples by yourself, tweak variables, as you may not get what is stated at the first sight.
Though, I can add some clarifications on the overall purpose of the tutorial.
The first step of the tutorial is to create a player, represented by a square, with methods to make him move.
Consider grid coordinates (player.grid_x,player.grid_y) represents where we want the player to move pressing a directionnal key.
In the update loop, each dt, the player is asked to move until (player.grid_x,player.grid_y are different from player.act_x,player.act_y.
The second part (Adding collision) maps a 2D array, using nested for loops. Values inside the map tables represents either a walkable location or an unwalkable location on the grid to be drawn later.
Function testMap performs a check when a key is pressed. Before the next move is authorized, this functions retrieves the value inside the map table located a the very cell we are attempting to reach. Yet it returns true if that cell was found walkable (meaning its value was different from 1), either it returns false (meaning value equals 1).
That's all I can say...