]> Untitled Git - frog-ninja.git/blobdiff - player/moves/fall.gd
Separated the Visual from the Model
[frog-ninja.git] / player / moves / fall.gd
index 205f19465d7a7cc3f75557083ac7853613e9c6aa..70765e567cf185e1fd886b5621606139e2e82955 100644 (file)
@@ -2,10 +2,29 @@ extends Move
 class_name Fall
 
 
 class_name Fall
 
 
+const fall_landing_limit := 3.0
+const fall_roll_limit := 6.0
+
+var landing_type := ""
+
+
+func should_enter(input: InputPacket) -> String:
+       if not player.is_on_floor():
+               input.actions.append("fall")
+       elif not landing_type.is_empty():
+               input.actions.append(landing_type)
+               
+       input.actions.sort_custom(moves_priority_sort)
+       return input.actions[0]
+
+
 func update(_input: InputPacket, delta: float):
        player.velocity += player.get_gravity() * delta
 func update(_input: InputPacket, delta: float):
        player.velocity += player.get_gravity() * delta
+       
+       if abs(player.velocity.y) > fall_landing_limit:
+               if abs(player.velocity.y) > fall_roll_limit:
+                       landing_type = "fallToRoll"
+               else:
+                       landing_type = "fallToLanding"
+       
        player.move_and_slide()
        player.move_and_slide()
-
-
-func on_enter_state():
-       player.skin.transition_fall()