Collision detection testing question ?
I want to know how you handle the collision detection testing in your games ? For example, I have one player, one missile and one enemy on the map. What''s the best way for testing the collisions ? Test all entities againist all others or test just some entities ?
thanks,
blazter
Bounding box collision is the easiest way (if you''re using 2D sprites). It isn''t exactly ''perfect'' collision detection, but it gets the job done. Essentially you say: if the right most part of the missile is greater than the left most part of the enemy, then there is a missile collision with the enemy. You then do the same thing for the left top and bottom of the enemy with the missile.Doing this for every object in your game world could be quite slow so you can set restrictions like, this missile will never hit the player and the player can''t hit the enemy. This means that you must only check the missile with the enemy. 2/3 of your collision detections have been cut down. If you want exact bounding box collision detection code, email me and i''ll see what I can do. Cheers!
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Muzzafarath: it''s a 2d action game.
AnalGoat: thanks for the help, but I know how to handle the collision detections. The only problem was the collision testing between game entities. I''m trying to find an optimal method to take less CPU power.
AnalGoat: thanks for the help, but I know how to handle the collision detections. The only problem was the collision testing between game entities. I''m trying to find an optimal method to take less CPU power.
i would recomend u use sectors
u logicly divide your screen into sectors
each sectors is 2 times your biggest sprite
for each sector u should have an equivalent cell in a 2d
array.
every time u move a sprite it would reflect in the 2d array
every time u need to check for collision u check only the sprites that adjacent to the sprite u want (using the 2d array)
get it
good luck
u logicly divide your screen into sectors
each sectors is 2 times your biggest sprite
for each sector u should have an equivalent cell in a 2d
array.
every time u move a sprite it would reflect in the 2d array
every time u need to check for collision u check only the sprites that adjacent to the sprite u want (using the 2d array)
get it
good luck
0 error(s), 0 warning(s)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement