View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Collision detection for multiple objects/types of objects

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.

3 replies to this topic

### #1ChainedHollow  Members

Posted 04 November 2012 - 11:36 PM

Ive pretty much completed a tetris clone game and I did the collision just fine using a matrix and just checking if the areas are filled or not.
Then the last game I did still had 1 type of object that I stored in a vector and of course walls. So for collision detection I just cycled through the vector checking for collisions between the objects.
For more complex games I'm confused though.
For example a game with multiple objects and many types of objects. Not just walls and 1 object.
Maybe a character, bullets he shoots, enemies, etc. All these types of objects have to check collision between each other and handle the actions differently.

So my question is, can someone explain to me or suggest some articles on collision like this? Do I just always check every single object for a collision whether is near, far, relevant or not? Any help would be greatly appreciated! My goal is to get to the point where I can have the knowledge to be able to try making a sidescrolling shooter game, similar to MegaMan or Metroid, etc. Thank you!

### #2ultramailman  Prime Members

Posted 05 November 2012 - 12:11 AM

Ive pretty much completed a tetris clone game and I did the collision just fine using a matrix and just checking if the areas are filled or not.
Then the last game I did still had 1 type of object that I stored in a vector and of course walls. So for collision detection I just cycled through the vector checking for collisions between the objects.
For more complex games I'm confused though.
For example a game with multiple objects and many types of objects. Not just walls and 1 object.
Maybe a character, bullets he shoots, enemies, etc. All these types of objects have to check collision between each other and handle the actions differently.

So my question is, can someone explain to me or suggest some articles on collision like this? Do I just always check every single object for a collision whether is near, far, relevant or not? Any help would be greatly appreciated! My goal is to get to the point where I can have the knowledge to be able to try making a sidescrolling shooter game, similar to MegaMan or Metroid, etc. Thank you!

Nice article here
They even have some interactive examples there for you to play with

Edited by ultramailman, 05 November 2012 - 12:12 AM.

### #3DmitryNik  Members

Posted 05 November 2012 - 03:15 AM

Also, you might want to read real-time collision detection book written by Christer Ericson. There could be found some heads up.

### #4BeerNutts  Members

Posted 05 November 2012 - 04:37 PM

It's great to understand how collision detection works in games. You can look up "Spatial Hashing" for more information, on how to efficiently handle collisions.

However, I would also suggest to look at using a 2d physics library. These typically handle all movement and responses of physical objects. You are responsible for assigning it attributes (mass, size, shape, force, velocity, etc.) and it handles the movement and the collision detection. You can allow the engine to handle collisions (ie, have them bounce off each other if elastic), or you can register for a callback when a collision occurs, and do what your game needs to do.

IMO, it take much of the work and does it for you, and I won't make a game without it now. My favorite is chipmunk-physics, but other use Box2d as well.

Good Luck!
My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

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.