Allows the player to glide

main
Ervan Lefevre 2 years ago
parent df61097d27
commit b307837dc5
  1. 13
      nodes/player/player.gd
  2. 2
      scenes/poc.tscn

@ -93,6 +93,7 @@ func jump_state(_delta):
if(direction): if(direction):
velocity.x = move_toward(velocity.x, direction * SPEED, SPEED) velocity.x = move_toward(velocity.x, direction * SPEED, SPEED)
if velocity.y > 0:
if is_on_floor(): if is_on_floor():
if direction: if direction:
$fsm.set_next_state("walk") $fsm.set_next_state("walk")
@ -137,13 +138,23 @@ func after_state(delta):
move_and_slide() move_and_slide()
if use_gravity[$fsm.current_state] == true: if use_gravity[$fsm.current_state] == true:
velocity.y += gravity * delta handle_gravity(delta)
if can_grab_obstacles[$fsm.current_state] == true: if can_grab_obstacles[$fsm.current_state] == true:
handle_grab() handle_grab()
handle_sprite_orientation() 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(): func handle_grab():
if Input.is_action_just_pressed('player_action'): if Input.is_action_just_pressed('player_action'):
if grabbed_obstacle == null: if grabbed_obstacle == null:

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save