This post is a portion of Part 12 in my on going series about 2D Game Development using the Allegro 5 library. These posts are in course order. You can see all of the posts in this course by clicking the “2D Game Development” button at the top of this site.
- 12.0 – Collision Detection
- 12.1 – Bounding Rectangle Collision Detection
- 12.2 – Distance Based Collision Detection
- 12.3 – Pixel Perfect Collision Detection
Full source can be found here.
Great Tutorials so far!
You probably know this, but I just wanted to point out that using sqrt() and pow() in your collision detection is ridiculously inefficient (unless your compiler is really good at optimizing and DWIM). A faster method would be:
Cool, thanks for posting. I rarely work directly with math in my day to day and hadn’t really done any efficiency testing.