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:
CreateClouds
into the game
class.Method CreateClouds:Int()
Local obj:ftObject
shape
variable of the type FLOAT.Local shape:Float
eng.SetDefaultLayer(layerClouds)
1
to 10
.For Local i:Int = 1 To 10
0
to 100
.shape = Rnd(100.0)
shape
is less or equal to 20
. If yes, then load one cloud shape from the sprite atlas. Place it randomly on the canvas.If shape <= 20.0 Then obj = eng.CreateImage(atlas,128,0,64,64,Rnd(10,cw-10),Rnd(10,ch-10))
shape
is greater than 20
and less than or equal to 70
, then load the second cloud shape.Elseif shape > 20.0 And shape <= 70.0 Then obj = eng.CreateImage(atlas,192,0,64,64,Rnd(10,cw-10),Rnd(10,ch-10))
shape
is greater than 70
, load the last cloud sprite shape.Else obj = eng.CreateImage(atlas,0,64,128,128,Rnd(10,cw-10),Rnd(10,ch-10)) Endif
obj.SetSpeed(Rnd(0.2,2),Rnd(360)) obj.SetAngle(Rnd(360))
obj.SetWrapScreen(True)
Next Return 0 End
The CreateClouds
method will add 10
clouds on the canvas in a random fashion. It will determine the shape to use randomly.
To make this method more general, you could add a parameter to the method head, which determines the amount of clouds to be created. But for now, we will go by this fixed amount we have chosen.