Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

3. Game #2, Rocket Commander > Time for action — displaying the game score

Time for action — displaying the game score

To display the game score, follow the ensuing steps:

  1. Modify the RenderGame method again.
    Method RenderGame:Int()
    'Render Ground
    SetColor(0, 0, 150)
    DrawRect(0, cHeight-40, cWidth, 40)
    
  2. Draw text for the level number and the score, in the middle of the canvas.
    SetColor(255, 255, 255)
    DrawText("Level: "+levelNumber, cWidth/2, cHeight-34, 0.5, 0.0)
    DrawText("Score: "+score, cWidth/2, cHeight - 20, 0.5, 0.0)
    RenderCities()
    RenderLaunchers()
    

What just happened?

You have added some code to display the level number and the score of the game.

If you run the game, the score and level output will look like the following image:

What just happened?

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint