go to opposite side of ladder if at the top and holding direction (fixes #37)

This commit is contained in:
Haze Weathers 2023-05-24 12:53:01 -04:00
parent 5f3d907c3f
commit ebdb4e51aa
2 changed files with 7 additions and 3 deletions

View file

@ -109,7 +109,6 @@ func die() -> void:
func _on_Grounded_state_entered() -> void:
# still jump if pressed frame hit ground
if Input.is_action_just_pressed("jump"):
print("BOING")
state_chart.send_event("jump")
# toggle hurtbox shapes
grounded_shape.disabled = false
@ -190,7 +189,12 @@ func _on_Climbing_state_entered() -> void:
global_position.y -= get("collision/safe_margin")
velocity = Vector2.ZERO
snap = Vector2.ZERO
if global_position.x < _attached_ladder.middle:
var input_dir = sign(Input.get_axis("ui_left", "ui_right"))
var ladder_dir = sign(_attached_ladder.middle - global_position.x)
var flip = global_position.y - 1.0 <= _attached_ladder.global_position.y and input_dir == ladder_dir
print(ladder_dir)
print(flip)
if ladder_dir >= 0.0 != flip:
global_position.x = _attached_ladder.left_snap
graphics.scale.x = 1.0
else:

View file

@ -1165,8 +1165,8 @@ script = ExtResource( 8 )
[connection signal="state_physics_processing" from="StateChart/Root/Movement" to="." method="_process_movement"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded" to="." method="_on_Grounded_state_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded" to="." method="_process_grounded"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_can_walk"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_horizontal_movement_grounded"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_can_walk"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Still" to="." method="_on_Still_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Walking" to="." method="_on_Walking_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Blinking" to="." method="_on_Blinking_state_entered"]