
上QQ阅读APP看书,第一时间看更新
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.
- Add a
Select
statement to theOnUpdate
method.Method OnUpdate:Int() Select gameMode
- Depending on whether
gameMode
isgmMenu
orgmOver
, we will call a new methodUpdateMenu
.Case gmMenu, gmGameOver UpdateMenu()
- When
gameMode
is equal togmPlay
, call another new method calledUpdateGame
.Case gmPlay UpdateGame()
- Close the
Select
statement.End End
- Now, add the bodies of the formerly mentioned methods,
UpdateMenu
andUpdateGame
. InsideUpdateMenu
, 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