game.gd 465 B

123456789101112131415161718
  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. get_tree().change_scene_to_file("res://screens/main_menu.tscn")
  10. func _on_timer_timeout():
  11. health_bar.health += direction
  12. if health_bar.health == 0 || health_bar.health == health_bar.MAX_HEALTH:
  13. direction *= -1