Jayextee, on 15 June 2012 - 10:21 AM, said:
I don't recall, has anyone ever fixed the collision? -- when Sonic (or Tails) is colliding with two objects at once, only one registers? This is why Sonic walks through certain badniks in ARZ when he's scattering leaves, and why he can't collect dropped rings in lava without jumping.
Like I said earlier, it probably wouldn't be good performance-wise to check every object each frame, but there's another way to get around this problem:
Fix collisions with the lava collision maker object
The way object collisions work, it's impossible to collide with two objects at once unless the object itself does the collision checks. That's what we're going to do here.
We're going to be editing object 31, the lava collision maker. First locate the label Obj31_Init
dc.b $96 ; 0
dc.b $94 ; 1
dc.b $95 ; 2
dc.b 0 ; 3
addq.b #2,routine(a0) ; => Obj31_Main
move.b Obj31_CollisionFlagsBySubtype(pc,d0.w),collision_flags(a0) ; <-------
Now, we replace the data table Obj31_CollisionFlagsBySubtype
and the line that uses it with the following:
dc.b $20 ; 0
dc.b $40 ; 1
dc.b $80 ; 2
dc.b 4 ; 3
Next, we need to add our own collision check. Here's the routine, place it anywhere close to the object's code. I put it between Obj31_Main
and the object's mappings.
; test horizontal
; left edge
; right edge
; test vertical
moveq #$20,d1 ; we assume a constant y_radius of 32 pixels
; top edge
; bottom edge
; hurt player
move.l a0,-(sp) ; save object address
exg a0,a1 ; switch object and player addresses
movea.l (sp)+,a0 ; load 0bj address
Now we need the object to call this routine. Right after the label Obj31_Main
, add this:
bne.s + ; skip collision checks if in object placement mode mode
Now, I'm no expert on coding bounding box checks, so if someone can come up with a better collision checking routine that uses less cycles, post away. This does have the potential to slow the game down a little, so every little bit helps.
What really helps is s3k's collision checking routine. Instead of going through the entire object list, it only checks objects that add themselves to a specific list. This means objects that have no collisions or ones that do the checks themselves will be skipped.
The fix for the ARZ leaf makers should work the same way, but I'd need to check first to be sure.