Time for action — modifying the menu update process

  1. Head to the UpdateMenu method and add the following lines:
    If gameMode = gmMenu
    'we will add code here later
    
  2. Check if the P key was hit.
    If KeyHit(KEY_P) Then
    
  3. 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
    
  4. Check if the R key is hit after one game is over.
    If KeyHit(KEY_R) Then
    
  5. Remove all cities and rocket launchers.
    RemoveCities()
    RemoveLaunchers()
    
  6. Set up the game again, and set the game mode to gmPlay.
    SetupGame()
    gameMode = gmPlay
    Endif
    Endif
    Return True
    End
    

What just happened?

Good, now we can leave this part of code and forget about it. We can start the game now or restart it.

Rendering our precious rocket launchers

Just like the cities, we want to see our launchers in the game. That is why we need to enhance the RenderGame method.

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

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