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 — determine the time delta

  1. Add a new method call, UpdateGametime.
    Method UpdateGameTime:Int()
    
  2. Store the difference between the current Millisecs value and the global variable lastTime into deltaTime.
    deltaTime = Millisecs() - lastTime
    
  3. Add the delta to the time of the last call.
    lastTime += deltaTime
    
  4. Return the deltaTime and close the method.
    Return deltaTime
    End
    

What just happened?

This is a simple method which determines the time in milliseconds since its last call. The delta time can be used to factor speed values or other factors that are time dependent.

Updating the game statistic info text objects

In each frame, we want to update the text objects that will display our most important game fields, such as score, lifes, levelNumber ...

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