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.
This is one going out to all you developers out there, either current or aspiring.
It’s amazing to me how fussed, nay, obsessed-over the 16-bit Sonic the Hedgehog games are even to this day. There are a lot of good things about them, and arguably the best is their platforming engines, which are among the best in the field. They take advantage of the processing power of the Genesis/Mega Drive, fueled by a Motorola 68000 processor, the same processor as the classic Apple Macintosh, clocked only slightly slower. This was basis of Sega’s infamous “blast processing” slogan at the time, touting how much faster the Genesis was than the Super Nintendo Entertainment System. This was somewhat unfair, as SNES carts often came with supplemental chips in them that acted like co-processors, and was of a completely different architecture as well with different characteristics, but it did make the Sonic engine possible. A lot of the credit also goes to Sonic programmer Yuji Naka, who is legendary in game coding circles for a very good reason.
If this is the kind of discussion that makes your heart race, we’re glad to have you reading Set Side B! If it’s not, that’s okay. I’m a bit stymied myself, even though I love dives like this. (All images in this post from Sonic Retro.)
The result of the Genesis’s power and Naka’s expertise was a game engine with, yes, raw speed, but also a lot of nuance. If you jump and land on an enemy or monitor, you can control the height of your rebound, no matter how fast you were going when you hit it. If you jump while on a slope, you don’t jump straight up but away from it, which takes some getting used to at first but can be taken advantage of. There’s lots of fun little cases like these, and figuring them out, and their implications, is the source of a lot of the joy of playing Sonic the Hedgehog for the first time.
Those two places where the slope only intrudes slightly into Sonic’s ground tile are what get me.
I’d even argue, without the solid engine, and great level design taking advantage of it, all of Sega of America’s marketing efforts, which formed the foundation of the media juggernaut that Sonic has become today, with several cartoon series and comic books, and two successful movies and a third one in the works, would have been for naught.
Judging by the later 2D adventures, the nuances of Sonic the Hedgehog’s engine are difficult to grasp without a good amount of effort. It is likely that Sega themselves don’t have the institutional memory to understand how they worked, which is why they went to Christian “The Taxman” Whitehead, and others from the fan game community, to make Sonic Mania, which has a faithful recreation of the original games’ physics.
Why has no one made a Sonic half-pipe trick skateboarding game?
Bringing it back around, the obsession of the Sonic fan community has produced a number of disassembles of the game’s code, which have served as the basis for a wide array of romhacks of rather shocking levels of quality. I wrote about many of those in the Someone Set Up Us The Rom ebooks (ahem).
They also served as the basis for the subject of this post, the physics descriptions at Sonic Retro. Here is basically all you need to make a Sonic-style platformer. Synthesizing this and putting it into practice is a formidable task on its own, but it’s a doable one, and you don’t have to read source code (other than your own) to do it. To those who attempt this task, we salute you! And let us know how it goes!