Jump to content
  • Advertisement
Sign in to follow this  
fooman_69

Where do you store collision detection??

This topic is 4884 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

hello, I am at the point in my first "real" game where I have to determine when things should blow up! haha I'm not sure what class to store the collision detection in. I have a Sprite class that holds basic info such as texture coords (bottom, top, left, right, textID etc), and I have an Entity class that does more involved things with the characters such as animation and whatnot. I have decided to shoot for pixel-level CD because I think I'd learn a lot, and for my game it'd help me a lot on the aftermath-of-the-explosion graphics (buildings being damaged). I figured I would store the CD in the Sprite class, so I could work with the Sprites of the buildings, which aren't Entity's. I am completely new at collision detection, so please explain anything you wish on this topic. I have read as many articles on 2D CD as I could find here, so if you have any that may be tucked away deep in the net, send em here!!

Share this post


Link to post
Share on other sites
Advertisement
You could do it a number of ways depending on what type of collision detection you are implementing, if you doing just simple bounding box collision, i'd got for a boundingbox class, and then whack an instance of that in your 3D Object base class, and when the model is loaded, add your points to the bounding box, then you can implement the collision in the bounding box class... you can do the same with spheres too...

so many ways tho... my advise is investigate a whole bunch of options and either choose one, or invent your own ;-)

Share this post


Link to post
Share on other sites
I'm doing simple(r) 2D detection. I think I may just go alone on it because I have a few ideas, but you guys usually give me a heads up on things I would have overlooked.

Share this post


Link to post
Share on other sites
There are approximately 341,228 ways to organize collision detection. I think i'm on my 4th iteration of my basic collision system for my project.

For you though, i would create a new CollisionObject and inherit from that. I would not integrate it into the Sprite object because you will doubtless have a lot of sprites that have nothing to do with collision detection (explosions, animation, particles, background objects, etc.). You don't want a glob of collision detection info associated with each object when it's never going to get used.

However, if you really wanted per-pixel collisions, you need to tap into the actual sprite data somehow, so combining Sprite + CollisionObject makes sense. You might just have your collision system be a simple set of stand-alone functions like CheckForCollision(Sprite,Sprite). Of course, unless you are making a game like Lemmings, there are usually better ways to do collision detection that checking every single pixel (IMHO).

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!