From b284b325c9c1ccd9246b1da66821659e091f80f0 Mon Sep 17 00:00:00 2001 From: Snoweuph Date: Mon, 10 Apr 2023 23:50:19 +0200 Subject: [PATCH] Cleaning Code --- Scripts/EntitySystem/Bunny.gd | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Scripts/EntitySystem/Bunny.gd b/Scripts/EntitySystem/Bunny.gd index afa660f..811e925 100644 --- a/Scripts/EntitySystem/Bunny.gd +++ b/Scripts/EntitySystem/Bunny.gd @@ -71,20 +71,16 @@ func sub_on_death(callback : Callable): func update_animation(): match self.velocity: Vector2.ZERO: animation_player.play("Idle") - _: handle_diagonal_animations(self.velocity) - pass - -func handle_diagonal_animations(dir : Vector2): - - var left_dot = Vector2.LEFT.dot(dir) - var right_dot = Vector2.RIGHT.dot(dir) - var up_dot = Vector2.UP.dot(dir) - var down_dot = Vector2.DOWN.dot(dir) - - var max_dot = minf(left_dot, minf(right_dot, minf(up_dot, down_dot))) - match max_dot: - left_dot: animation_player.play("MoveLeft") - right_dot: animation_player.play("MoveRight") - up_dot: animation_player.play("MoveUp") - down_dot: animation_player.play("MoveDown") + _: + var left_dot = Vector2.LEFT.dot(self.velocity) + var right_dot = Vector2.RIGHT.dot(self.velocity) + var up_dot = Vector2.UP.dot(self.velocity) + var down_dot = Vector2.DOWN.dot(self.velocity) + + var max_dot = maxf(left_dot, maxf(right_dot, maxf(up_dot, down_dot))) + match max_dot: + left_dot: animation_player.play("MoveLeft") + right_dot: animation_player.play("MoveRight") + up_dot: animation_player.play("MoveUp") + down_dot: animation_player.play("MoveDown") pass