To create the bomb
class, we will follow the ensuing steps:
1. Open an empty script and save it under the name
bombClass.monkey
.2. As always, switch into
Strict
mode, importgameClasses
, and create a global list that holds all instances of thebomb
class.Strict Import gameClasses Global bombs := New List<bomb>
For one last time, we will add a few wrapper functions, which we then can add to the
mainClass.monkey
file, later on.3. Add functions to create, update, render, remove, and count bombs.
Function UpdateBombs:Int() For Local bomb := Eachin bombs bomb.Update() Next Return True End Function RenderBombs:Int() For Local bomb := Eachin bombs bomb.Render() Next Return True End Function CreateBomb:Int() Local b:bomb = New bomb b.Init() bombs.AddLast(b) Return True End Function RemoveBombs:Int() bombs.Clear() Return True End Function GetBombsCount:Int() Return bombs.Count() End
Now, define the actual
bomb
class.4. Create a class called
bomb
.Class...