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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.196.217