X-Git-Url: http://git.purplebirdman.com/frog-ninja.git/blobdiff_plain/953e05ff87d97ec54c5ad44336773ac849bc37fe..refs/heads/state-machine:/player/moves/fall.gd?ds=sidebyside diff --git a/player/moves/fall.gd b/player/moves/fall.gd index 034f41f..0330e7c 100644 --- a/player/moves/fall.gd +++ b/player/moves/fall.gd @@ -2,10 +2,29 @@ extends Move 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.player_actions.append("fall") + elif not landing_type.is_empty(): + input.player_actions.append(landing_type) + + input.player_actions.sort_custom(moves_priority_sort) + return input.player_actions[0] + + 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() - - -func on_enter_state(): - player.skin.transition_falling()