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 — detailing the OnRender method

We won't change the OnRender method in the game class. We will only change the background color and set the text of the FPS indicator to see how fast our game renders everything:

  1. Add the optional parameters to the CLS statement, which defines a nice orange color background.
    Method OnRender:Int()
    Cls (255,155,0)
    
  2. Then, set the text property of our txtFPS object with the current FPS value.
    txtFPS.SetText("FPS: "+eng.GetFPS())
    eng.Render()
    Return 0
    End
    

What just happened?

The OnRender method is done. We determine the current FPS value inside it, as Monkey is skipping rendering frames if OnUpdate is taking to long. Only here will you get the true FPS value in its traditional meaning.

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