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 — creating a StartNewGame method

This method will do various things, from cleaning up the layers to initializing the tile map to setting the end time.

  1. Start a new method called StartNewGame, inside the game class.
    Method StartNewGame:Int()
    
  2. Define a local tile variable with the type INT.
    Local tile:Int = 0
    
  3. Seed the random number generator with the current value of Millisecs and set the game score to 0.
    Seed = Millisecs()
    score = 0
    
  4. Set the game mode to gmPlay and activate layers with it.
    gameMode = gmPlay
    ActivateLayer(gameMode)
    
  5. To create the objects, set the default layer to layerGame and remove all objects form the game layer and the GFX layer.
    eng.SetDefaultLayer(layerGame) layerGame.RemoveAllObjects() layerGFX.RemoveAllObjects()  ...

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