Game Development Reference
In-Depth Information
Only if the player is allowed to move do we update the nextX and nextY values for the player.
Note that if the player is not near the edge of the screen, the nextX and nextY values will always
be the same as the x and y values for the player. This is because we want the player to remain in
the center of the screen unless it is in a column or row that forces the scrolling to stop.
The sound for the player car is played based on the delay value from an array. We populated this
array earlier:
private var carSoundDelayList:Array = [90,80,70,60,50,40,20,10,0];
The delay is pulled from this array based on the player velocity. This is similar to how we do the
animationDelay for the wheels, but since we needed larger numbers and wanted to test each, we
used an array look up table.
Testing iteration 4
When you build or test this movie, you should see the level screen fade out and the player car
sitting in its starting spot. You will need to click the screen with the mouse before you can control
the car with the keys. You can scroll all over the world without any collision detection. Figure 10-
11 shows iteration 4.
Figure 10-11. Iteration 4 in action—there is no collision detection yet, so drive on the walls!
Search WWH ::




Custom Search