The OnUpdate
method of the game
class is responsible for calculating the delta time since the last frame and updating the game, depending on which mode it is in.
1. Start a
Select
statement on the game mode.Method OnUpdate:Int() Local d:Float = Float(eng.CalcDeltaTime())/60.0 If isSuspended = False Then eng.Update(Float(d)) Select gameMode
2. Check for the constant
gmPlay
.Case gmPlay
3. Start a touch check on the game layer to determine which gems are selected.
If eng.TouchHit(0) Then eng.TouchCheck(layerGame) Endif
4. Check if there are no gems moving.
If layerGame.GetObjTransCount()= 0 Then
5. Fill up empty slots with new gems.
FillTiles()
6. Check if gems line up and clear them. Then, close the IF check.
ClearGems() Endif
7. If the N key is pressed, reset the grid calling
StartNewGame
.If KeyHit(KEY_N) Then StartNewGame()
8. If the Esc key is pressed, show the menu layer.
If KeyHit(KEY_ESCAPE) Then ShowMenu()
9. Update all the info text objects...