O'Reilly logo

Monkey Game Development by Michael Hartlef

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 for action — updating the text info

We will build the functionality to update text info into a method that will update not only the time left, but also the game's score value.

  1. Add a new method called UpdateInfoText in the game class.
    Method UpdateInfoText:Int()
    
  2. Set the text property of txtScore with the score value.
    txtScore.SetText(score)
    
  3. Calculate the number of seconds left by subtracting the current millisecond value from the end time, after adding 750 (to make it more accurate), and then dividing everything by 1000, to get seconds.
    seconds = (endTime-Millisecs()+750)/1000
    
  4. Determine the number of minutes left using the value of seconds.
    minutes = seconds/60
    
  5. Subtract the result of minutes times 60 to get the seconds left.
    seconds -= (minutes*60) ...

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