1234567891011121314151617181920212223242526272829303132333435363738 |
- extends Node
- # Manage game state
- enum State {IDLE, GAMING}
- var _current_state = State.IDLE
- func _ready():
- randomize() # Plant seed for random number generation
- func trigger_pause():
- if _pausable():
- _toggle_pause()
- func _unhandled_input(event: InputEvent):
- if event.is_action_pressed("ui_accept"):
- print("Trigger pause")
- trigger_pause()
- func _pausable():
- return _current_state == State.GAMING
- func _toggle_pause():
- var previous := get_tree().is_paused()
- get_tree().set_pause(!previous)
- func _on_Main_game_over():
- _current_state = State.IDLE
- func _on_Main_game_started():
- _current_state = State.GAMING
|