Time for action — creating some comets

  1. As always, inside the game class, create a new method called CreateComets. Its parameter will be the amount of comets that have to be created.
    Method SpawnComets:Int (ccount:Int)
    
  2. Add a FOR loop from 1 to the amount of comets you want to create.
    For Local i:Int = 1 To ccount
    
  3. Call up the method CreateComet with the size set to large, and random values for position, angle, and speed.
    obj = CreateComet(cmLarge,Rnd(64,eng.canvasWidth-64),Rnd(64,eng.canvasHeight-64),Rnd(1,4)/2,Rnd(0,359))/
    
  4. Close the FOR loop, and the method.
    Next
    Return 0
    End
    

What just happened?

To actually spawn comets, you have created a method that will do this randomly over the canvas area. You just tell how many comets you need and it will spawn them.

Mission complete... finalizing the OnCreate process

We have now created all the methods to create the initial objects. It is time to finalize the OnCreate method of the game class.

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

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