Improved graphics. Added game over scene

This commit is contained in:
2024-05-05 13:42:51 +01:00
parent 5a40233292
commit fef3ae9d8e
24 changed files with 392 additions and 48 deletions

27
Global.gd Normal file
View File

@@ -0,0 +1,27 @@
extends Node
var score : int = 0 :
set(x):
score = x
EventBus.update_score.emit(score)
if score > highscore:
highscore = score
var highscore : int = 0 :
set(x):
highscore = x
EventBus.update_highscore.emit(highscore)
_save()
func _ready() -> void:
if FileAccess.file_exists("user://data.json"):
var data = JSON.parse_string(FileAccess.get_file_as_string("user://data.json"))
highscore = data.get("highscore", 0)
func _save() -> void:
var data : Dictionary = {
"highscore": highscore
}
var f = FileAccess.open("user://data.json", FileAccess.WRITE)
f.store_string(JSON.stringify(data))
f.close()