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 — building some cities

For each of the objects in RocketCommander, we will build an individual class, in its own file. So, let's just do that.

  1. Create a new empty script and save it under the name cityClass.monkey.
  2. Add the usual Strict statement to it and import our gameClasses.monkey file.
    Strict
    Import gameClasses
    
  3. Create a global list that stores all instances of the city class.
    Global cities := New List<city>
    

    Besides the methods of an object, we will create some functions that we can use from within the mainClass file; for example, a function to render all the cities in one batch. These helper functions are wrappers for code, which we could have stored inside the mainClass.monkey file. But, we want to keep things nice and neat. ...

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