diff --git a/princesse.gd b/princesse.gd index c226b4c..4fd7a20 100644 --- a/princesse.gd +++ b/princesse.gd @@ -49,6 +49,8 @@ var jump_key_counter : int = 0 var falling_step : int = -1 +var pressing_wall = false + func walk(direction:int) -> int: # Fait marcher le personnage. @@ -58,6 +60,9 @@ func walk(direction:int) -> int: if is_on_floor(): threshold = WALK_INCR_GROUND + if is_on_wall(): + walking_step = min(walking_step, 1) + # Si le joueur décide de marcher alors, le compteur de pas doit s'incrémenter # Si le joueur ne veut plus marcher, alors, le compteur de pas décrémente @@ -99,6 +104,8 @@ func fall() -> int: return velocity.y else: falling_step = min(falling_step+1, FALL_SPEED_TABLE.size()-1) + if pressing_wall: + falling_step = min(falling_step, FALL_SPEED_TABLE.size()-5) return FALL_SPEED_TABLE[falling_step] * FALLING_SPEED @@ -151,8 +158,10 @@ func _physics_process(delta: float) -> void: "move_right" + action_suffix ) + pressing_wall = is_on_wall_only() and not is_zero_approx(axis) if axis != 0: direction = axis + velocity.x = walk(direction) if not is_zero_approx(velocity.x): @@ -161,6 +170,9 @@ func _physics_process(delta: float) -> void: else: animation.scale.x = -1.0 + if pressing_wall and not jumping: + animation.scale.x *= -1 + floor_stop_on_slope = not platform_detector.is_colliding() move_and_slide() # Character is colliding @@ -180,10 +192,13 @@ func get_new_animation(is_shooting := false) -> String: animation_new = "idle" else: if velocity.y > 0.0: - if walking_step > 0: - animation_new = "falling_diagonals" + if pressing_wall: + animation_new = "wall_stick" else: - animation_new = "falling_straight" + if walking_step > 0: + animation_new = "falling_diagonals" + else: + animation_new = "falling_straight" else: animation_new = "jumping" return animation_new