Game Development Reference
In-Depth Information
player.animationDelay = 3 : The animation delay will adjust based on the
velocity of the car. It will be greater when the car is moving slower and smaller
when the car is moving faster.
player.velocity = 0 : With this, we're simply setting the velocity of the car to
start at 0.
5.
Next, we initialize the LookAheadPoint instances.
6.
We set the player to be invisible for the next step, which is the animation of the
Game.as screen onto the viewable area.
7.
We make sure to draw the current background to the screen so it will display when the
level animates onto the screen.
The systemGamePlay function
The full game loop for DriveSheSaid follows; it is associated with the STATE_SYSTEM_GAMEPLAY
state of the internal DriveSheSaid state machine:
private function systemGamePlay():void {
if (!countDownTimer.started) {
countDownTimer.start();
playerStarted= true;
player.visible = true;
}
if (playerStarted) {
checkInput();
}
update();
checkCollisions();
render();
checkforEndLevel();
checkforEndGame();
countDownTimer.update();
updateScoreBoard();
}
Here is a detailed description of the main points of this function:
1.
If the countDownTimer has not started yet, this run must be the first one through the
function for the game level. We set the player visible start the timer in this instance.
2.
Only if the player is started do we want to accept input.
3. We run through the rest of the game loop functions.
Testing game iteration 3
When you build or test the movie, you should see the level screen fade out and the player car
sitting in its starting spot, as shown in Figure 10-9. You will not see the level yet, because the
drawCamera function is currently a blank stub. We are going to add in the update / render loop in
iteration number 4 and then finish out the game in iteration 4.
Search WWH ::




Custom Search