Actions

Difference between revisions of "SPG:Ring Loss"

From Sonic Retro

(Ring bounce info (specifically the behaviour of the ring object itself has been moved to Game Objects)
(Ring Distribution: Improved example code)
Line 8: Line 8:
  
 
   
 
   
  let t = 0
+
  let ring_counter = 0
  let angle = 101.25 ; assuming 0=right, 90=up, 180=left, 270=down
+
  let ring_angle = 101.25° (184) ($B8)  // assuming 0=right, 90=up, 180=left, 270=down
  let n = false
+
  let flip = false
 
  let speed = 4
 
  let speed = 4
 
    
 
    
  while t is less than the number of rings max 32
+
  // perform loop while the ring counter is less than number of lost rings
 +
while ring_counter < number of rings (max 32)
 
  {
 
  {
     create a bouncing ring object
+
     create a bouncing ring object at the Player's X and Y Position
     set the ring's vertical speed to -sine(angle)*speed
+
     ring's X Speed = cosine(ring_angle)*speed
     set the ring's horizontal speed to cosine(angle)*speed
+
     ring's Y Speed = -sine(ring_angle)*speed
     if n is true
+
   
 +
    // ever other ring will be at the same angle as the previous, but the other side of the ring
 +
     if flip == true
 
     {
 
     {
         multiply the ring's horizontal speed by -1
+
         ring's X Speed = ring's X Speed * -1 // reverse ring's x speed
         increase angle by 22.5
+
         ring_angle += 22.5° (240) ($F0)  // we increment angle on every other ring which makes 2 even rings either side
 
     }
 
     }
     let n = not n ; if n is false, n becomes true and vice versa
+
      
     increase t by 1
+
    // toggle flip
     if t = 16
+
    flip = !flip  // if n is false, n becomes true and vice versa
 +
      
 +
    // increment counter
 +
    ring_counter += 1
 +
      
 +
    // if we are halfway, start second "circle" of rings with lower speed
 +
    if ring_counter == 16
 
     {
 
     {
         let speed = 2 ; we're on the second circle now, so decrease the speed
+
         speed = 2
         let angle = 101.25 ; and reset the angle
+
         ring_angle = 101.25° (184) ($B8)  // reset the angle
 
     }
 
     }
 
  }
 
  }

Revision as of 12:47, 12 July 2021

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 ring_counter = 0
let ring_angle = 101.25° (184) ($B8)  // assuming 0=right, 90=up, 180=left, 270=down
let flip = false
let speed = 4
 
// perform loop while the ring counter is less than number of lost rings
while ring_counter < number of rings (max 32)
{
    create a bouncing ring object at the Player's X and Y Position
    ring's X Speed = cosine(ring_angle)*speed
    ring's Y Speed = -sine(ring_angle)*speed
    
    // ever other ring will be at the same angle as the previous, but the other side of the ring
    if flip == true
    {
        ring's X Speed = ring's X Speed * -1  // reverse ring's x speed
        ring_angle += 22.5° (240) ($F0)  // we increment angle on every other ring which makes 2 even rings either side
    }
    
    // toggle flip
    flip = !flip  // if n is false, n becomes true and vice versa
    
    // increment counter
    ring_counter += 1
    
    // if we are halfway, start second "circle" of rings with lower speed
    if ring_counter == 16
    {
        speed = 2
        ring_angle = 101.25° (184) ($B8)  // 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.

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