SDL Collision Detection

Started by
9 comments, last by wyrzy 19 years, 7 months ago
I actually did use color collision detection for one part of the last shooter game I made (in DirectX), and I think it worked out rather well. The problem I had, was how to detect the collision of 120 some tiny 3x3px bullets with a 10 to 20 enemies on the screen at once. The game was a top-down shooter, so I only checked a small box in front of the enemy to see if it was colliding with a bullet of a certain color. In this way, I was checking just a small section of the 10 to 20 enemies if they were colliding with a specific color, instead of making 1200-2400 rectangle overlap tests to see if each bullet was colliding with an enemy.

The general opinion of the thread seemed to be against color collision tests like this, but do you see why I used this approach -- 10 some tests compared to 1200 some tests. While some people have said this method would be slow, I would wait until it is actually slow for you. If you were making a 2D side scroller, it might be helpful to use this method if you make a map or something that has curves, and you want your player to gradually move up the curve. Well, you would just need to check color collisions near the player's feet (if he has feet), and adjust his position acordingly to make him gradually run up hills or down them. If you'd try to use rectangle collision for an arbitrary slope, I believe this would be more difficult. If anyone knows of an easy way to gently make a main character in a 2D game run/walk up/down hills in a different way, I would like to know how they do it. All the examples I've seen in 2D use color collision detection.

This topic is closed to new replies.

Advertisement