Sign in to follow this  

Collision Detection and Resolution - Need Help With Bugs

This topic is 2658 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

Hey Everybody!

I want to give a little intro to this first. So I've been working on my own 2D game development library in Java for months now. It's been a fairly steady project until I hit collisions. I had so much trouble I just put it off. It's been recently bugging me, so I've decided to turn here for some help from people who actually know what they are doing.

As far the coding I've done. I've a book about physics and collisions in games. However, the book was written with the intention of the reader using C++ and 3 dimensions. Heh. So I've adapted it all for Java and a 2D environment.

I have three main classes which handle collision: Contact, ContactResolver, and CollisionDetector.

CollisionDetector: Finds any sources of collisions (object with screen, object with object, object with scenery) for each frame and returns an array of Contacts which need to be resolved.

ContactResolver: Handed the array of Contacts and thusly resolves them.

Contact: Works behind the scenes; created in CollisionDetector.

However, as it stands, instead of CollisionDetector, I started with ScreenCollisionDetector as a hopefully easier start. All it's meant to do is find collisions with the different parts of the screen (top, bottomleft, right, etc). That creates an array of Contacts which are sent to ContactResolver. For reference, here's the code I have.

ScreenCollisionDetector: http://pastebin.ca/1930207
ContactResolver: http://pastebin.ca/1930208
Contact: http://pastebin.ca/1930209

Finally, very important, here's the implementation.
http://pastebin.ca/1930210

All the code compiles with no errors nor warnings, thus it's obviously a logic error.

If there's anything else I should post or questions you need to ask me, I'll be more than happy to answer. I shall truly thank anyone who can help solve this problem. Thanks in advance for any possible help.

Share this post


Link to post
Share on other sites

This topic is 2658 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.

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