O'Reilly logo

Monkey Game Development by Michael Hartlef

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — modifying the UpdateGame method

To modify the UpdateGame method, we will follow the ensuing steps:

  1. We need to modify the UpdateGame method in the mainClass.monkey file.
    Method UpdateGame:Int()
    
  2. Check if a random number is equal to 100 and the current active bombs are not more than the level number.
    If Rnd(0,100) > 99 And (GetBombsCount() < levelNumber) Then
    
  3. Create a new bomb.
    CreateBomb()
    Endif
    UpdateLaunchers()
    UpdateBombs()
    UpdateRockets()
    UpdateExplosions()
    
  4. If no city is left, remove all rockets, bombs, and explosions, and set the game mode to gmGameOver.
    If GetCityCount() = 0 Then
    RemoveRockets()
    RemoveBombs()
    RemoveExplosions()
    gameMode = gmGameOver
    Endif
    
  5. Check if the next level is reached by comparing levelNumber times 10 with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required