Game Development Reference
In-Depth Information
Parallax Universe
Parallax scrolling can help to add depth to the look of a 2D platform game by making the
background appear to move at a slightly slower rate from the foreground. You can use multiple
layers of parallax backgrounds to represent objects from the near to far distance to amplify the 3D
effect. Some versions of the original Zool game applied this technique, so we're going to add it to
ours next. The spr_clouds sprite ( Misc group) contains seven images that are designed to
represent background objects from the near distance to the horizon (see Figure 6-7). Notice that
each of these is designed to be repeated horizontally, so the right side of the first image has a
small piece of the purple blob from the left side of the image. They are also all 512 pixels wide,
which is the width of our screen view into the room, and all but the first image is 32 pixels high.
When you normally assign a background to a room, it automatically appears to move as the
view scrolls around the screen, but of course it is actually the view that is moving and the
background is staying still. Parallax backgrounds are more complicated, as the backgrounds
themselves need to move relative to the view position, and the amount they should move is
different depending on how far away each background layer is supposed to be. This mimics the
real world, where if you are walking along on a hilltop path looking at a town in the distance, then
the position of that town appears to remain fairly static while nearby objects along the path seem
to move by much more quickly.
To keep the work Game Maker has to do to a minimum, we're only going draw the clouds
around the view itself (see Figure 6-8) and adjust their position as the view moves around the
level. This may sound tricky, but it can be done using just one object.
Figure 6-7. The parallax scrolling background sprite and its subimages
 
Search WWH ::




Custom Search