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

Text

We need to add three different text elements to the screen: the score, the time remaining, and the bullets remaining. Since we already have variables created for all three, we’ll just have to add a line of code to display each of them. Notice how we divide the timeleft variable by 1000 so that the player will see the time remaining in seconds. We’ll also add a line of text to appear when the player has run out of bullets. Add the following code in bold:

Text 100,10,"Score: " +score#,True,False
Text 400,10,"Bullets Remaining: "+bulletcount
Text 800,10,"Time Remaining: "+TimeLeft /1000
If reload=1 Then Text GraphicsWidth()/2, GraphicsHeight()/2,"Press R to
Reload",1,1
Flip
Wend
End

Run the game now, fire 100 bullets, and you should see text ...

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