Early on in my programming career, I used to use a check on each frame to see if there was any collision. Sounds like the standard way to do collision detection, you might think. But for some reason it was always rather inefficient. I can’t remember exactly how I used to code my collision detection, but I do remember people laughing at my attempts at collision detection.

That was, until I discovered (this sounds like a cheesy info-mercial doesn’t it?) that there was a lot of physics (and one massive calculation) involved in efficient collision detection. The system I use now, is based on a bit of physics I came across a few months back. It’s a long and boring (for most people that is) piece of physics but it’s the best solution I’ve found (so far).
Anyway, here’s a link to a piece of C++ pseudo code that explains (to those who can read C++ code) what the physics does. The neatest thing about this code, is that you would only have to run this once, and it would tell you if two objects will ever cross on their current trajectories.

Related Post


Jamie is a .NET developer specialising in ASP.NET MVC websites and services, with a background in WinForms and Games Development. When not programming using .NET, he is either learning about .NET Core (and usually building something cross platform with it), speaking Japanese to anyone who'll listen, learning about languages, writing for this blog, or writing for a blog about Retro Gaming (which he runs with his brother)