
上QQ阅读APP看书,第一时间看更新
Time for action — modifying the menu update process
- Head to the
UpdateMenu
method and add the following lines:If gameMode = gmMenu 'we will add code here later
- Check if the P key was hit.
If KeyHit(KEY_P) Then
- Set game mode to
gmPlay
, and also seed the random number generator with the current time (in milliseconds) from when this game is active.gameMode = gmPlay 'Set random number generator Seed = Millisecs() Endif Else 'Code that runs when gameMode = gmGameOver
- Check if the R key is hit after one game is over.
If KeyHit(KEY_R) Then
- Remove all cities and rocket launchers.
RemoveCities() RemoveLaunchers()
- Set up the game again, and set the game mode to
gmPlay
.SetupGame() gameMode = gmPlay Endif Endif Return True End