53 lines
675 B
GDScript
53 lines
675 B
GDScript
class_name ArcadeGame
|
|
extends Node
|
|
|
|
|
|
signal game_started
|
|
signal game_won
|
|
signal game_lost
|
|
signal game_reset
|
|
|
|
|
|
var is_running: bool = false
|
|
var run_config: Dictionary = {}
|
|
|
|
|
|
func configure(config: Dictionary = {}) -> void:
|
|
run_config = config
|
|
|
|
|
|
func start_game() -> bool:
|
|
if is_running:
|
|
return false
|
|
|
|
is_running = true
|
|
game_started.emit()
|
|
|
|
return true
|
|
|
|
|
|
func win_game() -> void:
|
|
if not is_running:
|
|
return
|
|
|
|
is_running = false
|
|
game_won.emit()
|
|
|
|
|
|
func lose_game() -> void:
|
|
if not is_running:
|
|
return
|
|
|
|
is_running = false
|
|
game_lost.emit()
|
|
|
|
|
|
func reset_game() -> void:
|
|
is_running = false
|
|
game_reset.emit()
|
|
|
|
|
|
func restart_game() -> void:
|
|
reset_game()
|
|
start_game()
|