extends AirborneState class_name JumpState func on_air_enter() -> void: #play_char.godot_plush_skin.set_state("jump") if player.jump_cooldown < player.jump_cooldown_ref: player.jump_cooldown = player.jump_cooldown_ref player.coyote_jump_cooldown = -1.0 #un saut consomme le coyote jump : pas de saut gratuit en retombant juste apres #if player.movement_dust.emitting: player.movement_dust.emitting = false jump() func check_apex() -> bool: #le perso commence a descendre : la suite de la chute se passe dans InairState return player.velocity.y < 0.0 and fall() func handle_input() -> bool: if input.jump_pressed(): jump() if input.jump_released(): #cut jump in action, allow to manage jump height #(the longer you press the button, the more high the play char goes, similar to the Mario Bros games) #le freinage de la montee est applique par InairState a son entree player.has_cut_jump = true return fall() return false func jump() -> void: #manage the jump behaviour, depending of the different variables and states the character is var can_jump : bool = false #jump condition #in air jump if !player.is_on_floor(): if player.coyote_jump_on: player.jump_cooldown = player.jump_cooldown_ref player.coyote_jump_cooldown = -1.0 #so that the character cannot immediately make another coyote jump player.coyote_jump_on = false can_jump = true elif player.nb_jumps_in_air_allowed > 0: player.nb_jumps_in_air_allowed -= 1 player.jump_cooldown = player.jump_cooldown_ref can_jump = true #on floor jump if player.is_on_floor(): player.jump_cooldown = player.jump_cooldown_ref can_jump = true #jump buffering if player.buffered_jump: player.buffered_jump = false player.nb_jumps_in_air_allowed = player.nb_jumps_in_air_allowed_ref #apply jump if can_jump: player.velocity.y = -player.jump_velocity can_jump = false #play squash and strech effect, and display jump particles if player.is_on_floor(): player.squash_and_strech(1.12, 0.1) #player.particles_manager.display_particles(player.jump_particles, player)