princesse/prout: gravité progressive

Si la princesse dash vers le haut, alors la gravité va reprendre
progressivement.
This commit is contained in:
Thomas Lavocat
2023-05-08 19:40:18 +02:00
parent 7d7ea8542f
commit a7fec3a450
2 changed files with 7 additions and 1 deletions

View File

@@ -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