Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
8.15 remove destroyed projectiles from the game
' 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