added main menu and can continue from last level

This commit is contained in:
derek
2025-02-24 17:00:41 -06:00
parent a303eb6430
commit c87f22d9e8
14 changed files with 204 additions and 68 deletions

View File

@@ -35,7 +35,10 @@ func save_persistent_data():
print("LAST HIT PATH " + str(last_hit_path))
file.store_var(last_hit_path)
file.store_var(player.velocity)
file.store_var(get_tree().current_scene.scene_file_path)
file.store_var(get_tree().current_scene.gamemode.resource_path)
file.store_var(GameGlobals.money)
file.store_var(GameGlobals.deposited_money)
file.store_var(GameGlobals.health)
file.store_var(GameGlobals.high_score)
file.store_var(player_deaths)
@@ -52,24 +55,20 @@ func save_persistent_data():
func load_persistent_data():
var level_control = get_tree().current_scene
var player = level_control.player
if FileAccess.file_exists(persistent_save_path):
var file = FileAccess.open(persistent_save_path, FileAccess.READ)
last_hit_path = file.get_var()
print("CROWN PARENT : " + str(last_hit_path))
player_velocity_cache = file.get_var()
GameGlobals.current_level = str(file.get_var())
GameGlobals.current_gamemode = file.get_var()
GameGlobals.money = set_nulls_zero(file.get_var())
print("MONEY : ", GameGlobals.money)
GameGlobals.deposited_money = set_nulls_zero(file.get_var())
GameGlobals.health = file.get_var()
print("HEALTH : ", GameGlobals.health)
GameGlobals.high_score = file.get_var()
print("HIGH SCORE : ",GameGlobals.high_score)
player_deaths = set_nulls_zero(file.get_var())
print("PLAYER DEATHS : " + str(player_deaths))
enemies_killed = set_nulls_zero(file.get_var())
print("ENEMIES KILLED : " + str(enemies_killed))
shots_fired = set_nulls_zero(file.get_var())
print("SHOTS FIRED ",shots_fired)
var held_guns_encoded = file.get_var()
GameGlobals.held_guns = load_resource_path(held_guns_encoded)
@@ -77,7 +76,8 @@ func load_persistent_data():
GameGlobals.ammo_reserve = file.get_var()
GameGlobals.current_gun_index = file.get_var()
if GameGlobals.current_gun_index != null:
get_tree().current_scene.gun_spawn(GameGlobals.current_gun_index)
if !get_tree().current_scene.is_in_group("ui"):
get_tree().current_scene.gun_spawn(GameGlobals.current_gun_index)
data_cleared = file.get_var()
file.close()