bounding box collision detection
I'm not able to use the TIA's hardware collision to detect sprite collisions as it's possible, due to flicker, that 2 colliding objects are never drawn on the same frame. As such, I've started working on a software collision detection routine.
Collisions are only tested for a sprite that is moved (saves a lot of time as most sprites are stationary on each frame).
The quickest thing to determine is if the rectangles containing the spites overlap - that's called Bounding Box Collision Detection. To facilitate debugging, I've outlined the images to make the rectangles visible.
The ARM chip uses 32 bit integers, so my collision routine returns a single value with bits turned on where each bit represents a single sprite (bit 0 = player, bit 1 = Evil Otto, bits 2-23 = robot). If no bits are turned on then no collision occurred (the routine's designed to never test if a sprite is colliding with itself, as that bit would always be turned on). I'm using the score to display the collisions. I'll eventually use bit 31 to denote a collision with the play field.
The next revision of this routine will only return a collision if pixels actually overlap.
Nothing colliding
Colliding with sprite 4 (bit 4 on = 0x10 in hexadecimal)
Colliding with sprite 9 (bit 9 on = 0x0200 in hexadecimal)
Colliding with both sprites 4 and 9
Note: When a room is first displayed, the Humanoid might be overlapping another sprite, but the score won't denote the collision it until you move the Humanoid with the joystick.
ROM
Source
0 Comments
Recommended Comments
There are no comments to display.