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 ourgameClasses.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 themainClass.monkey
file. But, we want to keep things nice and neat. So let's create them here.The first wrapper function will be the one that renders all cities in one call on the canvas.
4. Create a new function called
RenderCities
.Function RenderCities:Int()
5. Now, loop through our list of cities...