From c23d9d3914f1258daf912866e2a56ee29f74a575 Mon Sep 17 00:00:00 2001 From: Thomas Lavocat Date: Sat, 29 Apr 2023 17:06:08 +0200 Subject: [PATCH] coyote: rajout du coyote time pout le saut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit le joueur peut sauter pendant quelques frames après avoir quitté le sol. ça rend le jeu beaucoup plus smooth --- princesse.gd | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/princesse.gd b/princesse.gd index 826dfa9..886f65b 100644 --- a/princesse.gd +++ b/princesse.gd @@ -28,7 +28,7 @@ var gravity: int = ProjectSettings.get("physics/2d/default_gravity") # Nombre de frames coyote durant lesquelle le joueur peut encore sauter # sans encore être au sol -@export var COYOTE_LENGTH := 20 +@export var COYOTE_LENGTH := 15 # Direction dans laquelle est positioné le personnage. var direction : int = 1 @@ -47,6 +47,7 @@ var jumping : bool = false var need_jump : bool = false var jumping_step : int = -1 var jump_key_counter : int = 0 +var coyote_ground = [] var falling_step : int = -1 @@ -168,14 +169,19 @@ func end_jump(): jump_key_counter = 0 func _physics_process(delta: float) -> void: + + coyote_ground.append(is_on_floor()) + if coyote_ground.size() > COYOTE_LENGTH: + coyote_ground.remove_at(0) + pressing_wall = wall_detect_left.is_colliding() or wall_detect_right.is_colliding() grab_wall = pressing_wall and Input.is_action_pressed("grab" + action_suffix) if Input.is_action_just_pressed("jump" + action_suffix): - if ground_far_detect.is_colliding() or is_on_floor(): + if ground_far_detect.is_colliding() or (is_on_floor() or coyote_ground[0]): need_jump=true - if need_jump and is_on_floor(): + if need_jump and (is_on_floor() or coyote_ground[0]): need_jump = false if not jumping: jumping = true