What is a technique for 2D ray-box intersection that is suitable for old console hardware?

Posted by DJCouchyCouch on Game Development See other posts from Game Development or by DJCouchyCouch
Published on 2012-03-29T13:45:37Z Indexed on 2012/03/29 17:43 UTC
Read the original article Hit count: 318

I'm working on a Sega Genesis homebrew game (it has a 7mhz 68000 CPU). I'm looking for a way to find the intersection between a particle sprite and a background tile. Particles are represented as a point with a movement vector. Background tiles are 8 x 8 pixels, with an (X,Y) position that is always located at a multiple of 8.

So, really, I need to find the intersection point for a ray-box collision; I need to find out where along the edge of the tile the ray/particle hits.

I have these two hard constraints:

  1. I'm working with pixel locations (integers). Floating point is too expensive. It doesn't have to be super exact, just close enough.

  2. Multiplications, divisions, dot products, et cetera, are incredibly expensive and are to be avoided.

So I'm looking for an efficient algorithm that would fit those constraints. Any ideas? I'm writing it in C, so that would work, but assembly should be good as well.

© Game Development or respective owner

Related posts about sprites

Related posts about projectile-physics