Skip to content
Snippets Groups Projects
Commit 1b847ae8 authored by STAVRIDIS ADONIS's avatar STAVRIDIS ADONIS :speech_balloon:
Browse files

#116 prepare directional attacks

parent e2ecee36
Branches
Tags
No related merge requests found
...@@ -126,9 +126,11 @@ func _physics_process(delta:float): ...@@ -126,9 +126,11 @@ func _physics_process(delta:float):
# Called from the game script to update the vars # Called from the game script to update the vars
func getPlayerInputs(movementInput:int, jumpId:int, attackTypeInput:int, mouseX:int, mouseY:int): func getPlayerInputs(movementInput:int, jumpId:int, attackTypeInput:int,
mouseX:int, mouseY:int):
# Prevent the player from moving when attacking # Prevent the player from moving when attacking
if isAttacking: if isAttacking:
motion = 0
return return
motion = movementInput motion = movementInput
...@@ -141,18 +143,19 @@ func getPlayerInputs(movementInput:int, jumpId:int, attackTypeInput:int, mouseX: ...@@ -141,18 +143,19 @@ func getPlayerInputs(movementInput:int, jumpId:int, attackTypeInput:int, mouseX:
# Execute attack # Execute attack
if attackTypeInput != NONE: if attackTypeInput != NONE:
attackDirection = MOUSE_UP attackDirection = MOUSE_UP
if (!self.is_on_floor() && mouseY < 0 && mouseX < mouseY && mouseX > -mouseY): if (mouseX < 0 && mouseX <= mouseY):
attackDirection = MOUSE_DOWN
elif (mouseX < 0 && mouseX <= mouseY):
attackDirection = MOUSE_LEFT attackDirection = MOUSE_LEFT
bodyRotation = -1 bodyRotation = -1
set_rotation_degrees(Vector3(0, 180, 0)) set_rotation_degrees(Vector3(0, 180, 0))
broadcastTurn(bodyRotation) broadcastTurn(bodyRotation)
elif (mouseX > 0 && mouseX >= -mouseY): elif (mouseX >= 0 && mouseX >= -mouseY):
attackDirection = MOUSE_RIGHT attackDirection = MOUSE_RIGHT
bodyRotation = 1 bodyRotation = 1
set_rotation_degrees(Vector3(0, 0, 0)) set_rotation_degrees(Vector3(0, 0, 0))
broadcastTurn(bodyRotation) broadcastTurn(bodyRotation)
if (!self.is_on_floor() && mouseY > 0 && mouseX < mouseY && mouseX > -mouseY):
attackDirection = MOUSE_DOWN
print(attackDirection)
processAttack(attackTypeInput) processAttack(attackTypeInput)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment