O'Reilly logo

3D Game Programming for Teens, Second Edition by Eric Grebler, Maneesh Sethi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time Remaining

As discussed earlier in this chapter, the game will end when one of two things happen: either all the gallery items have been destroyed or three minutes have elapsed. In order to time the game, we need to create two timers—one outside the game loop that will start the timer and one inside the game loop that will indicate the current time in the game. When we subtract the current time from the start time, we’ll end up with how much time has elapsed. Start by creating a variable called starttime just before the game loop:

;Defining the starting time of the game
starttime=MilliSecs()
;The following code makes our program run
While Not KeyDown(ESC_KEY)

Now we’ll create two more variables within the game loop: one called currenttime ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required