Swept Rectangle x Grid Collision Algorithm
Swept Rectangle x Grid Collision Algorithm

Winter 2020 c# windows forms

While I was prototyping a 2D platform game, I wanted an algorithm for continuous collision detection between a rectangle and a grid of cells, without testing against every single cell.

I ended up with an algorithm that I’m very happy with, and I think that it has lots of properties that make it especially great for 2D platformer or 3D voxel games. I threw together a neat interactive demo with Windows Forms, which was also very helpful in finding & debugging edge cases!