35 lines
668 B
GDScript
35 lines
668 B
GDScript
extends Node
|
|
|
|
const SAVE_FILE : String = "user://SAVEFILE.save"
|
|
var game_data = {}
|
|
|
|
func _ready():
|
|
load_data()
|
|
|
|
func load_data():
|
|
var file = FileAccess.open(SAVE_FILE, FileAccess.READ)
|
|
if file == null:
|
|
game_data = {
|
|
"display_mode": 0,
|
|
"vsync_on": false,
|
|
"current_resolution_index": 0,
|
|
"move_up": KEY_W,
|
|
"move_down": KEY_S,
|
|
"move_left": KEY_A,
|
|
"move_right": KEY_D,
|
|
"master_volume": 0,
|
|
"music_volume": 0,
|
|
"sfx_volume": 0,
|
|
}
|
|
save_data()
|
|
else:
|
|
game_data = file.get_var()
|
|
file.close()
|
|
pass
|
|
|
|
func save_data():
|
|
var file = FileAccess.open(SAVE_FILE, FileAccess.WRITE)
|
|
file.store_var(game_data)
|
|
file.flush()
|
|
file.close()
|
|
pass
|