Code: 1 2 3 4 5 6 X Z ! @ & ! * C N C W - 0 0 0 X 4 0 + $ 4 4 : : : 7 8 9 8 0 8 0 R # $ N N N T F G Y R N O O 0 X 3 - { 0 S S + N A 8 B B C 0 C 0 0 0 K 3 5 7 C J J 3 + + N 4 R C { N ] O . - N D 7 E F G H U O 0 0 ( N N N T U J N C 0 ] 8 } J C \ / ? O R N 4 I J K L M Y S 0 3 0 ) 5 0 0 0 L F U A - ^ N T U < 7 N N V N N N J O P Q J C R # ( ) - 0 0 A N 0 0 R B 0 + N 0 \ / > N 7 N N N J C R S L U # A ^ X 3 0 B 0 7 A 0 D N [ ( 4 X N N ~ " 5 N N N T U ] W W X ^ Z @ ! Z ! * 3 [ ] O O N N N N N N N N 5 N N

Images are stored - in 8 x 8 art format which recalls which specific palette to draw from (recall 2 pages ago if you're still unclear). I also spoke about how the genesis, and Sonic the hedgehog, uses these base 8x8 tiles to form bigger objects. Now I'll talk about how levels are stored and created as a whole.The first thing to understand about how sonic the hedgehog works is that what you see, and what you're interacting with, are two very different creatures. I'll explain a bit later when I talk about the actual game physics, but for now, just remember that we're talking strictly about the level as you see it.First up, lets take a look at a sample level... we'll be using Metallic Madness act 2 present from sonic CD to explain how levels are stored. Behold the level in it's full glory:I chose to use this level on purpose because it's one of the most confusing in all of Sonic CD. It's level design is frantic and very sprawling, with no two areas looking the same. Each part of the level looks very distinct and random.If there is one thing I've learned from studying the way the sonic engine works, it's that Sonic the Hedgehog, as a whole, is not nearly as frantic, confusing, or hectic as it seems. The entire engine is hyper organized, and if you look hard enough, patterns will form. Case in point, if I simply add a grid to the above image, a sort of patter appears...Amazingly, the level is stored in an array using repeating, pre-created 64x64 tiles. I've gone through the above image and organized the tiles and labeled them...and there you have it. From the 61 tiles you see above, the entire level is created. You can accurately represent the level, in fact, as so:So, let's step back a bit. Below is a 64x64 tile taken from Hydrocity Zone, Sonic 3, that has been blown up two times it's original size:Like I explained before, this 64 x 64 tile is made up of several 8 x 8 tiles, as shown below:I've already talked about how these 8 x 8 basic tiles are stored (refer to 2 pages ago if you're unclear), but now we see how these larger 64 x 64 tiles are stored - they're made up of arranged 8 x 8 tiles in a similar fashion to the way 8 x 8 tiles are stored. Where as 8 x 8 tiles were made up of character representations of numbers corresponding to palette entries, these larger 64 x 64 tiles are made up of character representations of 8 x 8 tiles. Take, for example, the 8 x 8 tile that makes up the first square in the 64 x 64 tile. That tile is saved as a grid of palette entries, and then labelled as something, say '1' to keep things clear. Th 8 x 8 tile next to it is stored as 2, and so forth.We see, then, that the 64 x 64 tile can be represented as an 8 x 8 grid, where the top left quadrant storing '1', the one next to it stores '2', and so forth.Once we've selected the 8 x 8 tiles which make up the art for the 64 x 64 tile, we can then save the 64 x 64 tile as a single level art object, which I call LAOs. LAOs get saved and assigned a label (similar to the labels I gave above).These LAOs can then be arranged in a grid to make up the level by repeating the same process. You can store a level by simply creating a grid of LAO labels. I'll explain in full how these get drawn to the screen later.As you should have noticed, the entire system is just a repeated process where you take a small element, arrange them in a grid, save that grid as an object, then use that object as the element for the next object you'll create.Sonic the hedgehog is one of the most impressive games ever released. At surface value, it looks like a mario game, but when you begin to examine the game engine, it is one of the most complex game engines created. While Yuji Naka is a terrible producer and designer, he coded one hell of a game engine. Sit back for a moment and just look at the physics of sonic the hedgehog. There is a lot in sonic the hedgehog's engine that really goes over looked.For example, in Mario World, mario always jumps vertically. This is because of how mario's jump routine works. They simply decrease his vertical velocity. Go onto a hill, and jump, and you'll jump straight up.Sonic's jump routine was far more complex. Sonic jumps perpendicular to whatever piece of ground he's standing on. While this in it's own is pretty impressive, what's more impressive is how the game FINDS the perpendicular ground. It actually reads the angle of the ground you're walking on DEPENDING ON THE IMAGE OF THE GROUND and puts you perpendicular to that angle. Go onto a hill in sonic, and jump, and you'll jump backwards and up.A good example to demonstrate how complex and neat this is... load up sonic 1. Stand still, don't press left or right, and jump... you'll jump forward a little. When you land, jump again, and you'll jump backwards. You can actually move quite a bit into the level just by jumping. The game is actually reading all those little hills in the ground. They aren't just for decoration.And this is just from the jump routine. Those hills actually affect your speed, velocity, and weight. Sonic has weight in sonic 1, which is why he speeds up when you roll down a hill.Really amazing engine.Someone asked "So you're telling me the engine can determine the slope of the ground just by looking at the ground's image file?", which I said:Yes.The engine actually constantly has a pointer infront of sonic and at the center of sonic at all times. The engine uses a standard pixel-perfect collision routine to determine when the pixels first intersect. It then determines the angle sonic is based taking the arc tangent of the pointer he's currently on over the pointer 1 pixel in front of him.Now, this is a little misleading. The game doesn't actually determine by the art, they determine by the solidity chart of each tile. Let me show a couple of screenshots of SonED, a development tools used to make sonic the hedgehog to explain how it works:As you can see, the editor lets you assign 8x8 tiles over a big block of land. This is the art side of the editor.Below the art, however, the editor lets you choose solidity, which looks like this:What you're looking at is solidity charts. These are essentially binary blocks of 8x8. For every 8x8 block, you assign one of these charts to it. This tells the game engine what parts of each image are solid, and what parts are not. This is why sonic doesn't run jagged over ground with blades of grass showing - the blades aren't solid, it has a flat solidity chart.Thus, we meet infinite scrolling. Sonic's engine has the unique ability to allow you to warp from the top of the level to the bottom of the level, sort of like how you could move from the right side of the screen in Mario Bros and end up in the left side of the screen. Using creative level design, they could then fool you into thinkin the level was really tall.So, if we enable infinite scrolling, and move past a certain point on this column, we get to this:That's right, the column continues at the bottom of the level. Since it's moving at an angle, you eventually move over enough so that it doesn't overlap. the end result is sorta like this:I just posted a picture of the ascii, too much work. the ___ and the / are supposed to be ground pieces, the periods are air.}you see? the tube looks longer than it is because it wraps around. What would have happened is we would have (in the final version) hit a trigger to turn off water in the game. That's how Labrynth Zone wraps - if you notice, at points in the game, the water goes down for no reason, then rises back up. It's a trick to make you think you're still going up. When you reach a point, the water goes down below the screen, then turns off. Then, when you get up high enough, they turn it back on and have it raise again to meet you.Truly excellent games. Most people don't even realize how well made of a platformer they are.