From 1b847ae847ee87b5797a4532aa6439f1b0d33ecc Mon Sep 17 00:00:00 2001 From: Adonis Stavridis <adonis-ioannis.stavridis@etu.unistra.fr> Date: Fri, 27 Mar 2020 19:30:15 +0100 Subject: [PATCH] #116 prepare directional attacks --- server/entities/characters/player.gd | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server/entities/characters/player.gd b/server/entities/characters/player.gd index fce0783..1228ada 100644 --- a/server/entities/characters/player.gd +++ b/server/entities/characters/player.gd @@ -126,9 +126,11 @@ func _physics_process(delta:float): # 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 if isAttacking: + motion = 0 return motion = movementInput @@ -141,18 +143,19 @@ func getPlayerInputs(movementInput:int, jumpId:int, attackTypeInput:int, mouseX: # Execute attack if attackTypeInput != NONE: attackDirection = MOUSE_UP - if (!self.is_on_floor() && mouseY < 0 && mouseX < mouseY && mouseX > -mouseY): - attackDirection = MOUSE_DOWN - elif (mouseX < 0 && mouseX <= mouseY): + if (mouseX < 0 && mouseX <= mouseY): attackDirection = MOUSE_LEFT bodyRotation = -1 set_rotation_degrees(Vector3(0, 180, 0)) broadcastTurn(bodyRotation) - elif (mouseX > 0 && mouseX >= -mouseY): + elif (mouseX >= 0 && mouseX >= -mouseY): attackDirection = MOUSE_RIGHT bodyRotation = 1 set_rotation_degrees(Vector3(0, 0, 0)) broadcastTurn(bodyRotation) + if (!self.is_on_floor() && mouseY > 0 && mouseX < mouseY && mouseX > -mouseY): + attackDirection = MOUSE_DOWN + print(attackDirection) processAttack(attackTypeInput) -- GitLab