Jump to content

  • Log In with Google      Sign In   
  • Create Account


Top down shooter and bullet collisions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 roby65   Members   -  Reputation: 154

Like
0Likes
Like

Posted 01 February 2012 - 05:00 PM

Hi,

i'm developing a 2d top down shooter and i implemented collisions using rects, and everytime something moves i test collisions with all the other rects.
The problem raised now that i have to add bullets to my game, my first approach was to get the points of the line of the bullet and test collision with every rect for every point of the line, but this is the worst implementation that i ever used.
What's the best approach for the bullet physic?

Roby

Sponsor:

#2 SimonForsman   Crossbones+   -  Reputation: 6066

Like
0Likes
Like

Posted 01 February 2012 - 05:32 PM

You might want to look at line/line intersection tests, (check the line the bullet is making against each line of the bounding rectangle for the possible target objects)

Then remember these simple facts:
1) The fastest code you can write is code that isn't executed
2) Objects that are far from eachother will not touch eachother
3) circle/circle collision tests or AABB tests are faster than line/line test. (and thus it makes sense to perform a quick rough test using one of these before you do a more expensive and accurate test)
4) If you partition your objects based on their location (using for example a tree structure) you can avoid testing colissions against objects that are far away very easily.
I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS