The Basics of Sonic Physics

The (very most barest) basics are explained in this five-minute video from Game Facts Special:

The (impossibly detailed) specifics are on Sonic Retro. Warning: you have no idea.

Can I summarize them briefly? Not really, but here’s the basics. The tiles link to a list of heights for that tile. If Sonic is traveling vertically up a wall, then the heights count as widths. If upside-down, then the inverse of the tile’s heights are used.

Every frame, Sonic emits four or five “sensors,” basically raycasts, around his feet and head. Those indicate where he’s standing and where the ceiling is. If he’s traveling vertically the rays are rotated 90 degrees in the proper direction, and for an upside-down Sonic they’re rotated 180 degrees. Additionally, each tile has a record of what its angle is, and that’s used for things like how it affects speed and what angle Sonic should jump at.

When going around a loop, Sonic’s sensors remain as normal until up past 45 degrees up the first ramp. Then his sensors rotate, and he’s now going up. 135 degrees around the loop, it rotates again, and again at 225 degrees, and one more time at 315 degrees. The same height values get used for each slope, just used for different purposes. It’s surprising it works as well as it does, really.