Last active
December 23, 2016 22:19
-
-
Save codetravis/3e0d37abb16c0061839fdc4c8431c4da to your computer and use it in GitHub Desktop.
8.15 remove destroyed projectiles from the game
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
' Game Class | |
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()) | |
If (KeyDown(KEY_SPACE) And player.FireProjectile()) | |
CreateProjectile(player) | |
End | |
' Remove destroyed projectiles from our game | |
' and call projectiles update method | |
For Local projectile:Projectile = Eachin Self.projectiles | |
projectile.Update() | |
If (projectile.box.GetText() = "DESTROYED") | |
projectile.box.Remove() | |
Self.projectiles.RemoveFirst(projectile) | |
End | |
End | |
For Local enemy:Character = Eachin Self.enemies | |
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