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.
score
field of the game class is 5
or greater.Method OnLayerUpdate:Int(layer:ftLayer) If g.score >= 5 Then
g.txtYouWin
text object.g.txtYouWin.SetActive(True)
g.gmGameOver
and stop the engine sound effect.g.gameMode = g.gmGameOver g.sndEngine.Stop()
5
, check if the computer score is greater or equal to 5
.Elseif g.scoreC >= 5 Then
g.txtYouLoose
object.g.txtYouLoose.SetActive(True)
g.gmGameOver
.g.gameMode = g.gmGameOver
g.sndEngine.Stop() Endif Return 0 End
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!
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.