Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@codetravis
Created December 9, 2016 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codetravis/a1a1bad1e25b36fd7d5767c8c8f78b29 to your computer and use it in GitHub Desktop.
Save codetravis/a1a1bad1e25b36fd7d5767c8c8f78b29 to your computer and use it in GitHub Desktop.
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