Game Development Reference
In-Depth Information
the top of the screen to make room for the UI elements like the
score, current level, and timer indicators.
The timer is also started at this point; when the timer runs out,
the game engine
s endLevel method is triggered to end the game.
However, if the level is completed before the timer runs out, the
levelComplete method that was passed into startLevel will be
called. This method calculates the player
much time they had left, increments the level counter, and saves
their progress. After that it redirects them to the results screen
that we
ll take a quick look at three
other classes used in the game: the Marble, the HazardPit, and
the StandardWall.
ll look at shortly. First, we
The IBall interface we examined earlier requires very little more
than a simple DisplayObject in order to serve the purposes of the
game engine. However, as this is the player
it makes
will have a texture applied to it and appear to be three dimensional
as the texture will move in accordance with the ball
s movement.
This is accomplished by clever use of a mask and radial gradient. If
you open the Marble symbol from the XFL library, you
ll see sev-
eral layers. Figure 15.11A illustrates how the first two layers are
made up of a texture and a circular mask. Figure 15.11B shows the
gradient effect that will be laid over the masked texture to give it
lighting and a three-dimensional look. Finally, Fig. 15.11C repre-
sents the final composited effect.
In reality, the texture would bend around the edges of the ball a
little, an effect that could be created with a DisplacementMapFilter
or a PixelBender Shader. However, because it is so small, this effect
is entirely convincing for a moving ball and much less costly on the
CPU. Next, we
ll look at how we should use code to move the tex-
ture underneath the mask.
The texture we
of its current
size. It is a seamless texture that is tiled into four quadrants, as shown in
Fig. 15.12 .Thereasonwequadrupletheimagedataissothatasthetex-
ture moves it will need to be repositioned to maintain the illusion of an
infinitely wrapping surface. If we were using higher resolution textures, or
many more than lone image in question, the quadrupling could be done
inside Flash by making multiple instances of the single tile.
re using for the marble actually started out
Figure 15.11 The top two
components blended together
(A, B) result in the convincing
marble ball in the bottom
image (C).
import com.flashgamebook.iphone.engines.labyrinth.IBall;
final public class Marble extends Sprite implements IBall
Search Nedrilad ::

Custom Search