]> Untitled Git - frog-ninja.git/blob - player/moves/fall.gd
Added landing states
[frog-ninja.git] / player / moves / fall.gd
1 extends Move
2 class_name Fall
3
4
5 const fall_landing_limit := 3.0
6 const fall_roll_limit := 6.0
7
8 var landing_type := ""
9
10
11 func should_enter(input: InputPacket) -> String:
12         if not player.is_on_floor():
13                 input.actions.append("fall")
14         elif not landing_type.is_empty():
15                 input.actions.append(landing_type)
16                 
17         input.actions.sort_custom(moves_priority_sort)
18         return input.actions[0]
19
20
21 func update(_input: InputPacket, delta: float):
22         player.velocity += player.get_gravity() * delta
23         
24         if abs(player.velocity.y) > fall_landing_limit:
25                 if abs(player.velocity.y) > fall_roll_limit:
26                         landing_type = "fallToRoll"
27                 else:
28                         landing_type = "fallToLanding"
29         
30         player.move_and_slide()
31
32
33 func on_enter_state():
34         player.skin.transition_fall()