extends CharacterBody2D signal morreu const SPEED = 400.0 const JUMP_VELOCITY = -900.0 const GRAVITY_MULTIPLIER = 2.5 func _physics_process(delta): if not is_on_floor(): velocity += get_gravity() * delta * GRAVITY_MULTIPLIER if Input.is_action_just_pressed("ui_accept") and is_on_floor(): velocity.y = JUMP_VELOCITY var direction = Input.get_axis("ui_left", "ui_right") if direction: velocity.x = direction * SPEED $AnimatedSprite2D.flip_h = velocity.x < 0 else: velocity.x = 0 move_and_slide() if is_on_floor(): if direction: $AnimatedSprite2D.animation = "run" else: $AnimatedSprite2D.animation = "idle" else: if velocity.y < 0: $AnimatedSprite2D.animation = "up" else: $AnimatedSprite2D.animation = "down" func _on_visible_on_screen_notifier_2d_screen_exited(): morreu.emit()