I have a Tile Map in an array like so
Code: Select all
{0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0}
Code: Select all
newTile(x,y)
While the player can move freely throughout the map without any fixed movement.
Now that I have covered some background I can continue with my actual problem. I'm having no issues detecting if there is a collision but with actually solving the collision and determining which side the collision was detected.
My current approach is similar to as follows
Code: Select all
if(colliding(player, tile))
if(playerX + playerW >= tileX)
return rightSide
if(playerX <= tileX + tileW)
return leftSide
if(playerY + playerH >= tileY)
return bottomSide
if(playerY <= tileY + tileH)
return topSide
Code: Select all
if(checkSide() == rightSide)
// What now???
http://stackoverflow.com/questions/3403 ... -a-2d-grid