Last active
December 23, 2016 22:20
-
-
Save codetravis/34a44962eca229a666e3a65a6fc168a5 to your computer and use it in GitHub Desktop.
8.18 Increase the player's score when they destroy an enemy
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 | |
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") | |
' If the player destroyed the enemy, increase the score | |
If (enemy.current_health <= 0) | |
Self.player.IncreaseScore(enemy.point_value) | |
End | |
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