I was just wondering, what is the best way to respond to 2d tile map collision in java.
I have the code setup so that when the Players Rectangle intersects with a Tiles Rectangle, which is part of a 2d array of Rectangles (Rectangle[][] collRects), the collision happens.
I know how to set that up, but when i run the program and the Player collides with a tile, the Player moves along the edge of the inside tiles and eventually goes through the collision Rectangles.
The way i am responding to collisions right now is:
- I check with if statements which side of the tile the player collided with.
- The Player has a speed variable, so i set to a value of zero on whatever axis the player was moving on before the collision.
I guess what i am trying to say is, what is the best way to respond to a collision?
Help would be greatly appreciated, thanks.