Actions

Difference between revisions of "Sonic Physics Guide"

From Sonic Retro

(Refreshed the old introduction for the guide, new formatting)
(Undoing the use of tables for formatting, instead updating headers to organise)
Line 7: Line 7:
 
This guide will present these physics rules in an engine-agnostic manner, focusing on the tangible results of the game logic instead of delving into the minutiae of how the original 68k assembly code operated. As a result, these rules can be applied to modern programming languages such as Java, C, C++, Python, or a Lisp dialect when implementing the physics described in this guide. Moreover, individuals using this guide will be able to easily utilise specialised engines/IDEs such as GameMaker, Unity, Godot, Clickteam Fusion, or Love2D to implement the described game rules. Nevertheless, it is important to note that this guide will still acknowledge the quirks, limitations, and workarounds that were necessary for the original game due to its utilisation of a low-level programming language.
 
This guide will present these physics rules in an engine-agnostic manner, focusing on the tangible results of the game logic instead of delving into the minutiae of how the original 68k assembly code operated. As a result, these rules can be applied to modern programming languages such as Java, C, C++, Python, or a Lisp dialect when implementing the physics described in this guide. Moreover, individuals using this guide will be able to easily utilise specialised engines/IDEs such as GameMaker, Unity, Godot, Clickteam Fusion, or Love2D to implement the described game rules. Nevertheless, it is important to note that this guide will still acknowledge the quirks, limitations, and workarounds that were necessary for the original game due to its utilisation of a low-level programming language.
  
__NOTOC__
+
__TOC__
  
 
==Physics Guides==
 
==Physics Guides==
{| class="prettytable" style="width: auto;"
+
===General===
!style="width: 33%" colspan="3"|'''General'''
 
|-
 
|style="width: 33%; vertical-align: top;"|
 
 
'''[[SPG:Basics|Basics]]'''<br>
 
'''[[SPG:Basics|Basics]]'''<br>
A prerequisite for much of the info on this guide, including common variables, how angles work, how object sizes are displayed, and more.
+
A prerequisite for much of the info on this guide, including common object variables, how angles work, how object sizes are displayed, and more.
 
:*[[SPG:Basics#Positions|''Positions And Speeds'']]
 
:*[[SPG:Basics#Positions|''Positions And Speeds'']]
 
:*[[SPG:Basics#Angles|''Angles'']]
 
:*[[SPG:Basics#Angles|''Angles'']]
 
:*[[SPG:Basics#Variables|''Variables'']]
 
:*[[SPG:Basics#Variables|''Variables'']]
|style="width: 33%; vertical-align: top;"|
+
 
 
'''[[SPG:Calculations|Calculations]]''' (Technical)<br>
 
'''[[SPG:Calculations|Calculations]]''' (Technical)<br>
A detailed explanation of how values like speeds, positions, and angles are stored and calculated in the original games. While it is not necessary to emulate these things for an extremely close recreation, they are necessary for absolute accuracy.
+
A detailed explanation of how values like speeds, positions, and angles are stored and calculated in the original games. While it is not necessary to emulate things for an extremely close recreation, they are necessary for absolute accuracy
 
:*[[SPG:Calculations#Pixel and Subpixel|''Pixel and Subpixel'']]
 
:*[[SPG:Calculations#Pixel and Subpixel|''Pixel and Subpixel'']]
 
:*[[SPG:Calculations#Hex Angles|''Hex Angles'']]
 
:*[[SPG:Calculations#Hex Angles|''Hex Angles'']]
|style="width: 33%; vertical-align: top;"|
+
 
 
'''[[SPG:Characters|Characters]]'''<br>
 
'''[[SPG:Characters|Characters]]'''<br>
 
Information about specific characters and their constants, variables, sizes, and jump height.
 
Information about specific characters and their constants, variables, sizes, and jump height.
Line 30: Line 27:
 
:*[[SPG:Characters#Tails|''Tails'']]
 
:*[[SPG:Characters#Tails|''Tails'']]
 
:*[[SPG:Characters#Knuckles|''Knuckles'']]
 
:*[[SPG:Characters#Knuckles|''Knuckles'']]
|}
 
  
{| class="prettytable" style="width: auto;"
+
 
!style="width: 33%"|'''Collision'''
+
===Gameplay===
!style="width: 33%"|'''Physics'''
+
These guides will explain what happens during gameplay scenarios, such as slope collision, player movement, and object interactions.
!style="width: 33%"|'''Gameplay'''
+
<div class="large-4 columns" style="margin: 0px; padding: 0px 0.9375rem 0px 0px">
|-
+
====Collision====
|style="width: 33%; vertical-align: top;"|
 
 
'''[[SPG:Solid Tiles|Solid Tiles]]'''<br>
 
'''[[SPG:Solid Tiles|Solid Tiles]]'''<br>
''Terrain Part 1:'' A detailed description of the individual building blocks of terrain, and how they are processed and detected.  
+
''Terrain Part 1:'' A detailed description of the individual building blocks of terrain, and how they are processed and detected.
 
:*[[SPG:Solid Tiles#Sensors|''Sensors'']]
 
:*[[SPG:Solid Tiles#Sensors|''Sensors'']]
<hr>
+
 
 
'''[[SPG:Solid Terrain|Solid Terrain]]'''<br>
 
'''[[SPG:Solid Terrain|Solid Terrain]]'''<br>
 
:''Terrain Part 2:'' How Solid Tiles and collison layers are used to construct slopes, loops, and other structures.
 
:''Terrain Part 2:'' How Solid Tiles and collison layers are used to construct slopes, loops, and other structures.
 
:*[[SPG:Solid Terrain#Layers|''Layers'']]
 
:*[[SPG:Solid Terrain#Layers|''Layers'']]
 
:*[[SPG:Solid Terrain#Loops|''Loops'']]
 
:*[[SPG:Solid Terrain#Loops|''Loops'']]
<hr>
+
 
 
'''[[SPG:Slope Collision|Slope Collision]]'''<br>
 
'''[[SPG:Slope Collision|Slope Collision]]'''<br>
 
''Slopes Part 1:'' How the Player object uses its sensor arrangement to detect and react to sloped terrain.  
 
''Slopes Part 1:'' How the Player object uses its sensor arrangement to detect and react to sloped terrain.  
Line 54: Line 49:
 
:*[[SPG:Slope Collision#Ceiling_Sensors_.28C_and_D.29|''Ceiling Sensors (C and D)'']]
 
:*[[SPG:Slope Collision#Ceiling_Sensors_.28C_and_D.29|''Ceiling Sensors (C and D)'']]
 
:*[[SPG:Slope Collision#Wall_Sensors_.28E_and_F.29|''Wall Sensors (E and F)'']]
 
:*[[SPG:Slope Collision#Wall_Sensors_.28E_and_F.29|''Wall Sensors (E and F)'']]
<hr>
+
 
 
'''[[SPG:Hitboxes|Hitboxes]]'''<br>
 
'''[[SPG:Hitboxes|Hitboxes]]'''<br>
 
Object hitboxes, the Player's hitbox, and other ways objects directly interact with the player other than solidity.
 
Object hitboxes, the Player's hitbox, and other ways objects directly interact with the player other than solidity.
 
:*[[SPG:Hitboxes#The_Player.27s_Hitbox|''The Player's Hitbox'']]
 
:*[[SPG:Hitboxes#The_Player.27s_Hitbox|''The Player's Hitbox'']]
 
:*[[SPG:Hitboxes#Trigger_Areas|''Trigger Areas'']]
 
:*[[SPG:Hitboxes#Trigger_Areas|''Trigger Areas'']]
<hr>
+
 
 
'''[[SPG:Solid Objects|Solid Objects]]'''<br>
 
'''[[SPG:Solid Objects|Solid Objects]]'''<br>
 
Object solidity, jump through platforms, and sloped variants of each.
 
Object solidity, jump through platforms, and sloped variants of each.
Line 67: Line 62:
 
:*[[SPG:Solid Objects#Pushable Blocks|''Pushable Blocks'']]
 
:*[[SPG:Solid Objects#Pushable Blocks|''Pushable Blocks'']]
 
:*[[SPG:Solid Objects#Item Monitor|''Item Monitor'']]
 
:*[[SPG:Solid Objects#Item Monitor|''Item Monitor'']]
|style="width: 25%; vertical-align: top;"|
+
</div>
 +
<div class="large-4 columns" style="margin: 0px; padding: 0px 0.9375rem 0px 0.9375rem">
 +
====Physics====
 
'''[[SPG:Slope Physics|Slope Physics]]'''<br>
 
'''[[SPG:Slope Physics|Slope Physics]]'''<br>
 
''Slopes Part 2:'' How the Player moves with momentum over angled surfaces, and 360° movement along extreme slopes such as walls and ceilings.
 
''Slopes Part 2:'' How the Player moves with momentum over angled surfaces, and 360° movement along extreme slopes such as walls and ceilings.
Line 74: Line 71:
 
:*[[SPG:Slope Physics#Falling and Slipping Down Slopes|''Falling and Slipping Down Slopes'']]
 
:*[[SPG:Slope Physics#Falling and Slipping Down Slopes|''Falling and Slipping Down Slopes'']]
 
:*[[SPG:Slope Physics#Landing On The Ground|''Landing On The Ground'']]
 
:*[[SPG:Slope Physics#Landing On The Ground|''Landing On The Ground'']]
<hr>
+
 
 
'''[[SPG:Running|Running]]'''<br>
 
'''[[SPG:Running|Running]]'''<br>
 
Physics & control of the Player while walking/running.
 
Physics & control of the Player while walking/running.
<hr>
+
 
 
'''[[SPG:Rolling|Rolling]]'''<br>
 
'''[[SPG:Rolling|Rolling]]'''<br>
 
Physics & control of the Player while rolling.
 
Physics & control of the Player while rolling.
<hr>
+
 
 
'''[[SPG:Air State|Air State]]'''<br>
 
'''[[SPG:Air State|Air State]]'''<br>
 
Physics & control of the Player while they are in the air.
 
Physics & control of the Player while they are in the air.
<hr>
+
 
 
'''[[SPG:Jumping|Jumping]]'''<br>
 
'''[[SPG:Jumping|Jumping]]'''<br>
 
Physics & control while Jumping, how controllable jump height is achieved, and jumping at angles.
 
Physics & control while Jumping, how controllable jump height is achieved, and jumping at angles.
<hr>
+
 
 
'''[[SPG:Getting Hit|Getting Hit]]'''<br>
 
'''[[SPG:Getting Hit|Getting Hit]]'''<br>
 
What happens when the Player gets hit or dies.
 
What happens when the Player gets hit or dies.
<hr>
+
 
 
'''[[SPG:Rebound|Rebound]]'''<br>
 
'''[[SPG:Rebound|Rebound]]'''<br>
 
Physics when bouncing off enemies, bosses and other destroy-able items.
 
Physics when bouncing off enemies, bosses and other destroy-able items.
Line 97: Line 94:
 
:*[[SPG:Underwater#Air|''Air'']]
 
:*[[SPG:Underwater#Air|''Air'']]
 
:*[[SPG:Underwater#Physics|''Physics'']]
 
:*[[SPG:Underwater#Physics|''Physics'']]
<hr>
+
 
 
'''[[SPG:Super Speeds|Super Speeds]]'''<br>
 
'''[[SPG:Super Speeds|Super Speeds]]'''<br>
 
The Player's speeds and abilities when super.
 
The Player's speeds and abilities when super.
|style="width: 33%; vertical-align: top;"|
+
</div>
 +
 
 +
<div class="large-4 columns" style="margin: 0px; padding: 0px 0.9375rem 0px 0.9375rem">
 +
====Gameplay====
 
'''[[SPG:Main Game Loop|Main Game Loop]]'''<br>
 
'''[[SPG:Main Game Loop|Main Game Loop]]'''<br>
 
The order that objects update each frame, and order of specific events like Player collision and movement.
 
The order that objects update each frame, and order of specific events like Player collision and movement.
<hr>
+
 
 
'''[[SPG:Game Objects|Game Objects]]'''<br>
 
'''[[SPG:Game Objects|Game Objects]]'''<br>
 
Mechanics and sizes for things like rings, pushable blocks, buttons, and springs. How they are constructed, function, and interact with the Player.
 
Mechanics and sizes for things like rings, pushable blocks, buttons, and springs. How they are constructed, function, and interact with the Player.
<hr>
+
 
 
'''[[SPG:Game Enemies|Game Enemies]]'''<br>
 
'''[[SPG:Game Enemies|Game Enemies]]'''<br>
 
Badnik and bosses behaviour, collision, and specific interaction with the Player.
 
Badnik and bosses behaviour, collision, and specific interaction with the Player.
 
:*[[SPG:Game Enemies#Badniks|''Badniks'']]
 
:*[[SPG:Game Enemies#Badniks|''Badniks'']]
 
:*[[SPG:Game Enemies#Bosses|''Bosses'']]
 
:*[[SPG:Game Enemies#Bosses|''Bosses'']]
<hr>
+
 
 
'''[[SPG:Ring Loss|Ring Loss]]'''<br>
 
'''[[SPG:Ring Loss|Ring Loss]]'''<br>
 
Ring dispersal mechanics and physics when lost.
 
Ring dispersal mechanics and physics when lost.
<hr>
+
 
 
'''[[SPG:Special Abilities|Special Abilities]]'''<br>
 
'''[[SPG:Special Abilities|Special Abilities]]'''<br>
 
General special abilities such as spindashing, and also detailing how character specific moves work.
 
General special abilities such as spindashing, and also detailing how character specific moves work.
Line 124: Line 124:
 
:*[[SPG:Special_Abilities#Gliding|''Gliding'']]
 
:*[[SPG:Special_Abilities#Gliding|''Gliding'']]
 
:*[[SPG:Special_Abilities#Climbing|''Climbing'']]
 
:*[[SPG:Special_Abilities#Climbing|''Climbing'']]
<hr>
+
 
 
'''[[SPG:Elemental Shields|Elemental Shields]]'''<br>
 
'''[[SPG:Elemental Shields|Elemental Shields]]'''<br>
 
Elemental Shield abilities, powers, and moves.
 
Elemental Shield abilities, powers, and moves.
Line 130: Line 130:
 
:*[[SPG:Elemental_Shields#Bubble_Shield|''Bubble Shield'']]
 
:*[[SPG:Elemental_Shields#Bubble_Shield|''Bubble Shield'']]
 
:*[[SPG:Elemental_Shields#Lightning_Shield|''Lightning Shield'']]
 
:*[[SPG:Elemental_Shields#Lightning_Shield|''Lightning Shield'']]
<hr>
+
 
 
'''[[SPG:Special Stages|Special Stages]]'''<br>
 
'''[[SPG:Special Stages|Special Stages]]'''<br>
 
Special stages including the rotating mazes from Sonic 1.
 
Special stages including the rotating mazes from Sonic 1.
 
:*[[SPG:Special Stages#Rotating Maze|''Rotating Maze'']]
 
:*[[SPG:Special Stages#Rotating Maze|''Rotating Maze'']]
|-
+
</div>
!colspan="3"|'''Presentation'''
+
 
|-
+
==Presentation==
|style="vertical-align: top;" colspan="3"|
 
 
'''[[SPG:Camera|Camera]]'''<br>
 
'''[[SPG:Camera|Camera]]'''<br>
 
Camera mechanics when following the Player.
 
Camera mechanics when following the Player.
<hr>
+
 
 
'''[[SPG:Animations|Animations]]'''<br>
 
'''[[SPG:Animations|Animations]]'''<br>
 
Animations system, and specific animation timings & rules.
 
Animations system, and specific animation timings & rules.
Line 147: Line 146:
 
:*[[SPG:Animations#Normal Animation Timings|''Normal Animation Timings'']]
 
:*[[SPG:Animations#Normal Animation Timings|''Normal Animation Timings'']]
 
:*[[SPG:Animations#Animation Rules|''Animation Rules'']]
 
:*[[SPG:Animations#Animation Rules|''Animation Rules'']]
|-
+
 
!colspan="3"|'''Special'''
+
==Special==
|-
 
|style="vertical-align: top;" colspan="4"|
 
 
'''[[SPG:Overlay Scripts|Overlay Scripts]]'''<br>
 
'''[[SPG:Overlay Scripts|Overlay Scripts]]'''<br>
 
Lua scripts which overlay the game in an emulator for an interactive visual of collision.
 
Lua scripts which overlay the game in an emulator for an interactive visual of collision.
 
:*[[SPG:Overlay_Scripts#Sonic_1_Overlay|''Sonic 1 Overlay'']]
 
:*[[SPG:Overlay_Scripts#Sonic_1_Overlay|''Sonic 1 Overlay'']]
 
:*[[SPG:Overlay_Scripts#Sonic_2_Overlay|''Sonic 2 Overlay'']]
 
:*[[SPG:Overlay_Scripts#Sonic_2_Overlay|''Sonic 2 Overlay'']]
|}
+
 
 
[[Category:Sonic Physics Guide| ]]
 
[[Category:Sonic Physics Guide| ]]

Revision as of 16:24, 29 June 2023

Introduction

Welcome to the Sonic Physics Guide, a comprehensive resource dedicated to describing the inner workings of the classic Genesis & Sega CD Sonic games, along with Sonic Mania. Here, the intricate details of how the game's physics function are thoroughly explored, providing in-depth explanations about the exact values and rules and precise speed values governing Sonic's movements, 360 slope physics, Badnik & object behaviour, all the way to the construction of the sloped terrain. The guide will shed light on exactly how every aspect, from navigating slopes and loops to interacting with Springs, contributes to the gameplay.

Whether you're a curious newcomer, an experienced fan game developer, or a seasoned Sonic fan seeking a deeper understanding of the games, this guide aims to present the information in an accessible manner, providing clear and concise breakdowns of the underlying concepts.

This guide will present these physics rules in an engine-agnostic manner, focusing on the tangible results of the game logic instead of delving into the minutiae of how the original 68k assembly code operated. As a result, these rules can be applied to modern programming languages such as Java, C, C++, Python, or a Lisp dialect when implementing the physics described in this guide. Moreover, individuals using this guide will be able to easily utilise specialised engines/IDEs such as GameMaker, Unity, Godot, Clickteam Fusion, or Love2D to implement the described game rules. Nevertheless, it is important to note that this guide will still acknowledge the quirks, limitations, and workarounds that were necessary for the original game due to its utilisation of a low-level programming language.

Physics Guides

General

Basics
A prerequisite for much of the info on this guide, including common object variables, how angles work, how object sizes are displayed, and more.

Calculations (Technical)
A detailed explanation of how values like speeds, positions, and angles are stored and calculated in the original games. While it is not necessary to emulate things for an extremely close recreation, they are necessary for absolute accuracy

Characters
Information about specific characters and their constants, variables, sizes, and jump height.


Gameplay

These guides will explain what happens during gameplay scenarios, such as slope collision, player movement, and object interactions.

Collision

Solid Tiles
Terrain Part 1: A detailed description of the individual building blocks of terrain, and how they are processed and detected.

Solid Terrain

Terrain Part 2: How Solid Tiles and collison layers are used to construct slopes, loops, and other structures.

Slope Collision
Slopes Part 1: How the Player object uses its sensor arrangement to detect and react to sloped terrain.

Hitboxes
Object hitboxes, the Player's hitbox, and other ways objects directly interact with the player other than solidity.

Solid Objects
Object solidity, jump through platforms, and sloped variants of each.

Physics

Slope Physics
Slopes Part 2: How the Player moves with momentum over angled surfaces, and 360° movement along extreme slopes such as walls and ceilings.

Running
Physics & control of the Player while walking/running.

Rolling
Physics & control of the Player while rolling.

Air State
Physics & control of the Player while they are in the air.

Jumping
Physics & control while Jumping, how controllable jump height is achieved, and jumping at angles.

Getting Hit
What happens when the Player gets hit or dies.

Rebound
Physics when bouncing off enemies, bosses and other destroy-able items.

Underwater
Physics underwater, and how their remaining air is depleted.

Super Speeds
The Player's speeds and abilities when super.

Gameplay

Main Game Loop
The order that objects update each frame, and order of specific events like Player collision and movement.

Game Objects
Mechanics and sizes for things like rings, pushable blocks, buttons, and springs. How they are constructed, function, and interact with the Player.

Game Enemies
Badnik and bosses behaviour, collision, and specific interaction with the Player.

Ring Loss
Ring dispersal mechanics and physics when lost.

Special Abilities
General special abilities such as spindashing, and also detailing how character specific moves work.

Elemental Shields
Elemental Shield abilities, powers, and moves.

Special Stages
Special stages including the rotating mazes from Sonic 1.

Presentation

Camera
Camera mechanics when following the Player.

Animations
Animations system, and specific animation timings & rules.

Special

Overlay Scripts
Lua scripts which overlay the game in an emulator for an interactive visual of collision.