Chapter 12. A Side-Scroller
The player’s sprite in a side-scrolling game usually travels left or right through a landscape that extends well beyond the limits of the gaming pane. The landscape scrolls past in the background while the player jumps (or perhaps flies) over various obstacles and bad guys, landing safely on platforms to collect treasure, food, or rescue Princess Peach. Of course, the quintessential side-scroller is Super Mario Bros., still available today in many versions on many platforms.
Most side-scrollers implement their backgrounds using tile maps: the tiles can be square, rectangular, or any shape once transparent GIFs are brought in. Tiles can be unchanging blocks, animated, or they can behave like (clever) sprites.
Backgrounds are often composed of several tile map layers, representing various background and foreground details. They may employ parallax scrolling, in which layers “further back” in the scene scroll past at a slower rate than layers nearer the front.
Tiling is a versatile technique: Super Mario (and its numerous relatives) present a side view of the game world, but tiles can offer bird’s eye viewpoints looking down on the scene from above and can offer isometric views, as in Civilization, to create a pseudo-3D environment. You’ll see how to implement a basic isometric game in Chapter 13.
This chapter describes
JumpingJack, a side-scroller in the Super Mario mold—albeit considerably simpler—that illustrates tile maps, layers, parallax scrolling, ...