To modify the UpdateGame
method, we will follow the ensuing steps:
1. We need to modify the
UpdateGame
method in themainClass.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
times10
with the total number of destroyed bombs.If totalBombsDestroyed >= (levelNumber * 10) Then
6. Add
3000
points for each city left, and add5
new rockets to each launcher. Also, raise the level number.score += GetCityCount() * 3000...