Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
8.4 Modify Character class to handle taking damage
Class Character
' ........................
Method Update
' ......................
' Every update, check to see if the character was damaged
If (Self.box.GetText() = "DAMAGED")
Self.TakeDamage(1)
End
End
' Add a method that handles lowering character health
' and tags characters with 0 health as destroyed
Method TakeDamage(amount:Int=0)
Self.current_health -= amount
If (Self.current_health <= 0)
Self.box.SetText("DESTROYED")
Else If (Self.is_player)
Self.box.SetText("PLAYER")
Else
Self.box.SetText("ENEMY")
End
End
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment