|
|
|
|
@ -93,15 +93,16 @@ func jump_state(_delta): |
|
|
|
|
if(direction): |
|
|
|
|
velocity.x = move_toward(velocity.x, direction * SPEED, SPEED) |
|
|
|
|
|
|
|
|
|
if is_on_floor(): |
|
|
|
|
if direction: |
|
|
|
|
$fsm.set_next_state("walk") |
|
|
|
|
else: |
|
|
|
|
velocity.x = 0 |
|
|
|
|
$fsm.set_next_state("idle") |
|
|
|
|
if velocity.y > 0: |
|
|
|
|
if is_on_floor(): |
|
|
|
|
if direction: |
|
|
|
|
$fsm.set_next_state("walk") |
|
|
|
|
else: |
|
|
|
|
velocity.x = 0 |
|
|
|
|
$fsm.set_next_state("idle") |
|
|
|
|
|
|
|
|
|
if is_on_wall() || (is_on_ceiling() and Input.is_action_pressed("player_up")): |
|
|
|
|
$fsm.set_next_state("climb") |
|
|
|
|
if is_on_wall() || (is_on_ceiling() and Input.is_action_pressed("player_up")): |
|
|
|
|
$fsm.set_next_state("climb") |
|
|
|
|
|
|
|
|
|
func on_enter_climb_state(): |
|
|
|
|
sprite.modulate = Color(1, 0, 0) |
|
|
|
|
@ -137,13 +138,23 @@ func after_state(delta): |
|
|
|
|
move_and_slide() |
|
|
|
|
|
|
|
|
|
if use_gravity[$fsm.current_state] == true: |
|
|
|
|
velocity.y += gravity * delta |
|
|
|
|
handle_gravity(delta) |
|
|
|
|
|
|
|
|
|
if can_grab_obstacles[$fsm.current_state] == true: |
|
|
|
|
handle_grab() |
|
|
|
|
|
|
|
|
|
handle_sprite_orientation() |
|
|
|
|
|
|
|
|
|
func handle_gravity(delta): |
|
|
|
|
var gravity_delta = gravity |
|
|
|
|
if velocity.y > 0: |
|
|
|
|
if Input.is_action_pressed('player_jump'): |
|
|
|
|
gravity_delta = WORLD_GRAVITY / 10 |
|
|
|
|
else: |
|
|
|
|
gravity_delta = WORLD_GRAVITY |
|
|
|
|
|
|
|
|
|
velocity.y += gravity_delta * delta |
|
|
|
|
|
|
|
|
|
func handle_grab(): |
|
|
|
|
if Input.is_action_just_pressed('player_action'): |
|
|
|
|
if grabbed_obstacle == null: |
|
|
|
|
|