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 — 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 ...

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