space_empire/scripts/GameState.gd
2025-10-13 17:09:10 +02:00

19 lines
477 B
GDScript

extends Node
# GameState.gd - simple resource manager singleton (add as Autoload 'GameState' in Project Settings)
var resources := {
"metal": 100,
"energy": 50
}
func add_resource(kind: String, amount: int):
if not resources.has(kind):
resources[kind] = 0
resources[kind] += amount
func spend_resource(kind: String, amount: int) -> bool:
if resources.get(kind, 0) >= amount:
resources[kind] -= amount
return true
return false