Actions

Difference between revisions of "SPG:Ring Loss"

From Sonic Retro

m (changed the psuedo code bit to be correct)
m (Text replacement - "Genesis/Mega Drive" to "Mega Drive")
Line 49: Line 49:
 
But there are further limitations on bouncing rings, probably also in place to avoid processor load.  They are totally unaffected by walls, and are only concerned with vertical surfaces.  Moreover, they only check to see if they are colliding with a solid when they are moving downward (i.e. their vertical speed is positive).  Thus they can also fly up through ceilings.  This can actually become a bother to Sonic if he is struck in a small corridor, as most of his rings are lost in the ceiling and don't fall back down to be regathered.
 
But there are further limitations on bouncing rings, probably also in place to avoid processor load.  They are totally unaffected by walls, and are only concerned with vertical surfaces.  Moreover, they only check to see if they are colliding with a solid when they are moving downward (i.e. their vertical speed is positive).  Thus they can also fly up through ceilings.  This can actually become a bother to Sonic if he is struck in a small corridor, as most of his rings are lost in the ceiling and don't fall back down to be regathered.
  
Personally, if I were using a system with more power than the Genesis/Mega Drive, I would make the rings check for horizontal collisions.  If they collide, then they should multiply their horizontal speed by a factor of -0.25.  I would also check for ceilings, by asking in their vertical collision check whether they are moving up or down.  If they are moving down, they should bounce as normal, but if they are moving up, they should set their vertical speed to 0.  This is kinder to the player, for most of the rings do not get lost due to system limitations.
+
Personally, if I were using a system with more power than the Mega Drive, I would make the rings check for horizontal collisions.  If they collide, then they should multiply their horizontal speed by a factor of -0.25.  I would also check for ceilings, by asking in their vertical collision check whether they are moving up or down.  If they are moving down, they should bounce as normal, but if they are moving up, they should set their vertical speed to 0.  This is kinder to the player, for most of the rings do not get lost due to system limitations.
  
 
==Ring Lifespan==
 
==Ring Lifespan==

Revision as of 14:13, 10 April 2018

Note: Research gathered from Sonic the Hedgehog (16-bit), but it is highly likely that it holds true for Sonic CD, Sonic 2 (16-bit), Sonic 3, and Sonic & Knuckles.

Ring Limit

When Sonic gets hit, the number of rings he is carrying scatter away, unless he is carrying more than 32, in which case any rings over 32 are ignored. Sonic is therefore no safer carrying 100 rings than 32.

Ring Distribution

The rings that scatter away from Sonic are distributed in a specific pattern of 2 concentric circles, each containing a maximum of 16 rings. The rings in the first circle move outward faster than the rings in the second. Here is a formula for creating the rings, which can be converted into the programming language of your choice:

 {
 let t = 0
 let angle = 101.25 ; assuming 0=right, 90=up, 180=left, 270=down
 let n = false
 let speed = 4
 
 while t is less than the number of rings max 32
   {
   create a bouncing ring object
   set the ring's vertical speed to -sine(angle)*speed
   set the ring's horizontal speed to cosine(angle)*speed
   if n is true
     {
     multiply the ring's horizontal speed by -1
     increase angle by 22.5
     }
   let n = not n ; if n is false, n becomes true and vice versa
   increase t by 1
   if t = 16
     {
     let speed = 2 ; we're on the second circle now, so decrease the speed
     let angle = 101.25 ; and reset the angle
     }
   }
 }

So, the first 16 rings move at a velocity of 4 pixels per step, and the second 16 move at half that rate, or 2 pixels per step.

Ring Gravity

Rings do not heed the same gravity constant as Sonic does. Instead, their gravity is a force of 0.09375. So, this value is added to the rings' vertical speed every step.

Ring Bounce

When the scattered rings hit the ground, their vertical speed is multiplied by a factor of -0.75. This has the effect of reversing their vertical motion, as well as slowing it somewhat. This calculation is performed after the addition of the gravity. Their horizontal speed is unaffected by bouncing.

When the rings bounce off the floor, they do so so imprecisely, it is almost embarrassing. But this is really not noticed during normal play, and was perhaps necessary to avoid too much slowdown. It looks to me like they don't check to see if they are colliding with the ground every step, so they sometimes pass well into the ground before deciding to bounce away. This is something not really worth emulating.

But there are further limitations on bouncing rings, probably also in place to avoid processor load. They are totally unaffected by walls, and are only concerned with vertical surfaces. Moreover, they only check to see if they are colliding with a solid when they are moving downward (i.e. their vertical speed is positive). Thus they can also fly up through ceilings. This can actually become a bother to Sonic if he is struck in a small corridor, as most of his rings are lost in the ceiling and don't fall back down to be regathered.

Personally, if I were using a system with more power than the Mega Drive, I would make the rings check for horizontal collisions. If they collide, then they should multiply their horizontal speed by a factor of -0.25. I would also check for ceilings, by asking in their vertical collision check whether they are moving up or down. If they are moving down, they should bounce as normal, but if they are moving up, they should set their vertical speed to 0. This is kinder to the player, for most of the rings do not get lost due to system limitations.

Ring Lifespan

All scattered rings are destroyed after 256 steps if they have not been regathered. Also, if they leave the horizontal view boundaries, they are destroyed. Again, on a more powerful system, you may choose not to include this feature.

Regathering Rings

64 steps must have passed since Sonic was hit before he can regather any rings, scattered or otherwise.

Invulnerability

Sonic remains invulnerable for a short time after being hit. This invulnerability lasts while Sonic is flying back from the blow, and then 120 steps more after he recovers movement. During those 120 steps, he flashes on and off, spending 4 steps on and 4 steps off.

While in this state, Sonic can not collect level rings until less than 90 invulnerability steps remain.

Ring Animations

Fixed rings have 4 frames of animation, and spend 8 steps showing each frame before moving to the next. Scattered rings are more complicated, in that they have a much faster animation speed when they are created, but this slows down over their lifespan. They begin only showing each frame for about 2 steps, and wind up at the end slowing to a crawl, showing each frame for 16 steps or more. I do not know the precise values yet. Scattered rings are created showing their initial frame of animation, which is the ring shown face on.

Ring Depth

All rings, scattered or fixed, have a higher depth than Sonic, i.e. behind him. But they have a lower depth, i.e. in front of him, when they turn into sparkles.