Jump to content
  • 1
Geehaf

Sprite Collisions

Question

Hi All,

Has anybody experimented with using the newly implemented sprite collisions with R38?

The VERA doco mentions sprite collisions but I was hoping somebody could provide a worked example / explanation.

Reading the doco it looks like each of the 128 sprites can be assigned a 4 bit collision mask but I'm not sure how this works together with the 4 bits of "sprite collisions" provided by the ISR register ($9F27).

Any help much appreciated.

Regards,

G
 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Each of the 4 bits represent 4 groups of sprites that collisions would be checked for. For example, if 2 or more sprites with bit 0 set are "touching" each other on a given pixel, then the VERA knows there's a collision in group 0, thereby setting the corresponding bit in the ISR register upon V-Blank. The flags must be cleared after they're checked, so collisions that just happened won't "spill" into the next frame.

PS: Using the hardware collisions is known to cause different behavior/side effects, depending on the video output mode, start/stop/scaling, and (as I'm pretty sure) the sprite "work units" that are being spent on each line. It's considered best to use software collision detection (though it may not be pixel-perfect, considering that's a CPU-intensive operation).

Share this post


Link to post
Share on other sites
  • 0
2 minutes ago, StinkerB06 said:

Each of the 4 bits represent 4 groups of sprites that collisions would be checked for. For example, if 2 or more sprites with bit 0 set are "touching" each other on a given pixel, then the VERA knows there's a collision in group 0, thereby setting the corresponding bit in the ISR register upon V-Blank. The flags must be cleared after they're checked, so collisions that just happened won't "spill" into the next frame.

PS: Using the hardware collisions is known to cause different behavior/side effects, depending on the video output mode, start/stop/scaling, and (as I'm pretty sure) the sprite "work units" that are being spent on each line. It's considered best to use software collision detection (though it may not be pixel-perfect, considering that's a CPU-intensive operation).

Thanks - this now makes sense.

Essentially collisions are detected for up to 4 potential groups and each sprite can be assigned a specific group. Does this mean collisions are only detected/generated within a specific group, e.g. if a player sprite (say) was assigned to group 0 and all enemy sprites to group 1 then collisions would not be generated when a player collides with an enemy sprite?

Also thanks for the heads up re. HW vs SW collision detection approach.

 

Share this post


Link to post
Share on other sites
  • 0
3 hours ago, Geehaf said:

Does this mean collisions are only detected/generated within a specific group, e.g. if a player sprite (say) was assigned to group 0 and all enemy sprites to group 1 then collisions would not be generated when a player collides with an enemy sprite?

Also thanks for the heads up re. HW vs SW collision detection approach.

I've started using HW sprite collisions for my current project the last few days. To answer the first question: yes collisions are detected among the same group of sprites. So for example I assigned the same group to enemy sprites and the laser shots of my ship. VERA reliably detects collisions.

Which brings me to HW vs SW collision detection: until now I can't see a real disadvantage using HW detection. I mean you have to combine the 2 anyway. HW detection just tells you that there was a collection in a group of sprites. You then have to figure out which sprites were involved.

At least in my current project (see "Invaderz" demo) it really helped to reduce lag and improve performance a lot.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   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.


×
×
  • Create New...

Important Information

Please review our Terms of Use