Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So here is the deal. I've been working on and off on my little platformer and im at the point for collision detection with the map. I have a method that generates a polygon on every tile and checks if the player hits it it's all fine there. But the problem is that when ever a player touches a wall in front of him the D key wich moves him to the front gets disabled so he can't walk any further that way. this method works great for preventing him to walk 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 thus preventing the character to walk left or right because the game thinks it is hitting the tile in the front but i is hitting from above (i'm sorry a little vague i'm not good at english). Long story short the games handles collision from the top the same as collisions from front or back because i don't have an idea how to make a method that would make it able to recognize collisions from the top or side. i hope you guys can help if further explantion is needed please ask. Thank you!

This is my code i don't have directly acces to it but it is along the lines of this

if(PlayerPolygon.interesects(TiledPolygon) && dKey==1) {
         moveX = 0;
}
if(dKey==1) {
  player.x +=moveX
}
share|improve this question
 
Code would be nice. Initial idea is to have two functions. One to detect vertical collision, and one to detect horizontal collision. –  mobo Oct 6 at 19:50
 
i added some code... not the ideal code but i hope you get the idea but hwo woudl i make a method that knows when i hit it form the side of top using the same hitboxes –  jan vos Oct 6 at 20:00
 
That isn't much code, What is your intersects method? Whats dKey? How is moveX used? –  mobo Oct 6 at 20:18
 
i'm using slick2d's intersect method so i don't really know much about that dKey is just the d key on your keyboard i will add the move method too. –  jan vos Oct 6 at 20:31

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.