Jump to content
  • entries
    657
  • comments
    2,692
  • views
    897,856

bounding box collision detection


SpiceWare

693 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

blogentry-3056-0-33499300-1313262180_thumb.png

 

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

blogentry-3056-0-41268500-1313262186_thumb.png

 

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

blogentry-3056-0-52824700-1313262199_thumb.png

 

Colliding with both sprites 4 and 9

blogentry-3056-0-57361500-1313262193_thumb.png

 

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

frantic_harmony20110813.bin

 

Source

Frantic20110813.zip

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...