X-Git-Url: http://git.purplebirdman.com/frog-ninja.git/blobdiff_plain/9fac9f2c3ccbba52e1e450f5b9dde7a52336fa57..2e697142bf5e1b94429281572bdc1cbf5868d5ce:/player/moves/fall.gd diff --git a/player/moves/fall.gd b/player/moves/fall.gd index 205f194..70765e5 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.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 + + 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_fall()