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 — creating the bomb class

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, import gameClasses, and create a global list that holds all instances of the bomb 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 ...

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