Jump to content
  • Advertisement
Sign in to follow this  
ismetteren

bounding rectangles - collision detection

This topic is 3637 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 have a game where i have used bounding rectangles for collision detection. But i dont think that i am doing it right and i have run into a problem. You can see a video of the game here:
as you can see the bounding rectangels are not turning with the tank. The code i am using for updating is so: boundingRect = new Rectangle(getXPos(), getYPos(), getWidth(), getHeight()); So the bounding rect is just taking some values that allready is stored and stores them agian. The only advantage is that because i am using Java, the Rectangle has an intersects method. The problem is that i now want to make the tanks aviable to create walls on the battlefield, and walls are some pretty long thin things, so it wont work if the bounding rectangle isent rotatet the same as the tank. because the rotate only visually rotates things while they keep the same x, y, width, height i can't just rotate the thing. am i doing this completely wrong?

Share this post


Link to post
Share on other sites
Advertisement
I'm no Java guy, but it is likely that the built in Intersect() method you refer to probably only works for axis aligned bounding boxes (i.e. not rotated).

Checking for intersections with non axis aligned boxes is not trivial. To do this manually, SAT is one way to go, but it is some work to implement.

However, a quick google turned up this library. There are probably several others.

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!