From a7fec3a450fb21071a4e1ccd8279d4eb45582061 Mon Sep 17 00:00:00 2001 From: Thomas Lavocat Date: Mon, 8 May 2023 19:40:18 +0200 Subject: [PATCH] =?UTF-8?q?princesse/prout:=20gravit=C3=A9=20progressive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Si la princesse dash vers le haut, alors la gravité va reprendre progressivement. --- princesse.gd | 7 ++++++- princesse.tscn | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/princesse.gd b/princesse.gd index 07e760c..37ce96f 100644 --- a/princesse.gd +++ b/princesse.gd @@ -208,6 +208,9 @@ func fall() -> float: if jumping or kicking or dashing: falling_step = -1 return velocity.y + var intertia = 0 + if velocity.y < 0: + intertia = max(velocity.y, -FALLING_SPEED) if is_on_floor_only(): if get_floor_normal()[0] < 0: # pente à gauche if direction >= 0:# on va à droite, désactive la gravité @@ -225,8 +228,10 @@ func fall() -> float: if grab_wall: falling_step = max(falling_step-1, 1) else: + if intertia < 0 and intertia + FALL_SPEED_TABLE[falling_step] * FALLING_SPEED >0: + falling_step = 0 falling_step = min(falling_step+1, FALL_SPEED_TABLE.size()-1) - return FALL_SPEED_TABLE[falling_step] * FALLING_SPEED + return intertia + FALL_SPEED_TABLE[falling_step] * FALLING_SPEED func jump() -> float: # fait sauter princesse diff --git a/princesse.tscn b/princesse.tscn index 4e279be..e5f5e04 100644 --- a/princesse.tscn +++ b/princesse.tscn @@ -283,6 +283,7 @@ collision_mask = 16 [node name="Camera2D" type="Camera2D" parent="."] zoom = Vector2(2, 2) +limit_smoothed = true drag_horizontal_enabled = true drag_vertical_enabled = true