Advertisement Jump to content
Sign in to follow this  

dynamic collision detection(2d)

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

Hey guys, I am trying to make a class that detects collision for n amount of entities. I am having trouble figuring out how to do this. I was thinking something around:
class collision
        void add_entity(SDL_Rect);   // adds entity
        int check_collision(SDL_Rect);   // returns int based on collision, and where
But I'm not sure how to impliment it, any suggestions, tips, tutorials, etc. would be greatly appreciated. Joe

Share this post

Link to post
Share on other sites
You may be interested in the two N Tutorials on the topic -- Basic Collision Detection and Response and Grid-Based Collision Detection and Raycasting -- the second of which is probably more relevant to your current problem. The in-text snippets and provided sample code are in ActionScript but shouldn't be overly difficult for you to follow, and the actual explanations are quite well written. Check out the reference links at the bottom of the articles as well.

There are also a number of collision detection articles here at GDNet, but I've not read them and so can't recommend any in particular or comment on their quality or relevance.

Hope that helps. [smile]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!