tags:

views:

39

answers:

1

Hey guys, I'm working on tile collision. Currently, I just draw the tile map the normal way (two for loops) and there is no scrolling. Right now, to check if my player is over a tile, I use tileX = (int)person1v.X / 16; tileY = (int)person1v.Y / 16; However, I want to detect collision before I hit the tile so it could act as a wall. How do I detect collision before even making the move?

A: 

If the player moves 3 pixels at a time then check for:

leftTile = (int)(person1v.x - 3) / 16;

And for the tile to the right:

rightTile = (int)(person1v.x + 3 + 16) / 16;
bitc