Post #4840 · Sat 120616 044428
2D games have two common types of level format:
Object based: Used in most platformers, including Super Mario Bros 1-3 and SMW. In memory, the level is a grid of (usually 16x16) tiles. When loading a level, the grid is cleared to an "empty" tile, then objects are "drawn" into it. The data specifies e.g. "3x1 block of coins at position 12,34", "16x3 floor at position 0,28", etc.
Usually the grid is divided into 16x16 "screens" or "pages", and object coordinates are local to a page, with a special object ID signalling to move to the next page.
Object format is typically something like
TT XY WH, with object type 0 or FF signalling the end of the list, potentially some additional parameter bytes, and some special "pseudo-object" types which don't draw objects at all, but use their position/size values to set parameters such as warps. (Lunar Magic uses such pseudo-objects to do all sorts of interesting things such as load ExGFX and override time limits and starting positions.)
In SMW, object type 0 is a special type, used for most fixed-size objects; in place of the size byte is the "real" object type. (i.e. 00 XY TT) In some games, certain objects just don't have a size byte at all.
Super Mario Bros 2 has a couple of interesting variations: you can specify what tile to fill the grid with (so a cave might be filled with rock tiles and then carved out with "air" objects, rather than built from "rock" objects around an empty space) and object positions are relative to eachother.
Tile based: Simpler, but generally less efficient for games with large maps. The grid is simply stored in ROM and copied directly into RAM. Usually compressed in some manner. Used in most top-down games, such as Pokémon.
3D games are another
can barrel of worms entirely, and much more complex. You'll want to learn about OpenGL and be capable of programming a simple 3D scene before you look at those...

____________________