Save boss and player statuses
This commit is contained in:
parent
b0c5798328
commit
6ea21b3181
9 changed files with 43 additions and 3 deletions
|
@ -3,12 +3,20 @@ extends Node
|
|||
const save_path = "user://savegame.save"
|
||||
|
||||
var is_loading = false
|
||||
var custom_data = { # Defaults
|
||||
"boss_defeated": false,
|
||||
"missiles": 0,
|
||||
"missiles_unlocked": false,
|
||||
"health": 4,
|
||||
}
|
||||
|
||||
func save_game():
|
||||
print("Saving game")
|
||||
var save_game = File.new()
|
||||
save_game.open(save_path, File.WRITE)
|
||||
var persistingNodes = get_tree().get_nodes_in_group("Persists")
|
||||
|
||||
save_game.store_line(to_json(custom_data))
|
||||
|
||||
for node in persistingNodes:
|
||||
var nodeData = node.save()
|
||||
save_game.store_line(to_json(nodeData))
|
||||
|
@ -25,6 +33,10 @@ func load_game():
|
|||
node.queue_free()
|
||||
|
||||
save_game.open(save_path, File.READ)
|
||||
|
||||
if not save_game.eof_reached():
|
||||
custom_data = parse_json(save_game.get_line())
|
||||
|
||||
while not save_game.eof_reached():
|
||||
var current_line = save_game.get_line()
|
||||
if current_line == "":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue