Instantly share code, notes, and snippets.

Embed
What would you like to do?
7.8 Add engine object text tags and remove destroyed objects
' in OnCreate
box.SetColGroup(PLAYER_GROUP)
box.SetColType(Self.engine.ctBox)
' Player box text
box.SetText("PLAYER")
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())
' Loop through the enemies and remove any that have been destroyed
For Local enemy:Character = Eachin Self.enemies
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
' in CreateEnemy
box.SetColGroup(ENEMY_GROUP)
box.SetColWith(PLAYER_GROUP, True)
' Enemy box text
box.SetText("ENEMY")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment