main.gd 452 B

123456789101112131415161718192021222324252627282930
  1. class_name Game
  2. extends Node
  3. signal start_new_game
  4. enum State {
  5. BOOTING,
  6. SET_UP,
  7. IN_PROGRESS,
  8. LOST
  9. }
  10. var _current_state = State.BOOTING
  11. func _ready():
  12. _current_state = State.IN_PROGRESS
  13. func _unhandled_input(event: InputEvent) -> void:
  14. if event.is_action_released("ui_accept"):
  15. if _current_state == State.LOST:
  16. _current_state = State.IN_PROGRESS
  17. emit_signal("start_new_game")
  18. func _on_game_lost():
  19. _current_state = State.LOST