📜 ⬆️ ⬇️

Review of physics in Sonic games. Parts 7 and 8: springs and gizmos, super speeds



Continuation of a series of articles on physics in games about Sonic. This post discusses the repulsion of characters from various game objects and their superpowers.

Links to other parts of the series:
Part 1: hard tiles
Part 2: Running
Parts 3 and 4: Jumping and Spinning
Parts 5 and 6: the loss of rings and being under water

Part 7: Springs and Gizmos



Spring pad
')
Red spring pads give Sonic speed of 16, and yellow ones give speed 10. Depending on the direction of the pad (up or down), the value is negative or positive, and accordingly the speed along the Y axis is given this value. If the spring pad is pointing left or right, the speed value is negative or positive, respectively, the speed along the X axis is equal to this value. Vertical platforms do not affect the speed of X, as horizontal platforms do not affect the speed of Y.



Diagonal Spring Pads

In Sonic the Hedgehog (16-bit) there are no diagonal spring pads. However, they are in Sonic 2 (16-bit), 3, Knuckles and CD. In Sonic 2, 3 and Knuckles they work the same, but the principle is different in Sonic CD.

in Sonic 2, 3 and Knuckles, the diagonal spring sets the speed X and Y to the spring pad with the appropriate sign. Therefore, a spring directed upwards and to the right gives a speed Y equal to -16 and a speed X equal to 16. The problem with this method is that technically Sonic pushes off diagonally faster than horizontally or vertically. This is because the developers did not care to take cosines and sines into account.

In Sonic CD, they corrected. Conveniently, the absolute values ​​of the sine and cosine of an angle of 45 degrees are the same, so only one value is required. The speed becomes 11.3125 for the red springs and 7.0703125 for the yellow ones.

Horizontal control lock

When Sonic bounces off a horizontal spring (red or yellow), he cannot slow down or otherwise influence his speed X for 16 cycles. The engine achieves this by setting the same horizontal control lock as when rolling off steep slopes (in S3 and Knuckles, bytes $ 32-33 are the state table of the player's object). Why block horizontal control? When colliding with a spring, the player most likely presses the crossbar in the direction of the spring, and this may lead to the repulsion of Sonic in the animation of inhibition. Temporarily ignoring input is a quick and elegant solution.

Animation

In the case of a spring pad, directed upwards, when Sonic loses all the speed directed upwards, he turns into a walking animation. The frames of this animation are replaced every 8 cycles.

In the case of any of the diagonal spring pads, Sonic does not go at all on the animation of walking in the air. It retains the animation of the "corkscrew" (three-dimensional rotation), the frames of which are replaced every 5.5 cycles.

Air balloons

When Sonic collides with balloons at the Carnival Night Zone levels, his speed Y is set to -7, regardless of the angle of collision. The speed of X does not change.



Bumpers

The bumpers in the Spring Yard Zone give Sonic a speed of X equal to 7 * cos (p) and a speed of Y 7 * -sin (p), where p is the angle between the centers of the bumper and Sonic. The speed is set regardless of the speed of Sonic before the collision with the bumper.



Cannons

The guns in the Carnival Night Zone give Sonic a horizontal speed of 16 * cos (p), and a vertical speed of 16 * -sin (p), where p is the angle of the cannon.



Spring Covers

Red caps with springs that close the pipes in the Chemical Plant Zone work like spring pads, but slightly stronger than yellow pads. In a collision, they give Sonic a speed of Y, equal to -10.5.



Turntables

Black turntables that disperse the hedgehog forward in the Chemical Plant Zone set the speed of X to 16. However, they do not slow it down if it is already moving faster.

Elevators in the sky

The elevators in the sky at Hill Top Zone travel at a speed of X, equal to 2, and a speed of Y, equal to 1.



Mushrooms

Mushrooms in the Mushroom Hill Zone work as spring platforms, but each subsequent rebound becomes higher than the previous one (up to three rebounds). The first bounce gives the speed Y-6.5, the second-7.5, and the third-8.5.



Destruction of walls

In Sonic 1, 2, 3 and Knuckles for punching destructible walls during rotation, the absolute speed X of a character must exceed 4.5 (with the exception of the character Knuckles, which crumbles the walls in a collision, and it does not have to rotate). Collisions with such walls do not affect the speed of X.

However, when Knuckles destroys walls in Sonic 3 and Knuckles, despite the fact that its speed X does not change, it does not move in the frame in which it hits the wall. The same is true for punching a wall with Sonic when rotating in Sonic 3 and Knuckles.

In Sonic CD, the speed limit X is removed. Sonic can pierce destructible walls by simply jumping next to them or rotating at any speed.

Destructible blocks and stones

When Sonic jumps on destructible objects, such as stones in the Hill Top Zone, blocks in the Marble Zone, or pipe covers in the Chemical Plant Zone, he bounces off them with a Y speed of -3. The speed of X does not change.



Part 8: Super Speed



Super fast boots

Translator's note: Super Fast Shoes is a speed increase bonus that lasts 20 seconds and increases Sonic's acceleration and maximum speed. Out of such monitors here:



VariableValue
Acceleration0.09375
Braking
0.5 (unchanged)
Friction
0.09375
Max speed12
Acceleration in the air
0.1875
Friction during rotation
0.046875
Deceleration during rotation
0.125 (unchanged)

Note : if the Sonic falls into the water, all the effects of Super Fast Shoes are reset. "Underwater" variables completely replace them. If you jump out of the water, the effect of super-fast shoes will not return. It seems that this applies to all 5 games.

In Sonic 3 and Knuckles, the tempo of a musical composition increases 1.25 times.

Super / Hypersonics

Translator's note: Supersonik (Super Sonic) is the superform of the Sonic the Hedgehog character. This form of Sonic was first used in the game Sonic the Hedgehog 2 and was then realized in a different volume in each main game about Sonic. You can turn into Supersonics by collecting all seven Chaos Emeralds, finding at least 50 rings and losing all protection. Having made a double jump, Sonic becomes a yellow Supersonic, this is a faster and almost invulnerable form of Sonic. However, the rings are spent on maintaining this shape (see below).



In Sonic 3 and Knuckles games, after collecting all the Chaos Emeralds at special levels, you can collect seven Super Emeralds, and then turn into a character hyperform. She also spends collected rings. In this mode, the character can make double-directed leaps, destroy all opponents on the screen and cannot drown, unlike the super form.





Variables refer to Supersonics in Sonic 2 and to Super- or Hypersonics in Sonic 3 and Knuckles, except for the marked variable.

VariableValueValue (under water)
Acceleration
0.1875
0.09375
Braking
one
0.5
Friction
0.046875 (unchanged)
0.046875 (unchanged)
Max speed
ten
five
Acceleration in the air
0.375
0.1875
Initial jump speed
eight
3.5 (unchanged)
Jump speed when the button is released
4 (unchanged)
2 (unchanged)
Friction during rotation
0.09375 (0.0234375 in Sonic 3 and Knuckles)
0.046875 (0.0234375 in Sonic 3 and Knuckles)
Deceleration during rotation
0.125 (unchanged)
0.125 (unchanged)

Hyper Blast Ability (Hypersonics Only)

When a player presses the jump button in the air a second time, Sonic’s speed on the X axis is equal to 8 if he is looking to the right, and to –8 if he is to the left, and the speed on the Y axis is reset. If a player holds “up” on the crosspiece when the button is pressed, then Sonic’s speed on the Y axis is equal to –8, and on the X axis it is reset.

Supertails, Super / Hypernacs

VariableValueValue (under water)
Acceleration
0.09375
0.046875
Braking
0.75
0.375
Friction
0.046875 (unchanged)
0.046875 (unchanged)
Max speed
eight
four
Acceleration in the air
0.1875
0.09375
Initial jump speed
(does not change)
(does not change)
Jump speed when the button is released
(does not change)
(does not change)
Friction during rotation0.0234375
0.0234375
Deceleration during rotation
0.125 (unchanged)
0.125 (unchanged)
Climbing speed (only for Knuckles)
2
2
Initial slip speed (only for knuckles)
4 (unchanged)
4 (unchanged)
Acceleration slip (only for naklza)
0.046875
0.046875

Wall Quake (Hypernacles only)

In order for Nackles to shake the screen and destroy all enemies in contact with the wall, he must slide at a speed of 4.5 pixels per cycle or higher.

Ring picking

While in Super / Hyper mode, a character loses one ring every 60 cycles, or every 1 second.

Notes

If Super / Hyperperson gets super-fast shoes by smashing the monitor, super-fast shoe variables replace Super / Hyper mode variables, actually slowing down the character (however, the maximum speed remains slightly higher). This may be undesirable in your own engine.

When a Super / Hyperperson falls into water, he uses the above variables. However, if they become Super / Hyper already under water, the Super / Hyper mode variables become as if it is not under water. This is a bug and should be avoided in your engine.

PS again for attentive and curious readers. Here the first encrypted word ends. Words do not refer to the Sonic universe, but deciphering requires knowledge of it (however, Google can do well).

image

Source: https://habr.com/ru/post/306756/


All Articles