Last active
December 16, 2016 23:35
-
-
Save codetravis/4ab5e5ca92f51dde61f6ca0873c65e1b to your computer and use it in GitHub Desktop.
8.5 Add a call to enemy Update methods in the Games OnUpdate method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Method OnUpdate() | |
Local time_delta:Float = Float(engine.CalcDeltaTime())/60.0 | |
If ((Millisecs() - Self.last_enemy_time) > Self.next_enemy_interval) | |
CreateEnemy() | |
Self.last_enemy_time = Millisecs() | |
End | |
player.Update(engine.GetCanvasWidth(), engine.GetCanvasHeight()) | |
For Local enemy:Character = Eachin Self.enemies | |
' Add an update to all of our enemies so we can check for damage | |
enemy.Update(engine.GetCanvasWidth(), engine.GetCanvasHeight()) | |
If (enemy.box.GetText() = "DESTROYED") | |
enemy.box.Remove() | |
Self.enemies.RemoveFirst(enemy) | |
End | |
End | |
If engine.GetPaused() = False | |
engine.Update(time_delta) | |
engine.CollisionCheck() | |
End | |
End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment