Jump to content
  • Advertisement
Sign in to follow this  

Collision Detection and Resolution - Need Help With Bugs

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

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
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!