persistence

This commit is contained in:
Page Asgardius 2023-11-01 09:36:29 -07:00
parent 3cc54a801d
commit fe2321cdd2
7 changed files with 62 additions and 6 deletions

View file

@ -2,11 +2,15 @@ extends Node
var title = preload("res://title.tscn").instantiate() var title = preload("res://title.tscn").instantiate()
var boot = preload("res://bootclick.tscn").instantiate() var boot = preload("res://bootclick.tscn").instantiate()
const loadgame = preload("res://load.gd")
const savegame = preload("res://save.gd")
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. loadgame.new()
print(Global.level1max)
#pass # Replace with function body.
#add_child(title) #add_child(title)

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=3 format=3 uid="uid://dyaorf0qpfokg"] [gd_scene load_steps=3 format=3 uid="uid://lghjmhbmqoyt"]
[ext_resource type="Script" path="res://bootclick.gd" id="1_52bti"] [ext_resource type="Script" path="res://bootclick.gd" id="1_52bti"]
[ext_resource type="Script" path="res://fps.gd" id="2_gnh1w"] [ext_resource type="Script" path="res://fps.gd" id="2_gnh1w"]

View file

@ -6,6 +6,14 @@ var origmpos
var mousepos var mousepos
var timelimit = 15000 var timelimit = 15000
var wait var wait
var hiscoresfile = "user://hiscores.save"
var level1max
var level2max
var level3max
var level4max
var level5max
var level6max
var level7max
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.

View file

@ -42,8 +42,7 @@ Pygame version testing
Astroboy Astroboy
Zencifer Zencifer
Natasha Natasha
Sakura Nakayama BMX Man
Bicycle Man
Godot version testing Godot version testing
@ -455,7 +454,11 @@ Source code hosted at https://git.asgardius.company/asgardius/r3-cd
You can listen the oficial radio station at https://asteroid.asgardius.company/public/r3 You can listen the oficial radio station at https://asteroid.asgardius.company/public/r3
Special Thanks for Unity Technologies for make me choosing Godot" Special Thanks for Unity Technologies for make me choosing Godot
Godot does what Unitydnt
I'm looking for developers, artists and japanese voice actors who want to help on my next videogame from Asgardius Virtualx series"
horizontal_alignment = 1 horizontal_alignment = 1
script = ExtResource("6_3q8sp") script = ExtResource("6_3q8sp")

36
load.gd Normal file
View file

@ -0,0 +1,36 @@
extends Node
var file
func _init():
if FileAccess.file_exists(Global.hiscoresfile):
file = FileAccess.open(Global.hiscoresfile, FileAccess.READ)
var checkpoint = file.get_as_text().rsplit(",", true, 7)
Global.level1max = checkpoint[0]
Global.level2max = checkpoint[1]
Global.level3max = checkpoint[2]
Global.level4max = checkpoint[3]
Global.level5max = checkpoint[4]
Global.level6max = checkpoint[5]
Global.level7max = checkpoint[6]
# We need to revert the game state so we're not cloning objects
# during loading. This will vary wildly depending on the needs of a
# project, so take care with this step.
# For our example, we will accomplish this by deleting saveable objects.
#var save_nodes = get_tree().get_nodes_in_group("Persist")
#for i in save_nodes:
# i.queue_free()
# Load the file line by line and process that dictionary to restore
# the object it represents.
else:
var saveinit = "9999999,9999999,9999999,9999999,9999999,9999999,9999999"
var file = FileAccess.open(Global.hiscoresfile, FileAccess.WRITE)
file.store_string(saveinit)
var checkpoint = saveinit.rsplit(",", true, 7)
Global.level1max = checkpoint[0]
Global.level2max = checkpoint[1]
Global.level3max = checkpoint[2]
Global.level4max = checkpoint[3]
Global.level5max = checkpoint[4]
Global.level6max = checkpoint[5]
Global.level7max = checkpoint[6]

View file

@ -24,7 +24,6 @@ Global="*res://global.gd"
window/size/viewport_width=1280 window/size/viewport_width=1280
window/size/viewport_height=720 window/size/viewport_height=720
window/size/mode=3
window/stretch/mode="viewport" window/stretch/mode="viewport"
[rendering] [rendering]

6
save.gd Normal file
View file

@ -0,0 +1,6 @@
extends Node
func _init():
var saveinit = str(Global.level1max)+","+str(Global.level2max)+","+str(Global.level3max)+","+str(Global.level4max)+","+str(Global.level5max)+","+str(Global.level6max)+","+str(Global.level7max)
var file = FileAccess.open(Global.hiscoresfile, FileAccess.WRITE)
file.store_string(saveinit)
file.close()