Jump to content







Photo

bounding box collision detection

Posted by SpiceWare, in Frantic 13 August 2011 · 157 views

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
Attached Image

Colliding with sprite 4 (bit 4 on = 0x10 in hexadecimal)
Attached Image

Colliding with sprite 9 (bit 9 on = 0x0200 in hexadecimal)
Attached Image

Colliding with both sprites 4 and 9
Attached Image

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
Attached File  frantic_harmony20110813.bin (32K)
downloads: 16

Source
Attached File  Frantic20110813.zip (518.82K)
downloads: 7




May 2012

S M T W T F S
  12345
6789101112
13141516171819
2021 22 23242526
2728293031  

Recent Entries

Recent Comments

0 user(s) viewing

0 members, 0 guests, 0 anonymous users

Search My Blog

Latest Visitors