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 the timer that will deactivate the shield when it fires.

Delta time related movement

If you want to have your objects move at the same speed no matter how fast the computer that the game is running on is, then you need to measure the time it will spend between each OnUpdate call.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.105.137