Game Development Reference
In-Depth Information
Scrolling
In a relatively simple 2D game such as
Pac-Man
or
Tetris
, everything fits on one
single screen. More complex 2D games, however, often have worlds that are lar-
ger than what can be displayed on a single screen. For these games, a common
approach is to have the level scroll as the player moves across it. In this section,
we cover progressively more complex types of scrolling.
Single-Axis Scrolling
In
single-axis scrolling
, the game scrolls only in the x or y direction. Infinite
scrollergamessuchas
Jetpack Joyride
,shownin
Figure2.6
,oftenfeaturethistype
of scrolling. How this is implemented depends on how large the levels are. For
games where all the background images can be loaded into memory at once, as we
will assume in this section, the algorithms are not too complex.
Figure 2.6
Single direction scrolling in
Jetpack Joyride
. The dotted line demon-
strates a boundary.
The easiest approach is to split up the background of the level into screen-sized
image segments. That's because a level may be 20 or 30 screens-sized segments,