Actions

Difference between revisions of "SPG:Underwater"

From Sonic Retro

m (Added reference to game objects page for bubble maker.)
(More information about entering/exiting water)
 
Line 4: Line 4:
 
*''For information about the Air Bubble Maker object and the physics of water bubbles, see [[SPG:Game_Objects#Air_Bubble_Maker|Game Objects]]
 
*''For information about the Air Bubble Maker object and the physics of water bubbles, see [[SPG:Game_Objects#Air_Bubble_Maker|Game Objects]]
 
==Air==
 
==Air==
While underwater, the Player can last 30 seconds before drowning. The Player's air value (we'll call this '''remaining_air''') starts at a value of 30 upon entering the water. As you would imagine, once '''remaining_air''' reaches 0, the Player will drown.
+
While underwater, the Player can last 30 seconds before drowning. The Player's air value (we'll call this '''remaining_air''') starts at a value of 30 upon entering the water. As you would imagine, once '''remaining_air''' reaches ''0'', the Player will drown.
  
 
This value represents the amount of seconds of air the Player has left. Meanwhile, a timer counts down from 60 each second. Each time this timer reaches 0, the "air event" occurs:
 
This value represents the amount of seconds of air the Player has left. Meanwhile, a timer counts down from 60 each second. Each time this timer reaches 0, the "air event" occurs:
Line 20: Line 20:
 
Secondly, 1 is subtracted from '''remaining_air'''.
 
Secondly, 1 is subtracted from '''remaining_air'''.
  
====Breathing Bubbles====
+
====Small Breathing Bubbles====
Thirdly, small bubbles are emitted from the Player's mouth. We'll call these "breathing bubbles".
+
Thirdly, small breathing bubbles are emitted from the Player's mouth.
  
Breathing bubbles spawn at the Player's X Position + 6 (or X Position - 6 when facing left) and at the Player's Y Position.
+
Small breathing bubbles spawn at the Player's '''''X Position''''' + 6 (or '''''X Position''''' - 6 when facing left) and at the Player's '''''Y Position'''''.
  
The number of breathing bubbles is either 1 or 2, chosen at random (the is an equal chance of either amount). If the number of breathing bubbles is 2, the second will spawn at a random interval between 1 to 16 frames later.
+
The number of small breathing bubbles is either 1 or 2, chosen at random (the is an equal chance of either amount). If the number of small breathing bubbles is 2, the second will spawn at a random interval between 1 to 16 frames later.
  
 
Notes:  
 
Notes:  
 
* ''The sine movement of the bubble is adjusted based on the way the Player is facing to ensure the bubble begins by moving away from the Player's mouth.''
 
* ''The sine movement of the bubble is adjusted based on the way the Player is facing to ensure the bubble begins by moving away from the Player's mouth.''
* ''When moving through a water tunnel like those in Labyrinth Zone, the breathing bubbles that spawn will move to the right by 4 pixels per frame.''
+
* ''When moving through a water tunnel like those in Labyrinth Zone, the small breathing bubbles that spawn will move to the right by 4 pixels per frame.''
  
 
===Count Down Warning===
 
===Count Down Warning===
If at the current ''air event'' a warning number bubble is to be emitted, this warning bubble will be spawned as of one of the breathing bubbles from the Player's mouth.
+
If at the current ''air event'' a countdown bubble is to be emitted, this countdown bubble will be spawned as if it were one of the small breathing bubbles from the Player's mouth.
  
If only 1 breathing bubble is emitted, that must be the number bubble. If 2 breathing bubbles are to be emitted, there is a quarter chance that the first will be the warning bubble, otherwise the second breathing bubble must be the warning bubble.
+
If only 1 small breathing bubble is emitted, that must be the number bubble. If 2 small breathing bubbles are to be emitted, there is a quarter chance that the first will be the countdown bubble, otherwise the second small breathing bubble must be the countdown bubble.
  
 
===Large Air Bubbles===
 
===Large Air Bubbles===
When a large air bubble is breathed, the Player's '''remaining_air''' is reset to 30 and the timer is reset to 60. Any drowning music is cancelled.
+
When a large air bubble is breathed, the Player's '''remaining_air''' is reset to ''30'' and the timer is reset to 60. Any drowning music is cancelled.
 
Note:
 
Note:
 
* ''For the collision and mechanics of bubbles, see [[SPG:Game_Objects#Large_Air_Bubble|Game Objects]].''
 
* ''For the collision and mechanics of bubbles, see [[SPG:Game_Objects#Large_Air_Bubble|Game Objects]].''
Line 43: Line 43:
 
==Physics==
 
==Physics==
 
When the Player is underwater their speeds are modified to that they move much more slowly, but otherwise the physics are largely the same. This is achieved mostly by halving the pertinent variables, but some, like gravity and initial jump velocity, are not exactly half.
 
When the Player is underwater their speeds are modified to that they move much more slowly, but otherwise the physics are largely the same. This is achieved mostly by halving the pertinent variables, but some, like gravity and initial jump velocity, are not exactly half.
 +
 +
===Water Entry and Exit===
 +
When the Player enters the water, their '''''X Speed''''' is multiplied by ''0.5'', and their '''''Y Speed''''' is multiplied by ''0.25'' quartering it (this occurs after ''gravity_force'' is added to '''''Y Speed''''').
 +
 +
When the Player exits the water, their '''''Y Speed''''' is doubled (after water ''gravity_force'' has been added), (however, '''''X Speed''''' is ''not'' affected when leaving the water). If the Player is being controlled by another object (like being carried by Tails), '''''Y Speed''''' will not be affected.
 +
 +
Also, if the Player's '''''Y Speed''''' is less than ''-16'' it will be limited to ''-16'' upon exiting.
  
 
===Constants===
 
===Constants===
Line 60: Line 67:
  
 
===Getting Hit===
 
===Getting Hit===
When [[SPG:Getting_Hit|getting hit]] underwater, the Player will fly back with an X Speed of 1 (or -1) and a Y Speed of -2, half that of normal.
+
When [[SPG:Getting_Hit|getting hit]] underwater, the Player will fly back with an '''''X Speed''''' of ''1'' (or ''-1'') and a '''''Y Speed''''' of ''-2'', half that of normal.
  
 
===Bubbles===
 
===Bubbles===
  
When the Player gets a bubble underwater, their X Speed and Y Speed are both set to 0.
+
When the Player gets a bubble underwater, their '''''X Speed''''' and '''''Y Speed''''' are both set to ''0''.
 
 
===Entry & Exit===
 
 
 
When the Player enters the water, their X Speed is multiplied by 0.5 and their Y Speed is multiplied by 0.25 (this occurs after ''gravity_force'' is added to Y Speed).
 
Conversely, when the Player exits the water, their Y Speed is doubled (after water ''gravity_force'' has been added), (however, X Speed is ''not'' affected when leaving the water).
 
  
 
===Speed Shoes===
 
===Speed Shoes===
  
When in possession of [[Speed Shoes]], but also underwater, the underwater variables take over, effectively nullifying the Speed Shoes altogether.  No calculations, such as multiplying by 0.5, take place.
+
When in possession of [[Speed Shoes]], but also underwater, the underwater variables take over, effectively nullifying the Speed Shoes altogether.  No calculations, such as multiplying by ''0.5'', take place.
  
 
==Drowning==
 
==Drowning==
  
When the Player drowns, their X Speed and Y Speed are both set to 0, and the ''gravity_force'' remains set to the lower water gravity.
+
When the Player drowns, their '''''X Speed''''' and '''''Y Speed''''' are both set to ''0'', and the ''gravity_force'' remains set to the lower water gravity.
  
 
===Drowning Bubbles===
 
===Drowning Bubbles===

Latest revision as of 04:54, 22 July 2023

Sonic Physics Guide
Collision
Physics
Gameplay
Presentation
Special

Notes:

  • The research applies to all four of the Sega Mega Drive games and Sonic CD.
  • For information about the Air Bubble Maker object and the physics of water bubbles, see Game Objects

Air

While underwater, the Player can last 30 seconds before drowning. The Player's air value (we'll call this remaining_air) starts at a value of 30 upon entering the water. As you would imagine, once remaining_air reaches 0, the Player will drown.

This value represents the amount of seconds of air the Player has left. Meanwhile, a timer counts down from 60 each second. Each time this timer reaches 0, the "air event" occurs:

Air Event

Each air event, the following happens:

Air Check

Firstly, remaining_air is checked. At certain air values, different actions will be performed:

  • [25, 20, 15] a warning chime is sounded.
  • [12] the drowning music begins.
  • [12, 10, 8, 6, 4, 2] a warning number bubble (the count down) will be emitted (these will be the numbers 5, 4, 3, 2, 1, or 0).
  • [0] Sonic drowns.

Air Decrease

Secondly, 1 is subtracted from remaining_air.

Small Breathing Bubbles

Thirdly, small breathing bubbles are emitted from the Player's mouth.

Small breathing bubbles spawn at the Player's X Position + 6 (or X Position - 6 when facing left) and at the Player's Y Position.

The number of small breathing bubbles is either 1 or 2, chosen at random (the is an equal chance of either amount). If the number of small breathing bubbles is 2, the second will spawn at a random interval between 1 to 16 frames later.

Notes:

  • The sine movement of the bubble is adjusted based on the way the Player is facing to ensure the bubble begins by moving away from the Player's mouth.
  • When moving through a water tunnel like those in Labyrinth Zone, the small breathing bubbles that spawn will move to the right by 4 pixels per frame.

Count Down Warning

If at the current air event a countdown bubble is to be emitted, this countdown bubble will be spawned as if it were one of the small breathing bubbles from the Player's mouth.

If only 1 small breathing bubble is emitted, that must be the number bubble. If 2 small breathing bubbles are to be emitted, there is a quarter chance that the first will be the countdown bubble, otherwise the second small breathing bubble must be the countdown bubble.

Large Air Bubbles

When a large air bubble is breathed, the Player's remaining_air is reset to 30 and the timer is reset to 60. Any drowning music is cancelled. Note:

  • For the collision and mechanics of bubbles, see Game Objects.

Physics

When the Player is underwater their speeds are modified to that they move much more slowly, but otherwise the physics are largely the same. This is achieved mostly by halving the pertinent variables, but some, like gravity and initial jump velocity, are not exactly half.

Water Entry and Exit

When the Player enters the water, their X Speed is multiplied by 0.5, and their Y Speed is multiplied by 0.25 quartering it (this occurs after gravity_force is added to Y Speed).

When the Player exits the water, their Y Speed is doubled (after water gravity_force has been added), (however, X Speed is not affected when leaving the water). If the Player is being controlled by another object (like being carried by Tails), Y Speed will not be affected.

Also, if the Player's Y Speed is less than -16 it will be limited to -16 upon exiting.

Constants

 acceleration_speed: 0.0234375 (half of 0.046875)
 deceleration_speed: 0.25 (half of 0.5)
 friction_speed:  0.0234375 (half of 0.046875)
 top_speed: 3 (half of 6)
 
 air_acceleration_speed:  0.046875 (half of 0.09375)
 
 roll_friction_speed: 0.01171875 (half of 0.0234375)
 roll_deceleration_speed: 0.125 (unchanged)
 
 gravity_force: 0.0625 (instead of 0.21875)
 jump_force: 3.5  (3 for knuckles) (instead of 6.5  (6 for knuckles))
 jump_release: -2 (instead of -4)

Getting Hit

When getting hit underwater, the Player will fly back with an X Speed of 1 (or -1) and a Y Speed of -2, half that of normal.

Bubbles

When the Player gets a bubble underwater, their X Speed and Y Speed are both set to 0.

Speed Shoes

When in possession of Speed Shoes, but also underwater, the underwater variables take over, effectively nullifying the Speed Shoes altogether. No calculations, such as multiplying by 0.5, take place.

Drowning

When the Player drowns, their X Speed and Y Speed are both set to 0, and the gravity_force remains set to the lower water gravity.

Drowning Bubbles

When drowning, 11 bubbles are created from the Player's mouth as they fall offscreen. The first bubble can spawn from 0 to 15 frames after drowning, chosen at random. Subsequent bubbles spawn 1 to 8 frames apart, also chosen at random.

Each of the 11 bubbles has a quarter chance of being a medium bubble, otherwise it will be a small bubble.

Animation Speeds

Being submerged doesn't affect the speed of the Player's animations at all. Variable Speed Animations will be attenuated by the same proportion automatically.