[stella] Collisions

Subject: [stella] Collisions
From: emooney@xxxxxxxxxxxxxxxx (Erik Mooney)
Date: Fri, 29 May 1998 15:48:37 GMT
Anyone have an easy way to process collisions between two objects, each of
which could have any multiple-copy NUSIZ value and any X-coordinate?  Like,
visualize a three-on-three in Combat, but I want to be able to calculate
collisions between each bullet and each plane separately - like the
rightmost bullet might hit the leftmost target plane, meaning the NUSIZ for
the bullets changes from three-close to two-close, and the NUSIZ for the
planes changes from three-close to two-close also, but we move the object's
X-coordinate sixteen pixels to the right (because the middle object became
the leftmost object.)  We can assume the bullets (missiles) are one pixel
wide each, and the players eight pixels wide (no double or quad width
NUSIZes, and we can calculate collisions - we don't care about
pixel-perfect collision detection via the collision registers.)

I think I'm just going to slap a huge table in ROM for each 8-pixel step
between the objects' X-coordinates, and each NUSIZ value for the source
object, containing the X-coordinate change and the new NUSIZ value for each
player (this can be done in one byte per player - put the NUSIZ in the
lower nibble and the X-change in the upper nibble).  That'd be 6 possible
NUSIZes for each object, and (320 / 8 = 40) possible X-differences (cause
the difference can be from -160 to 160 pixels), times 2 bytes per entry in
the table, for a table size of 2880 bytes.  If I limit the table so I don't
check it if the X-difference is more than 64 pixels either way, that
reduces the table to 6 * 6 * 18 * 2 bytes = 1296 bytes.

Anyone have a better way to do this?  Either by reducing the table size, or
having a way to calculate the collisions? (speed is essential, code size is
not)

--
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/stella.html

Current Thread