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 — first changes to the OnCreate method

Inside the OnCreate method, we want to determine the canvas size and load the sprite sheet and the game font. This is done as follows:

  1. Set the virtual canvas size to 800 by 600 pixels, as the background image is of the exact same size.
    Method OnCreate:Int()
    SetUpdateRate(60)
    eng = New engine
    eng.SetCanvasSize(800,600)
    
  2. Determine the canvas size and store the values in the fields we just created in the preceding section. You code set them with hard values, but this approach makes them more modular.
    ch = eng.canvasHeight
    cw = eng.canvasWidth
    
  3. Now, load the sprite sheet and store the reference in the atlas field.
    atlas = LoadImage("ad_Tiles.png")
    
  4. And lastly, load the bitmap font.
    font1 = eng.LoadFont("ad_font") ...

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