Difference between revisions of "Sonic the Hedgehog/Game Mechanics and Glitches"

From SDA Knowledge Base

Jump to: navigation, search
m (Air Abilities (S3 and S&K only))
(Changed slope glitch section from a joke to something useful.)
 
(7 intermediate revisions by 3 users not shown)
Line 16: Line 16:
  
 
The levels themselves are built using "chunks" of 16x16 blocks (256 pixels) in Sonic 1 and 8x8 blocks (128 pixels) in later games. Every pixel is then divided into 128 subpixels and all movement is calculated with them.
 
The levels themselves are built using "chunks" of 16x16 blocks (256 pixels) in Sonic 1 and 8x8 blocks (128 pixels) in later games. Every pixel is then divided into 128 subpixels and all movement is calculated with them.
 +
 +
Whenever the character moves, the new position is calculated based on your current position, speed and acceleration. If a solid object is in the way it is possible to completely bypass it if no calculated position collides with the object. In laymans terms, if Sonic is fast enough he can ignore solid objects because he's too fast to interact with them.
 +
 +
These speeds are typically above 16 pixels of movement per frame (p/f for future reference) and can't be achieved without assistance as no unaided action in the games give you greater speed. For a lot of "level wraps" the speed given is on the limit of being enough and thus your position becomes important, even down to the subpixel.
 +
 +
== Path switchers ==
  
 
[[File:PathSwitcher.png|200px|thumb|right|Path switcher in effect]]
 
[[File:PathSwitcher.png|200px|thumb|right|Path switcher in effect]]
Line 22: Line 28:
  
 
Sonic 1 doesn't switch paths with objects as all levels only have 1 solidity path. Instead, loops have a sort of area of transition.
 
Sonic 1 doesn't switch paths with objects as all levels only have 1 solidity path. Instead, loops have a sort of area of transition.
 
Whenever the character moves, the new position is calculated based on your current position, speed and acceleration. If a solid object is in the way it is possible to completely bypass it if no calculated position collides with the object. In laymans terms, if Sonic is fast enough he can ignore solid objects because he's too fast to interact with them.
 
 
These speeds are typically above 16 pixels of movement per frame (p/f for future reference) and can't be achieved without assistance as no unaided action in the games give you greater speed. For a lot of "level wraps" the speed given is on the limit of being enough and thus your position becomes important, even down to the subpixel.
 
  
 
== Speed cap ==
 
== Speed cap ==
Line 55: Line 57:
  
 
== Rolling and Spindashing ==
 
== Rolling and Spindashing ==
Spindashing has 8 possible speeds, between 8 p/f and 12 p/f in half integers. Every time a button is pressed you add 2 to the base value 8, which then subsequently decreases faster the higher the total value is. Because of this, the minimum requirement to get a 12 speed is 6 button presses, commonly referred to as a "6-tap".
+
Spindashing has 9 possible speeds, between 8 p/f and 12 p/f in half integers. Every time a button is pressed you add 2 to the base value 8, which then subsequently decreases faster the higher the total value is. Because of this, the minimum requirement to get a 12 speed is 6 button presses, commonly referred to as a "6-tap".
  
 
Since you always decelerate while rolling unless going down a slope, getting back to running by jumping into ceilings, down slopes or inside loops are things you generally want to do after spindashing.
 
Since you always decelerate while rolling unless going down a slope, getting back to running by jumping into ceilings, down slopes or inside loops are things you generally want to do after spindashing.
Line 61: Line 63:
 
There's no guaranteed way to get a certain spindash speed, so usually runners do 3-taps or other increments in order to get close to the desired speed.
 
There's no guaranteed way to get a certain spindash speed, so usually runners do 3-taps or other increments in order to get close to the desired speed.
  
Another quirk that further complicates rolling is that whenever you jump from one, you loose all control of your character. In Sonic 3, Sonic & Knuckles and Sonic 2 & Knuckles, doing your air ability will let you regain control mid air, but in Sonic 1 and Sonic 2 there's no way to manipulate your trajectory after a "rolljump".
+
Another quirk that further complicates rolling is that whenever you jump from one, you lose all control of your character. In Sonic 3, Sonic & Knuckles and Sonic 2 & Knuckles, doing your air ability will let you regain control mid air, but in Sonic 1 and Sonic 2 there's no way to manipulate your trajectory after a "roll jump".
  
Due to an error regarding Sonic's height in Sonic 2 whenever you rolljump into something and stop, you'll land 5 pixels above ground. This was fixed in Sonic 3 but consequently whenever you rolljump, you sink 5 pixels into the ground before taking off, which actually allow you to clip into the ground in Marble Garden 1 by a yellow spring as Sonic and Knuckles. Since Tails is smaller, he only sinks 1 pixel into the ground and thus can't do the same trick.
+
Due to an error regarding Sonic's height in Sonic 2 whenever you rolljump into something and stop, you'll land 5 pixels above ground. This was fixed in Sonic 3 but consequently whenever you rolljump, you sink 5 pixels into the ground before taking off, which actually allows you to clip into the ground in Marble Garden 1 by a yellow spring as Sonic and Knuckles. Since Tails is smaller, he only sinks 1 pixel into the ground and thus can't do the same trick.
  
 
== Air Abilities (Sonic 3 & Knuckles only) ==
 
== Air Abilities (Sonic 3 & Knuckles only) ==
Line 73: Line 75:
 
== Camera timer ==
 
== Camera timer ==
 
The other kind is this one, which only starts moving once it's brought onto the screen (or near the screen - when the object is first rendered, in any case). Knowing which objects have which timing properties is important to good times when you have to deal with them.
 
The other kind is this one, which only starts moving once it's brought onto the screen (or near the screen - when the object is first rendered, in any case). Knowing which objects have which timing properties is important to good times when you have to deal with them.
 +
 +
== Horizontal Movement Lock ==
 +
When moving on sloped ground/ceilings, the game imposes a movement lock if you are holding either left or right while attaining a certain minimum angled speed.  This lock removes your horizontal control of the character for a set number of frames (based on the angled speed you had), though you can still jump and roll.  You can avoid it by releasing to neutral before the lock activates, then pressing left or right after your angled speed is slow enough.  The lock's timer is frozen while you are in the air, and in the case of Sonic 3, if activated in tandem with the wheel glitch in Carnival Night 1.
  
 
= Mechanics specific to Sonic =
 
= Mechanics specific to Sonic =
Line 112: Line 117:
 
== Level wrap ==
 
== Level wrap ==
 
This is what happens when a zip causes you to bypass the left edge of the screen. The game treats your X-coordinate in memory as a number less than 0 - but position coordinates are unsigned, so instead of a negative number it's a VERY large positive one - which correlates to the end of the stage. This requires some very specific circumstances depending on the level.<br />
 
This is what happens when a zip causes you to bypass the left edge of the screen. The game treats your X-coordinate in memory as a number less than 0 - but position coordinates are unsigned, so instead of a negative number it's a VERY large positive one - which correlates to the end of the stage. This requires some very specific circumstances depending on the level.<br />
In Sonic 3 & Knuckles, a level wrap always puts you to x-position 32767, even if the stage isn't that long. To fill out the remainder of the map, the level repeats itself, this area is termed the "loopback". No sprites or path switchers exist in this area, but all the level geometry still exists, so you can maneuver around (somewhat) freely.
+
In Sonic 3 & Knuckles, a level wrap always puts you to x-position 32767, even if the stage isn't that long. To fill out the remainder of the map, the level repeats itself, this area is termed the "loopback". No sprites or path switchers exist in this area, but all the level geometry still exists, so you can maneuver around (somewhat) freely. However, if the camera locks on a boss room, the character is automatically transported to that boss room.
  
 
== Screen wrap ==
 
== Screen wrap ==
Line 118: Line 123:
  
 
== Slope glitch ==
 
== Slope glitch ==
TODO
+
When you stand on a sprite-based object as it's destroyed, you enter a state in which you retain the angle of the last ground you landed on.  So for instance if you land on a curved mound of snow in Ice Cap, you will be able to walk as if you were always on that same curve, even if you're not anymore.  You can use this to enter ground and walls, as well as "hover" in the air.  It remains active until you land on top of a sprite-based object like a spring or crumbling platform.  It does not go away if you touch a sprite from the side.  With few exceptions, you cannot crouch during this state.
 
+
<setz> i have an explanation<br />
+
<setz> it fucks up the game
+
  
 
= Detailed physics information =
 
= Detailed physics information =
 
*Sonic Retro's [http://info.sonicretro.org/Category:Sonic_Physics_Guide Sonic Physics Guide] is a fantastic resource for understanding how speed works in the Sonic games.
 
*Sonic Retro's [http://info.sonicretro.org/Category:Sonic_Physics_Guide Sonic Physics Guide] is a fantastic resource for understanding how speed works in the Sonic games.
 
*TASvideos has a much more in-depth analysis, mostly dealing with the way the engine works. It can be found at http://tasvideos.org/GameResources/Genesis/SonicTheHedgehog.html (this covers all three games in the classic series).
 
*TASvideos has a much more in-depth analysis, mostly dealing with the way the engine works. It can be found at http://tasvideos.org/GameResources/Genesis/SonicTheHedgehog.html (this covers all three games in the classic series).

Latest revision as of 12:06, 30 November 2013

Why we use in-game time and not real time

In all of the classic Sonic games, completing levels very quickly (under 30 seconds in Sonic 1 and 2, and under 60 seconds in Sonic 3 & Knuckles) gives a 50,000 point time bonus. Completing a level at 30 (or 60) seconds gives a 10,000 time bonus instead. On the act clear screen, the bonus ticks down at a rate of 100 points per frame, and cannot be skipped. What this means is, in real time it would in fact be faster to wait for the timer to tick over to 30 (or 60), as long as the time you would otherwise get is between 23 and a third (53 and a third) seconds and 30 (60) seconds even. The Sonic playing community generally agrees that this is pretty dumb, and the time spent actually playing the stages is what matters, so these games are timed by taking the sum of the in-game times for each level.

For a further explanation, this video does a good job of explaining why in-game time matters in certain games, particularly in the Sonic franchise.

Game Mechanics

General Physics

All Sonic games work with 3 types of 16x16 pixel blocks; Top solid, left/right/bottom solid and all solid. Additionally every block can be assigned solidity for "path 0" and "path 1".

All tiles also have an angle assigned to them which is a number between 0 and 256 (FF in hex) for which the games use a table of values for trigonometry calculations.

Lastly there are two planes (A and B) where B is used for background art and A is the level itself. For both of these planes, blocks can be assigned to show in front of the character or behind.

The levels themselves are built using "chunks" of 16x16 blocks (256 pixels) in Sonic 1 and 8x8 blocks (128 pixels) in later games. Every pixel is then divided into 128 subpixels and all movement is calculated with them.

Whenever the character moves, the new position is calculated based on your current position, speed and acceleration. If a solid object is in the way it is possible to completely bypass it if no calculated position collides with the object. In laymans terms, if Sonic is fast enough he can ignore solid objects because he's too fast to interact with them.

These speeds are typically above 16 pixels of movement per frame (p/f for future reference) and can't be achieved without assistance as no unaided action in the games give you greater speed. For a lot of "level wraps" the speed given is on the limit of being enough and thus your position becomes important, even down to the subpixel.

Path switchers

Path switcher in effect

Path switchers are invisible objects in Sonic 2, Sonic 3 and Sonic & Knuckles that changes what path you're on and allows the levels to work as structured. These objects seamlessly switch the character from one path to another. This is especially necessary for things like loops to work. Knowing where these are and how they work is key to some tricks in the games.

Sonic 1 doesn't switch paths with objects as all levels only have 1 solidity path. Instead, loops have a sort of area of transition.

Speed cap

In Sonic 1, the game imposes a horizontal speed cap of 6 p/f whenever all of the following is true:

  • Sonic isn't rolling or jumping from a roll
  • Sonic is travelling above the normal maximum running speed on flat ground
  • The player holds the button corresponding to the direction of travel

Sonic 2 partially fixed Sonic 1's very restrictive speed cap, but it still activates in limited situations. Specifically, the following conditions have to be met:

  • Sonic is not on the ground
  • Sonic has air control (see: rolljumping)
  • Sonic is travelling above the normal maximum running speed on flat ground
  • The player holds the button corresponding to the direction of travel

If all these conditions are met, Sonic's horizontal speed reverts to the normal maximum running speed 6 p/f. Surprisingly, this is actually beneficial in some levels, see Chemical Plant 1 and 2, and Metropolis 1.

In Sonic 2, Sonic 3 and Sonic & Knuckles, the speed cap can be overcome by other means of acceleration such as boosters, slope jumps and running down hills. The games will handle this higher speed as the new speed cap until you slow down below the normal cap.

Given the right conditions, running would allow you to accelerate indefinitely. Rolling however has a set speed cap of 16 p/f no matter the situation in all games.

Air physics

Horizontal acceleration is higher while in the air, which is why jumping at the beginning of a stage is common in Sonic 1. Whenever a character jumps, the vertical and horizontal speeds are added as vectors, with the addition of the power of your jump (6.5 p/f as Sonic and 6 p/f as Knuckles) and the angle of the slope you're currently on. Jumping on the very frame you land makes this calculation treat all slopes as having the angle 0 degrees (the angle of air).

Whenever a character has an upwards speed between 0 and 4 p/f, an "air drag" effect takes affect if the vertical velocity is above the normal maximum running speed. In all other situations (e.g. falling down or travelling up faster than 4 p/f) the air behaves like a vacuum and except for acceleration normal ground physics apply.

If a character is currently jumping and travelling upwards faster that 4 p/f, it can be instantly set to 4 p/f by releasing the jump button.


Rolling and Spindashing

Spindashing has 9 possible speeds, between 8 p/f and 12 p/f in half integers. Every time a button is pressed you add 2 to the base value 8, which then subsequently decreases faster the higher the total value is. Because of this, the minimum requirement to get a 12 speed is 6 button presses, commonly referred to as a "6-tap".

Since you always decelerate while rolling unless going down a slope, getting back to running by jumping into ceilings, down slopes or inside loops are things you generally want to do after spindashing.

There's no guaranteed way to get a certain spindash speed, so usually runners do 3-taps or other increments in order to get close to the desired speed.

Another quirk that further complicates rolling is that whenever you jump from one, you lose all control of your character. In Sonic 3, Sonic & Knuckles and Sonic 2 & Knuckles, doing your air ability will let you regain control mid air, but in Sonic 1 and Sonic 2 there's no way to manipulate your trajectory after a "roll jump".

Due to an error regarding Sonic's height in Sonic 2 whenever you rolljump into something and stop, you'll land 5 pixels above ground. This was fixed in Sonic 3 but consequently whenever you rolljump, you sink 5 pixels into the ground before taking off, which actually allows you to clip into the ground in Marble Garden 1 by a yellow spring as Sonic and Knuckles. Since Tails is smaller, he only sinks 1 pixel into the ground and thus can't do the same trick.

Air Abilities (Sonic 3 & Knuckles only)

In common for all air abilities is that they can only be executed while having an upwards velocity of less than 4 p/f. This is why you have to release the jump button and press it again in order to fly or instashield at the beginning of a jump, but can hold the button and press a new one at the apex of a jump.

Universal timer

There's two different timing properties of moving objects in these games. The universal timer is where an object starts moving the instant you start the level, and will therefore be in a certain position at a certain time, every time.

Camera timer

The other kind is this one, which only starts moving once it's brought onto the screen (or near the screen - when the object is first rendered, in any case). Knowing which objects have which timing properties is important to good times when you have to deal with them.

Horizontal Movement Lock

When moving on sloped ground/ceilings, the game imposes a movement lock if you are holding either left or right while attaining a certain minimum angled speed. This lock removes your horizontal control of the character for a set number of frames (based on the angled speed you had), though you can still jump and roll. You can avoid it by releasing to neutral before the lock activates, then pressing left or right after your angled speed is slow enough. The lock's timer is frozen while you are in the air, and in the case of Sonic 3, if activated in tandem with the wheel glitch in Carnival Night 1.

Mechanics specific to Sonic

Height

Sonic is a bit taller than Tails which means some zips, clips and tricks work differently or not at all. An example of a zip that Sonic can do but not Tails is the one right before the Lava Reef 2 boss skip and an example of a zip Sonic can't do is the Death Egg 2 level wrap. Whenever Sonic is doing a rolljump, he sinks 5 pixels into the ground on the first frame as opposed to Tails who only sinks 1 pixel. This is the main reason Sonic can clip into the ground at the spring in Marble Garden 1 but not Tails.

Shield properties (Sonic 3 & Knuckles only)

In Sonic 3 there's a timer for instashielding that prevents you from doing it more often than about every second or so. This was removed in S&K.

Having used an air ability sets a value in the ram even if you would switch ability mid jump, as is the case with Sonics shields. For example, if you were to instashield into a bubble monitor, the game would prevent you from bouncing until you land, but still make the small bounce you always get when landing after bouncing on an object.

The fire shield instantly sets your horizontal velocity to 8 p/f and vertical velocity to 0. Therefore it's faster to use once on flat ground or to spam as much as possible on upwards slopes, but not while having a higher speed.

The electrical shield sets your vertical speed to 5.5 p/f upwards. It also protects against some damaging electrical hazards such as the capacitors in Death Egg, but not the sparks flying off of them.

The bubble shield sets your vertical velocity to 8 downwards and then 7.5 p/f upwards, which means for example that bouncing from a destroyable object will give you more height regardless of starting point, but bouncing from a higher point without an object won't as objects typically completely reverses your speed.

Mechanics specific to Knuckles

Landing from a glide (Sonic 2 only)

When Knuckles lands from a glide, while it looks like he goes into the crouching animation he actually goes into a separate animation, which lasts for 15 frames (1/4 of a second) after landing. Importantly, Knuckles cannot spindash during this time.

Superglide

Simply jump on an object (an enemy or an item box) and glide just before you hit it. This causes you to translate your falling speed upwards, and since you're gliding you have a much lower rate of acceleration towards the ground. In layman's terms, you end up a lot higher than a standard jump.

Advanced Techniques

Ramp jump

Sonic's jump speed and height are dependent on both your speed going into the jump and the slope of the ground you jump off. Running up a slope causes your jump to become much higher, while running down a slope will make you jump quite flat to the ground, gaining speed. This applies even if the slope is very small.

Loop jump

Similar concept, but inside a loop. If you're moving through the loop from left to right, a loop jump is from the top-left to the bottom-left. It's kinda finicky because if you land at different angles you get different speeds, but in the best case it is faster, and it's also a very convenient way to switch from rolling to running.

Zip

A zip occurs when Sonic is stuck in a wall somehow and presses left or right. Since collision detection is designed to stop you from going into a wall in the first place, pushing left against a wall makes the game push you back to the right so you aren't embedded in it. As a result, when you're already inside a wall holding left or right causes you to travel in the opposite direction much faster than you can attain by normal play.

Level wrap

This is what happens when a zip causes you to bypass the left edge of the screen. The game treats your X-coordinate in memory as a number less than 0 - but position coordinates are unsigned, so instead of a negative number it's a VERY large positive one - which correlates to the end of the stage. This requires some very specific circumstances depending on the level.
In Sonic 3 & Knuckles, a level wrap always puts you to x-position 32767, even if the stage isn't that long. To fill out the remainder of the map, the level repeats itself, this area is termed the "loopback". No sprites or path switchers exist in this area, but all the level geometry still exists, so you can maneuver around (somewhat) freely. However, if the camera locks on a boss room, the character is automatically transported to that boss room.

Screen wrap

Similar concept to the level wrap, but using vertical coordinates instead. In levels that wrap around infinitely vertically (the three acts of Metropolis in Sonic 2, and Marble Garden 1, Ice Cap 1 and Sandopolis 2 in Sonic 3 & Knuckles), instead of using absolute values for vertical position, it uses values linked to the camera position. The top of the camera is position 0, and anything above it is negative, which since position values are unsigned, is a large positive number, which causes the screen to scroll downwards to that position. In the time it takes to scroll down, any sprite objects cease to exist until they are brought back onto the screen, and your character can move into them.

Slope glitch

When you stand on a sprite-based object as it's destroyed, you enter a state in which you retain the angle of the last ground you landed on. So for instance if you land on a curved mound of snow in Ice Cap, you will be able to walk as if you were always on that same curve, even if you're not anymore. You can use this to enter ground and walls, as well as "hover" in the air. It remains active until you land on top of a sprite-based object like a spring or crumbling platform. It does not go away if you touch a sprite from the side. With few exceptions, you cannot crouch during this state.

Detailed physics information

Personal tools