I'm implementing collision detection with the map for my platformer. I have a method that generates a polygon on every tile and checks if the player hits it -- that's all fine. The problem is that when ever a player touches a wall in front of him the d key which moves him to the front gets disabled so he can't walk any further that way.
This method works great for preventing him from walking into walls, but I also want him to be able to jump on the walls and there is the problem. So he falls on the tile(polygon) the game senses that and applies the same method for the d key, preventing the character from walking left or right, because the game thinks it is hitting the tile in the front but it is hitting from above.
Long story short, the game handles collision from above same as from the front or back. How do I make it recognise collisions from the side separately from above?
My code is along these lines:
if(PlayerPolygon.interesects(TiledPolygon) && dKey==1) {
moveX = 0;
}
if(dKey==1) {
player.x +=moveX
}