Time for action — changing the gameClasses file

The first thing you need to do is add a new object to the gameClasses.monkey file.

  1. Open the gameClasses.monkey file.
  2. Add an Import statement for the cityClass.monkey file.
    Import mainClass
    Import cityClass
    
  3. Save the file and close it.

What just happened?

We have added an Import statement for our new cityClass.monkey file to the gameClasses.monkey file. As we only import gameClasses.monkey in all of our scripts, the new class will be automatically visible in them, and so will all the other objects we create later on too.

Modifying the RocketCommander class

Ok, now comes the actual fun part. First, we want to to create some cities in our game. For this, we have created the CreateCity function. To set up the game objects at the beginning of a game, inside the RocketCommander class, there is a method called SetupGame. So, let's modify it.

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

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