The last thing to add is the need to act to the game modes. We have three modes:
0=Start of game
1=Gameplay
2=GameOver
We want to direct and inform the player about what mode the game is in and how they can start it. Then if the victory conditions are achieved, we want to give a visual response.
1. The first mode is bound to a new method that we will create now. Create a new method called
StartGame
.Method StartGame:Int()
2. We want to print a message only once; that is why we need the field
modeMessage
. If it is0
, then we can print this message. If we don't use such an approach, the message will be printed every time we call this method.If modeMEssage = 0 Then
3. Now set
messageMode
to1
and print a message:modeMessage = 1 Print ("Press P to start the game") Endif
4. In this method, we will also check if the
P
key was hit and setmessageMode
andgameMode
accordingly.If KeyHit(KEY_P) Then modeMessage = 0 gameMode = 1 'mode = Game playing...