Sign in to follow this  
Stukey

Walking in a 2d game

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this