Jump to content
  • Advertisement
Sign in to follow this  
Stukey

Walking in a 2d game

This topic is 4517 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm just trying to find a simple rectangle collision detection concept. I'm writing it in visual basic but I can implement anything from psuedocode, I'm just having trouble thinking of it. Currently it looks like: create test rectangle from players position intersect test rectangle with blockmap (a bunch of other rectangles) of level *this is the problem* split into two paths depending on if width of the collision, or height of the collision is greater move the player back if the corresponding rectangle dimension will not move them back past their previous position depending on which direction they were moving in (dx and dy from 1 to -1 possible) The problem is where the if splits off, if the player skims just the edge of a block rectangle it will allow them to walk into the rectangle. I know why this happens, and I could probably fix it by just making the code a bit longer, but I was just wondering if there is anything simpler I'm completely overlooking. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Could you show how you're handling each case right now? I can't quite see what would cause the collision to fail like that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!