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 the clouds

The clouds will come in different sizes and shapes. The shapes are chosen randomly from the sprite sheet by the method of creation, as follows:

  1. Insert the method CreateClouds into the game class.
    Method CreateClouds:Int()
    
  2. As we will be creating several clouds, create a local object variable.
    Local obj:ftObject
    
  3. To calculate the shape, add a local shape variable of the type FLOAT.
    Local shape:Float
    
  4. Set the cloud layer as the default layer; all new objects, from now on, will be assigned to it.
    eng.SetDefaultLayer(layerClouds)
    
  5. We want ten clouds. Start a FOR loop ranging from 1 to 10.
    For Local i:Int = 1 To 10
    
  6. To determine the cloud shape, we need a random number ranging from 0 to 100.
    shape = Rnd(100.0)
    
  7. Check if shape ...

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