Game Development Reference
In-Depth Information
graphics.beginBitmapFill(pd);
graphics.drawRect(0, 0, bmd.width, bmd.height);
graphics.endFill();
}
The racetrack module
The racetrack is where we race the ship. Along the way, the player must dodge the
asteroids in order to retain the current speed or pick up an item that may increase the
ship's maximum speed. The racetrack could be quite long and loading these items all
at once may be too much for the Flash Player. For this reason, we cut the entire track
into different quadrants.
Mapping coordinates
We will introduce the universe coordinates for the ship mainly along the x-axis. This
has nothing to do with the actual rendering of a ship on-screen, but with this, we
keep track of the ship's position relative to the entire racetrack.
In this implementation, the universe coordinates start from zero and go up to the
racetrack length. The racetrack length is equal to the number of quadrants times
the length of each quadrant.
Loading quadrants
In this implementation, we have 10 quadrants and each is of length 1,600. Each
quadrant gets loaded as it approaches it. At any given time, there are two quadrants
loaded—the ship currently in and the subsequent one.
 
Search WWH ::




Custom Search