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 — create a comet

  1. To create a comet, we need a new method called CreateComet. The parameters are the kind of comet, its position, the travel speed, and angle.
    Method CreateComet:ftObject(k:Int, xp:Float, yp:Float, speed:Float, speedAngle:Float)
    
  2. Define a local ftObject called com.
    Local com:ftObject
    
  3. Depending on the size of the comet, create the comet object from different locations of the sprite atlas. Also, set the radius depending on the size.
    If k = cmSmall Then
    com = eng.CreateImage(atlas, 0,32,16,16, xp, yp)
    com.SetRadius(4)
    Endif
    If k = cmMiddle Then
    com = eng.CreateImage(atlas, 32,0,32,32, xp, yp)
    com.SetRadius(12)
    Endif
    If k = cmLarge Then
    com = eng.CreateImage(atlas, 64,0,64,64, xp, yp)
    com.SetRadius(24)
    Endif
    
  4. Now, set the ...

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