game.gd 610 B

123456789101112131415161718192021222324
  1. extends Node2D
  2. @onready var health_bar = $HealthBar
  3. @onready var transition = $Overlay/Transition
  4. var direction = -1
  5. func _ready() -> void:
  6. transition.slide_out()
  7. func _process(_delta: float) -> void:
  8. if Input.is_action_pressed("ui_cancel"):
  9. var tree = get_tree()
  10. transition.text = ""
  11. transition.slide_in()
  12. await transition.game_fully_hidden
  13. tree.paused = true
  14. tree.change_scene_to_file("res://screens/main_menu.tscn")
  15. tree.paused = false
  16. func _on_timer_timeout():
  17. health_bar.health += direction
  18. if health_bar.health == 0 || health_bar.health == health_bar.MAX_HEALTH:
  19. direction *= -1