Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user jmi ! (Registered 2024-09-15) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > De-facto fast bullet collision detection in games
2024-07-09 21:21
cadaver

Registered: Feb 2002
Posts: 1159
De-facto fast bullet collision detection in games

Anyone have studied typical bullet <-> enemy collision detection methods used in games with high bullet count, like Salamander, Enforcer, Turrican?

Turrican appears to have the enemies checking chars underneath them for bullet chars, and index into a table which contains the damage value for each type of bullet char.

This avoids typical O(n^2) bounding box overlap checks (each bullet vs each enemy), though a large enemy would need to check many chars under it.

A side-effect of this method is that enemy bullets hitting the player usually cannot be chars, but rather sprites, which would check the collision differently.
2024-07-10 08:24
Fungus

Registered: Sep 2002
Posts: 668
Hrm, large enemies only need to check chars around their perimeter I would think, there could be a offset lookup table for that?

I have noticed in many older games the sprite collision is only used with the player, but it isn't entirely accurate when multiple things are colliding which is very annoying. Some games use an IRQ and it clears the register immediately so it can be used many times a frame, but that's not very useful if your game has tight timing for the raster. Phobia is pretty fast, enough to work on NTSC, I cannot remember what technique it used though.

Have you asked Dan Phillips what he used in Armalyte?
2024-07-10 09:18
Martin Piper

Registered: Nov 2007
Posts: 698
It really depends on a few factors, like how accurate you want the sprite collision, if the bullets/enemies/player are sprites, if you're scrolling the screen, if you can allocate a certain character range to be bullets/sold background, etc.

SEUCK does pixel accurate sprite to sprite collision, using the hardware collision register, for example.
Other games have an off-screen collision map (blob of memory), which might or might not be the same resolution as the screen. It might be half resolution for example. Some games plot their sprite enemies into this map along with their bullets.
Other game use a simple bounding rectangle (or "circle" or "diamond") check for their sprites.
Some games used the actual chars on screen, but look-up those chars up into another table that denotes the collision type of enemy/bullet/background.
Some use a mixture of these methods depending on if they are enemy to bullet, enemy to enemy, enemy to player etc.

There are many many variations on how to do this depending on data format/layout, accuracy, and sprites or not.

Sometimes you can spot where the collision map is by inspecting a live memory view, like in ICU64. Like in this video: https://youtu.be/3SvsElGt3Hc?t=2480
2024-07-10 10:16
Jetboy

Registered: Jul 2006
Posts: 265
Quoting cadaver
A side-effect of this method is that enemy bullets hitting the player usually cannot be chars, but rather sprites, which would check the collision differently.


Not a problem if enemy bullets use different char than player bullets do.
2024-07-10 10:46
cadaver

Registered: Feb 2002
Posts: 1159
Thanks for suggestions! Very true that the enemy doesn't necessarily need to check its inside area, though it also has to take into account the maximum velocity of bullets (e.g. a 2x2 faster moving "bounce" bullet in Turrican) and itself to not miss collisions due to "tunneling"
2024-07-10 11:22
tonysavon

Registered: Apr 2014
Posts: 25
For sure not the best method, but I want to report my experience with Guy in a vest,a project that is indefinitely on hold :-).
I hit CPU limits quite soon there, because I have colour scrolling plus soft-sprite bullets with sub-char positioning (each bullet is pixelled on top of the BG and takes 2 chars in the charmap, so you don't see the char fame around it, i think ikari warriors does that). Initially I was using the bounding box approach, so for each one of the N bullets I was testing collision with the M enemies on screen, so NxM comparisons. I started to have some slowdowns when I added digi. The solution for me was to blend bullet positioning / collision detection with the sprite multiplexer.
Say you have 4 raster splits with sprites and bullets equally spread, I'd do 4*(N/4)*(M/4) tests, which is 4 times faster, at the cost of making the multiplexer more complicated.

Guy in a vest is horizontal only scrolling, which makes things much easier but I suppose this approach could be used also for 4 ways scrolling. Just don't ask me how :-)
2024-07-10 12:29
Krill

Registered: Apr 2002
Posts: 2940
With sprite multiplexing and such, is there anything that would make spr-spr hw collision detection interleaved with the multiplexer logic a bad idea? :)
2024-07-10 12:42
Oswald

Registered: Apr 2002
Posts: 5074
"A side-effect of this method is that enemy bullets hitting the player usually cannot be chars"

why ?
2024-07-10 13:20
cadaver

Registered: Feb 2002
Posts: 1159
Quote: "A side-effect of this method is that enemy bullets hitting the player usually cannot be chars"

why ?


For avoiding a pathological case where a player char bullet overlaid on an enemy char bullet (or vice versa) would create a missed collision. That assuming the char bullets are drawn first, and all collisions are checked afterward.
2024-07-10 13:36
chatGPZ

Registered: Dec 2001
Posts: 11290
Quote:
With sprite multiplexing and such, is there anything that would make spr-spr hw collision detection interleaved with the multiplexer logic a bad idea? :)

didnt one of the old VICIIs clear the collision latch only once per frame?
2024-07-10 13:49
Martin Piper

Registered: Nov 2007
Posts: 698
Quote: With sprite multiplexing and such, is there anything that would make spr-spr hw collision detection interleaved with the multiplexer logic a bad idea? :)

Well SEUCK uses the hardware collision with its multiplexor. I also have the option of using hardware collision with my multiplexor, also used in the SEUCK redux games. As long as a "last 8 sprites" to real multiplexed sprite index map is maintained then it seems to work fine for detecting multiplexed hardware collision.
 
... 20 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 | 3 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
bugjam
Brush/Elysium
Almighty God/Level 6..
K-reator/CMS/F4CG
pcollins/Quantum
REBEL 1/HF
rexbeng
AmiDog
Druid/Occult
kbs/Pht/Lxt
Guests online: 166
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Uncensored  (9.6)
7 Wonderland XIV  (9.6)
8 Comaland 100%  (9.6)
9 No Bounds  (9.6)
10 Unboxed  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Dawnfall V1.1  (9.5)
8 Onscreen 5k  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Morph  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Nostalgia  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.2)
Top Webmasters
1 Slaygon  (9.6)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.053 sec.