Time for action — acting of layer update events

A good place is the OnLayerUpdate callback method of the engine class. Check if one of the scores is 5 or bigger, and then set the game mode and also display a message.

  1. Check if the score field of the game class is 5 or greater.
    Method OnLayerUpdate:Int(layer:ftLayer)
    If g.score >= 5 Then
    
  2. If yes, the player won. Activate the g.txtYouWin text object.
    g.txtYouWin.SetActive(True)
    
  3. Set the game mode to g.gmGameOver and stop the engine sound effect.
    g.gameMode = g.gmGameOver
    g.sndEngine.Stop()
    
  4. If the player score is lower than 5, check if the computer score is greater or equal to 5.
    Elseif g.scoreC >= 5 Then
    
  5. If yes, the computer won. Display the You Lose message by activating the g.txtYouLoose object.
    g.txtYouLoose.SetActive(True)
    
  6. Set the game mode to g.gmGameOver.
    g.gameMode = g.gmGameOver
    
  7. Stop the engine sound effect. Then close the initial IF check.
    g.sndEngine.Stop()
    Endif
    Return 0
    End
    

What just happened?

That is it. Using this method, we have set the winning conditions and when you build the game, you will have a playable full game. Have fun!

What just happened?

Have a go hero — enhancing the game

Of course, this game can be enhanced. There is enough room for you to expand on. How about more than one enemy plane to fight with? How about different planes to choose from? How about enhancing the artificial intelligence of the enemy planes? Maybe the player plane can hide inside the clouds, and if he is covered by the clouds, the enemy plane will not turn towards the player. Or making the turn more random? Maybe you can let the enemy sometimes turn in the other direction instead of towards the player.

You see, there is enough room for expansion. Have fun and experiment with it. That is the most important thing in game development.

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

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