Time for action — detailing the Update process

We have have three game modes. Two of them, gmMenu and gmGameOver, are modes where some kind of menu or text is displayed. The third mode, gmPlay, is for rendering and updating the actual game play.

  1. Add a Select statement to the OnUpdate method.
    Method OnUpdate:Int()
    Select gameMode
    
  2. Depending on whether gameMode is gmMenu or gmOver, we will call a new method UpdateMenu.
    Case gmMenu, gmGameOver
    UpdateMenu()
    
  3. When gameMode is equal to gmPlay, call another new method called UpdateGame.
    Case gmPlay
    UpdateGame()
    
  4. Close the Select statement.
    End
    End
    
  5. Now, add the bodies of the formerly mentioned methods, UpdateMenu and UpdateGame. Inside UpdateMenu, we will also add an IF statement to act differently, depending on the game mode.
    Method UpdateMenu:Int()
    If gameMode = gmMenu
    'we will add code here later
    Else
    'Code that runs when gameMode = gmGameOver
    Endif
    Return True
    End
    Method UpdateGame:Int()
    Return True
    End
    

What just happened?

As you can imagine, the preceding code is still far from being ready to run, as we have no objects so far. But once we add them, you will see the action easily. We have just laid out the logic for the Update process.

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

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