added saving

This commit is contained in:
pennyrigate 2023-01-03 20:52:30 -05:00
parent 1ca21d438f
commit 969364ebce
40 changed files with 625 additions and 88 deletions

View file

@ -1,6 +1,7 @@
extends Node2D
export var value = 1
export var number = 0 #Used for saving which specific shards collected
func _ready():
$AnimationPlayer.play("glow")
@ -11,4 +12,5 @@ func _on_Area2D_area_entered(area):
Game.play_sound(Game.a_shard,Game.ac_collectible)
Game.score += 500
Game.shards += value
Game.shards_collected[number] = true
queue_free()

View file

@ -30,5 +30,6 @@ func _on_Area2D_area_entered(area):
if Game.stars[0] && Game.stars[1] && Game.stars[2] && Game.stars[3] && Game.stars[4]:
Game.play_sound(Game.a_shard,Game.ac_collectible)
Game.shards += 1
Game.shards_collected[4] = true
Game.score += 500
queue_free()

View file

@ -16,4 +16,5 @@ func _physics_process(delta):
func _on_Area2D_area_entered(area):
if area.is_in_group("player"):
if Game.score > Game.high_score: Game.high_score = Game.score
Game.change_map(load("res://maps/demo_end.tscn"))
Game.save()
Game.change_map(load("res://maps/level_select.tscn"))

View file

@ -14,7 +14,7 @@ onready var high_counter = $HighCounter
func _physics_process(delta):
#Gold Counter
gold_counter.text = "%03d" % Game.golds
gold_counter.text = "%02d" % Game.golds
#Shard Counter
shard_counter.text = "%02d" % Game.shards
#Star Counter
@ -29,6 +29,6 @@ func _physics_process(delta):
arrow_counter.text = "%02d" % Game.arrows
##TOUCH UP LATER
#Lives counter
lives_counter.text = str("LIVES:") + str(Game.lives)
lives_counter.text = str(Game.lives)
#High counter
high_counter.text = str("HIGH:") + str("%06d" % Game.high_score)

View file

@ -1,35 +1,13 @@
[gd_scene load_steps=16 format=2]
[gd_scene load_steps=7 format=2]
[ext_resource path="res://scripts/recolor.tres" type="Shader" id=1]
[ext_resource path="res://graphics/collectibles/pal_star_yellow.png" type="Texture" id=2]
[ext_resource path="res://graphics/hud/stars_hud.png" type="Texture" id=1]
[ext_resource path="res://graphics/hud/hud.png" type="Texture" id=3]
[ext_resource path="res://graphics/collectibles/star.png" type="Texture" id=4]
[ext_resource path="res://graphics/collectibles/pal_star_red.png" type="Texture" id=5]
[ext_resource path="res://objects/hud/hud.gd" type="Script" id=6]
[ext_resource path="res://graphics/collectibles/pal_star_green.png" type="Texture" id=7]
[ext_resource path="res://graphics/collectibles/pal_star_blue.png" type="Texture" id=8]
[ext_resource path="res://graphics/collectibles/pal_star_magenta.png" type="Texture" id=9]
[ext_resource path="res://scripts/theme.tres" type="Theme" id=10]
[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 1 )
shader_param/palette = ExtResource( 5 )
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 1 )
shader_param/palette = ExtResource( 2 )
[sub_resource type="ShaderMaterial" id=3]
shader = ExtResource( 1 )
shader_param/palette = ExtResource( 7 )
[sub_resource type="ShaderMaterial" id=4]
shader = ExtResource( 1 )
shader_param/palette = ExtResource( 8 )
[sub_resource type="ShaderMaterial" id=5]
shader = ExtResource( 1 )
shader_param/palette = ExtResource( 9 )
[node name="CanvasLayer" type="CanvasLayer"]
layer = 100
@ -40,82 +18,76 @@ margin_bottom = 1.0
script = ExtResource( 6 )
[node name="Back" type="Sprite" parent="HUD"]
position = Vector2( 128, 8 )
position = Vector2( 128, 95 )
texture = ExtResource( 3 )
[node name="GoldCounter" type="Label" parent="HUD"]
margin_left = 14.0
margin_top = 1.0
margin_right = 54.0
margin_bottom = 21.0
margin_left = 12.0
margin_top = -2.0
margin_right = 52.0
margin_bottom = 18.0
theme = ExtResource( 10 )
text = "000"
text = "00
"
[node name="ShardCounter" type="Label" parent="HUD"]
margin_left = 53.0
margin_top = 1.0
margin_right = 93.0
margin_bottom = 21.0
margin_left = 41.0
margin_top = -2.0
margin_right = 81.0
margin_bottom = 18.0
theme = ExtResource( 10 )
text = "00"
[node name="RedStar" type="Sprite" parent="HUD"]
visible = false
material = SubResource( 1 )
position = Vector2( 79, 8 )
texture = ExtResource( 4 )
position = Vector2( 86, 5 )
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 0, 11, 11 )
region_rect = Rect2( 0, 0, 8, 8 )
[node name="YellowStar" type="Sprite" parent="HUD"]
visible = false
material = SubResource( 2 )
position = Vector2( 92, 8 )
texture = ExtResource( 4 )
position = Vector2( 96, 5 )
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 0, 11, 11 )
region_rect = Rect2( 8, 0, 8, 8 )
[node name="GreenStar" type="Sprite" parent="HUD"]
visible = false
material = SubResource( 3 )
position = Vector2( 105, 8 )
texture = ExtResource( 4 )
position = Vector2( 106, 5 )
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 0, 11, 11 )
region_rect = Rect2( 16, 0, 8, 8 )
[node name="BlueStar" type="Sprite" parent="HUD"]
visible = false
material = SubResource( 4 )
position = Vector2( 118, 8 )
texture = ExtResource( 4 )
position = Vector2( 116, 5 )
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 0, 11, 11 )
region_rect = Rect2( 24, 0, 8, 8 )
[node name="MagentaStar" type="Sprite" parent="HUD"]
visible = false
material = SubResource( 5 )
position = Vector2( 131, 8 )
texture = ExtResource( 4 )
position = Vector2( 126, 5 )
texture = ExtResource( 1 )
region_enabled = true
region_rect = Rect2( 0, 0, 11, 11 )
region_rect = Rect2( 32, 0, 8, 8 )
[node name="ScoreText" type="Label" parent="HUD"]
margin_left = 142.0
margin_top = 1.0
margin_right = 226.0
margin_bottom = 21.0
margin_left = 137.0
margin_top = -2.0
margin_right = 221.0
margin_bottom = 18.0
theme = ExtResource( 10 )
text = "SCORE:"
[node name="ScoreCounter" type="Label" parent="HUD"]
margin_left = 180.0
margin_top = 1.0
margin_right = 264.0
margin_bottom = 21.0
margin_left = 179.0
margin_top = -2.0
margin_right = 263.0
margin_bottom = 18.0
theme = ExtResource( 10 )
text = "000000"
[node name="HighCounter" type="Label" parent="HUD"]
visible = false
margin_left = 178.0
margin_top = 178.0
margin_right = 262.0
@ -124,17 +96,17 @@ theme = ExtResource( 10 )
text = "High:000000"
[node name="LivesCounter" type="Label" parent="HUD"]
margin_left = 1.0
margin_top = 178.0
margin_right = 85.0
margin_bottom = 198.0
margin_left = 240.0
margin_top = -2.0
margin_right = 324.0
margin_bottom = 18.0
theme = ExtResource( 10 )
text = "Lives:2"
text = "2"
[node name="ArrowCounter" type="Label" parent="HUD"]
margin_left = 237.0
margin_top = 1.0
margin_right = 321.0
margin_bottom = 21.0
margin_left = 68.0
margin_top = -2.0
margin_right = 152.0
margin_bottom = 18.0
theme = ExtResource( 10 )
text = "00"
text = "0"

View file

@ -278,4 +278,9 @@ func debug():
if Input.is_action_pressed("debug_move_player"):
position = get_viewport().get_mouse_position()
print(get_viewport().get_mouse_position())
if Input.is_action_just_pressed("debug_1"):
Game.save()
if Input.is_action_just_pressed("debug_2"):
var save = ConfigFile.new()
save.load(str("user://file") + str(1) + str(".pr"))
Game.score = save.get_value(str(Game.current_level),"Score",0)