Game Development Reference
In-Depth Information
2. Save the I]ej[?d]n]_pan*]o file and test the project.
3. Use the arrow keys to move the lh]uan object past the edges of the screen. Peek-a-boo! It
emerges from the opposite side.
After the detailed look at how to stop an object at the stage edges, I'm sure you can figure out what's
going on in this code already. It's almost exactly the same, except for being delightfully backward! It
uses the object's half-width and half-height to figure out whether the object has completely disap-
peared off the edge of the stage. As soon as it detects that this is the case, it positions the object
on the opposite side of the stage, just beyond the visible boundary. This creates the illusion that the
object is trapped on the surface of some kind of cylindrical, never-ending plane. I usually complain
about these sorts of things in this topic, but this time, it's a blast! Have fun with it! Screen wrapping is,
of course, a staple of many Old-Skool games like Pacman and Asteroids, and now you know how to
do it if you ever need to.
You can find the complete code for this screen wrapping example in the I]ej[O_naajSn]llejc*]o file
in the chapter's source files.
One thing that almost all 2D action and adventure games have in common is that most use an effect
called scrolling to allow a lh]uan to move about in an environment that is much bigger than the
confines of the stage. Like an ancient Chinese scroll being unrolled over a long wooden table, the
background moves to allow the character to explore the space beyond the stage edges.
Although it's hard to pick favorites, there's probably very little to learn about game design that isn't
in some way embodied in one or the other of the two greatest classic game series of all time: Super
Mario Bros. and The Legend of Zelda . Pretty much anything game designers need to consider about
good game design can be found in these two games, and scrolling is no exception.
Super Mario Bros. uses primarily what's known as horizontal side-scrolling . That's when the back-
ground moves left or right when the lh]uan reaches the left or right edges of the screen. The per-
spective in horizontal side-scrolling games is usually designed so that it looks as if you're viewing the
environment from the side. The Legend of Zelda uses overhead multi-axis scrolling . In overhead
scrolling, you view the environment from above, as if you were a bird flying in the sky and surveying
the scene below. With multi-axis scrolling, the lh]uan character is free to move in any direction (up,
down, left, or right), and the environment scrolls to keep up. Figure 6-11 illustrates the differences
between these two related systems.
In truth, most games that use scrolling use a combination of these two systems. In this chapter, you'll
look at the more complex of the two: multi-axis scrolling. Once you're comfortable with the scrolling
techniques covered here, you'll be able to implement any combination of these two systems.
Search Nedrilad ::

Custom Search