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 — modifying the rocket class

To modify the rocket class, we will follow the ensuing steps:

  1. Open the rocketClass.monkey file.
  2. Modify the Update method and add a CreateExplosion call there. The parameters are the current X and Y positions of the rocket.
    If cy < ty Then
    CreateExplosion(Self.cx, Selfish)
    rockets.Remove(Self)
    Endif
    
  3. Save the file.

What just happened?

We have modified the rocket class to create a new explosion once the rocket reaches its target position.

Updating the explosions

An explosion will grow in size over time, before it disappears. For this, we have created a function called UpdateExplosions.

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