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 — the ActivateShield method

  1. The new method will be called ActivateShield.
    Method ActivateShield:Int()
    

    The shield object is already created, so we just want to make it active. As we want it to be deactivated after 5 seconds, we need to create a timer to do this.

  2. Create a new object timer. The parameters are the shield object, the timer ID tmShieldTime, and when it should fire (in 5000 milliseconds).
    eng.CreateObjTimer(g.shield, g.tmShieldTime, 5000)
    
  3. While the shield is active, the player ship should not take any collisions.
    g.player.SetColGroup(0)
    
  4. Set the shield to active and close the method.
    g.shield.SetActive(True)
    Return 0
    End
    

What just happened?

The last method you have created will activate the shield of the player ship and create ...

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