Created
December 16, 2016 23:04
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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