-
Tile Based game map
I was once again reading the Tile Maze tutorial on gametutorials.com. Though I have read it a few times I still dont understand how this line detects the collision with the WALL tiles:
Code:
// Check if we collided with a wall (Used the 2D to 1D index conversion)
if(g_BoardArray[player1->Index.x + player1->Index.y * BOARD_WIDTH] == WALL)
the code was slightly changed (just the x and y point names)
I understand how it gets the top left corner point but I don't understand how that tests for collision with the rest of the user controlled sprite.
If anyone could explai this to me I would be very greatful, Thanks.
-
I haven't read the tutorial, but I'm gonna assume that the player is always within one square, never spanning two:
Code:
The player is in (2, 0)
..P..
.....
.....
.....
Then the player moves down and to the right:
The player is in (3, 1)
.....
...P.
.....
.....
The player never is partway between these two squares.
-
Hey thanks, a quick response with diagrams, those are the best kind.:D