Create a gist now

Instantly share code, notes, and snippets.

Embed
11.4 Set collisions between player and projectiles with the final boss
Import fantomX
Class CustomEngine Extends ftEngine
' Add player and projectile collision to the final boss
Method OnObjectCollision:Int(obj_one:ftObject, obj_two:ftObject)
If (obj_one.GetText() = "PLAYER" And (obj_two.GetText() = "ENEMY" Or obj_two.GetText() = "FINALBOSS"))
CharacterCollision(obj_one, obj_two)
Else If (obj_two.GetText() = "PLAYER" And (obj_one.GetText() = "ENEMY" Or obj_one.GetText() = "FINALBOSS"))
CharacterCollision(obj_two, obj_one)
End
If (obj_one.GetText() = "PROJECTILE" And (obj_two.GetText() = "ENEMY" Or obj_two.GetText() = "FINALBOSS"))
ProjectileCollision(obj_one, obj_two)
Else If (obj_two.GetText() = "PROJECTILE" And (obj_one.GetText() = "ENEMY" Or obj_one.GetText() = "FINALBOSS"))
ProjectileCollision(obj_two, obj_one)
End
Return 0
End
Method ProjectileCollision(projectile_box:ftObject, enemy_box:ftObject)
projectile_box.SetText("DESTROYED")
enemy_box.SetText("DAMAGED")
projectile_box.SetColWith(enemy_box.GetColGroup(), False)
End
Method CharacterCollision(player_box:ftObject, enemy_box:ftObject)
player_box.SetText("DAMAGED")
enemy_box.SetText("DAMAGED")
enemy_box.SetColWith(player_box.GetColGroup(), False)
End
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment