Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@codetravis
Created December 16, 2016 23:04
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/7f30756280fdc20aff4c84e2ce9e0b68 to your computer and use it in GitHub Desktop.
Save codetravis/7f30756280fdc20aff4c84e2ce9e0b68 to your computer and use it in GitHub Desktop.
8.3 Modify OnObjectCollision in our custom engine to damage characters instead of destroying them
Import fantomX
Class CustomEngine Extends ftEngine
Method OnObjectCollision:Int(obj_one:ftObject, obj_two:ftObject)
If (obj_one.GetText() = "PLAYER" And obj_two.GetText() = "ENEMY")
' Change the text to be damaged and set it for both the player and the enemy
' this way players and enemies will only get damaged once per update
obj_two.SetText("DAMAGED")
obj_one.SetText("DAMAGED")
obj_two.SetColWith(obj_one.GetColGroup(), False)
Else If (obj_two.GetText() = "PLAYER" And obj_one.GetText() = "ENEMY")
obj_one.SetText("DAMAGED")
obj_two.SetText("DAMAGED")
obj_one.SetColWith(obj_two.GetColGroup(), False)
End
Return 0
End
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment