Actions

Difference between revisions of "SPG:Animations"

From Sonic Retro

(Added animation system description for more accurate walk animation - however creates conflict with written predetermined subimage durations (addressed).)
m (Formatting)
Line 14: Line 14:
  
 
On the frame that the animation is first set, the subimage will be set to the first of the animation (or another if specified), and the subimage duration timer will be set. This is the case for all animations. In the case of the walking animation, this delay is set to
 
On the frame that the animation is first set, the subimage will be set to the first of the animation (or another if specified), and the subimage duration timer will be set. This is the case for all animations. In the case of the walking animation, this delay is set to
<nowiki>
+
 
 +
<nowiki>
 
duration = floor(max(0, 8-abs(GroundSpeed)))
 
duration = floor(max(0, 8-abs(GroundSpeed)))
 
</nowiki>
 
</nowiki>
Line 42: Line 43:
 
===Walking and Running===
 
===Walking and Running===
 
Using the timer described at the top, when Sonic is walking or running the subimage duration counter is set to   
 
Using the timer described at the top, when Sonic is walking or running the subimage duration counter is set to   
<nowiki>
+
 
 +
<nowiki>
 
duration = floor(max(0, 8-abs(GroundSpeed)))
 
duration = floor(max(0, 8-abs(GroundSpeed)))
 
</nowiki>
 
</nowiki>
 +
 
This is the same in Sonic 1, 2 and [[Sonic the Hedgehog 3|3]]. This remains even when at full speed (spinning feet), or faster. The animation is changed to spining feet when Sonic's absolute ground speed is larger or equal to 6.  
 
This is the same in Sonic 1, 2 and [[Sonic the Hedgehog 3|3]]. This remains even when at full speed (spinning feet), or faster. The animation is changed to spining feet when Sonic's absolute ground speed is larger or equal to 6.  
  
 
===Jumping/Rolling===
 
===Jumping/Rolling===
 
Using the timer described at the top, whyen Sonic is rolling the subimage duration counter is set to   
 
Using the timer described at the top, whyen Sonic is rolling the subimage duration counter is set to   
<nowiki>
+
 
 +
<nowiki>
 
duration = floor(max(0, 5-abs(GroundSpeed)))
 
duration = floor(max(0, 5-abs(GroundSpeed)))
 
</nowiki>
 
</nowiki>
 +
 
However, when rolling in the air or jumping, the animation speed will remain constant due to the fact that ground speed does NOT update in the air. In other words, the animation remains the speed it was when you left the ground until you land.
 
However, when rolling in the air or jumping, the animation speed will remain constant due to the fact that ground speed does NOT update in the air. In other words, the animation remains the speed it was when you left the ground until you land.
  

Revision as of 18:56, 11 December 2019

Notes: Research applies to all four of the Mega Drive games, and Sonic CD. There are varying differences between the games, as each game uses different animations. This will be covered below.

  • Animation notes for Tails and Knuckles are not yet included. They will be included in due time.
  • "subimage" refers to an animation frame, while "frame" refers to a game frame, or 1/60th of a second.

Animation System

The animation system in the original Sonic trilogy may differ from that offered in modern IDEs by default. While knowing the specific subimage durations may be enough for a rough emulation, some animations are dynamically sped up and slowed down (such as walking) and thus may require more depth to achieve the same timings.

The animation system works as a counter, counting down the animation subimage's duration, then updating the animation upon completion, and resetting the counter. For example, a subimage which has a duration of 8 frames sets the counter to 7, and counts down every frame. On the frame this counter reaches -1, the duration counter is reset and the subimage is increased. You could set the timer to 8 and have the counter terminate at 0, but this isn't how the original games perform and results may differ if you do.

Once the subimage exceeds the amount of subimages in a looping animation, that frame the subimage is simply set to the first subimage. Alternatively, the animation stops playing at the last frame.

Example

The walking animation will be covered again, however this is a special aniamtion using this system as it speeds up and slows down as Sonic does.

On the frame that the animation is first set, the subimage will be set to the first of the animation (or another if specified), and the subimage duration timer will be set. This is the case for all animations. In the case of the walking animation, this delay is set to

duration = floor(max(0, 8-abs(GroundSpeed)))

So for example: if Sonic's ground speed is 5 or -5, the duration counter will be set to 3. Remember, as stated initially this will actually result in the subimage being shown for 4 frames due to the duration counter's quirks.

On the next frame, the duration counter will begin decreasing. Once the counter reaches -1, on that same frame the animation moves to the next subimage and the duration is updated again and is once again calculated from the ground speed. For some animations these delays are predetermined as will be described in the specific speeds portion of this guide and may use a different timer. For the walk animation it is the same calculation as above each time. This process repeats until the animation is set to something else.


Specific Speeds

Shown below are the subimage durations of the animations featured in the Sonic games. Such information can be used to replicate accurate animations in a fangame engine. These predetermined durations are the apparent durations, and don't directly correlate with the strange timer in the walking animation described above. In this section, specific frame timings such as "24" mean 24 frames onscreen.

Idle

Sonic 1

Every sprite subimage in this animation lasts for 24 frames. Sonic stays still for 288 frames (the subimage occurs 12 times in the animation code) before entering the waiting subimages of the idle animation. When the waiting portion begins, Sonic enters a subimage for 24 frames, then has his eyes wide open for 72 frames. Afterwards, he will alternate between two subimages every 24 frames, making Sonic appear to tap his foot on the ground. This will loop until the player takes action.

Sonic 2

Every sprite subimage in this animation lasts for 6 frames. Sonic stays still for 180 frames (the subimage occurs 30 times in the animation code) before entering the first set of waiting subimages of the idle animation. He then blinks, which lasts for 6 frames, then has his eyes wide open for 30 frames. Afterwards, he will alternate between two subimages every 18 frames, making Sonic appear to tap his foot on the ground. This will loop until the player takes action.

Should the player NOT take action after Sonic taps his foot 3 times (126 frames) (Note: the animation starts with Sonic's foot down and ends with it pointing upwards), he will then look down at his wrist(watch?) for 60 frames, then resume tapping his foot. This foot-tapping/wristwatch sequence will continue 3 more times (204 frames/sequence*4=816 total frames). Afterwards, if no action is taken at this point, Sonic will enter a new animation where he lies down on the floor. It takes 6 frames for him to drop to the ground. He then enters a final alternating sequence tapping his finger against his shoe. Both subimages in this sequence last for 18 frames each.

Sonic 3K

Every sprite subimage in this animation lasts for 6 frames.

Walking and Running

Using the timer described at the top, when Sonic is walking or running the subimage duration counter is set to

duration = floor(max(0, 8-abs(GroundSpeed)))

This is the same in Sonic 1, 2 and 3. This remains even when at full speed (spinning feet), or faster. The animation is changed to spining feet when Sonic's absolute ground speed is larger or equal to 6.

Jumping/Rolling

Using the timer described at the top, whyen Sonic is rolling the subimage duration counter is set to

duration = floor(max(0, 5-abs(GroundSpeed)))

However, when rolling in the air or jumping, the animation speed will remain constant due to the fact that ground speed does NOT update in the air. In other words, the animation remains the speed it was when you left the ground until you land.

Pushing

The animation waits 32 frames before advancing to the next subimage when pushing. This remains true in all games.

Balancing

Sonic 1

While balancing, the animation waits 16 frames before advancing to the next subimage.

Sonic 2

In Sonic 2 each of the 3 balancing animations have different animation speeds.

The facing forward balance animation waits 10 frames before advancing to the next subimage.

The backwards balance animation waits 20 frames before advancing to the next subimage.

And the last balance animation waits 4 frames before advancing to the next subimage.

Sonic 3

In Sonic 3 there are only 2 balancing animations, the one when you're at the edge, and the one when you're further down the edge.

The first one waits 8 frames before advancing to the next subimage.

And the second one waits 6 frames before advancing to the next subimage.

Braking

In Sonic 1, the animation waits 8 frames before advancing to the next subimage while braking. It will continue to loop between the two subimages until Sonic has stopped. In Sonic 2 and Sonic 3K, the animation will stop when it finishes, instead of looping.

Spindash

The spindash animation itself waits 1 frame to advance a subimage.

When a button is pressed to charge up the spindash, the subimage is set to 1 (therefore resetting it).

Converting The Frame Duration

For programs such as GameMaker or MMF, to display an animation properly without an advances system you may need the speed of the animation instead of the duration of the frames. This is a very rough way to animate the sprites semi-accurately but may result in faster walking animations and other differences.

  • In GameMaker, the animation speed (image_speed) is how many subimages will be advanced per frame, so a speed of 1 will advance a subimage each frame,and 0.5 will advance a subimage every 2 frames. Although it's better to just set the image_speed like this in the first place.
    • To convert a frame duration to a GameMaker image speed, simply divide 1 by it.
     //Converts the frame duration into an image_speed compatible value for GameMaker.
     image_speed = (1/frame_duration);