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

79
maps/level_select.gd Normal file
View file

@ -0,0 +1,79 @@
extends Node2D
##Onreadys
onready var levels = preload("res://maps/leveldata/levels.tres")
onready var title = $Title
onready var shard_title = $ShardTitle
onready var shard_arrow = $ShardArrow
onready var high_score = $HighScore
onready var golds = $Golds
onready var levelarrow_up = $LevelArrowUp
onready var levelarrow_down = $LevelArrowDown
#Shards
onready var shard0 = $ShardGraphics/Shard
onready var shard1 = $ShardGraphics/Shard2
onready var shard2 = $ShardGraphics/Shard3
onready var shard3 = $ShardGraphics/Shard4
onready var shard4 = $ShardGraphics/Shard5
onready var shard5 = $ShardGraphics/Shard6
onready var shard6 = $ShardGraphics/Shard7
onready var shard7 = $ShardGraphics/Shard8
onready var shard8 = $ShardGraphics/Shard9
onready var shard9 = $ShardGraphics/Shard10
##Runtime
var save = 0
var current_level = 0
var current_shard = 0
# Called when the node enters the scene tree for the first time.
func _ready():
pass
func _physics_process(delta):
if Input.is_action_just_pressed("ui_up"): change_current_level(-1)
if Input.is_action_just_pressed("ui_down"): change_current_level(1)
if Input.is_action_just_pressed("ui_left"): change_current_shard(-1)
if Input.is_action_just_pressed("ui_right"): change_current_shard(1)
#Draw level title
title.text = levels.level[current_level].level_title
#Draw Shard Title
shard_title.text = levels.level[current_level].shard_title[current_shard]
func change_current_shard(amount):
if current_shard + amount != -1 && current_shard + amount != 10: #Check if in range
current_shard += amount
shard_arrow.position.x += 15 * amount
func change_current_level(amount):
if current_level + amount != -1 && current_level + amount != levels.level.size(): #Check if in range
current_level += amount
#Show arrows or don't
if current_level == 0:
levelarrow_up.visible = false
levelarrow_down.visible = true
elif current_level == levels.level.size() - 1:
levelarrow_up.visible = true
levelarrow_down.visible = false
else:
levelarrow_down.visible = true
levelarrow_up.visible = true
#Return Shard select
current_shard = 0
shard_arrow.position.x = 61
#Load new data
var save = ConfigFile.new()
save.load(str("user://file") + str(Game.current_file) + str(".pr"))
#Draw score and golds
high_score.text = str("%06d" % save.get_value(str(current_level),"High Score",0))
golds.text = str("%02d" % save.get_value(str(current_level),"Golds",0))
#Draw shards collected
shard0.visible = save.get_value(str(current_level),"Shard0",false)
shard1.visible = save.get_value(str(current_level),"Shard1",false)
shard2.visible = save.get_value(str(current_level),"Shard2",false)
shard3.visible = save.get_value(str(current_level),"Shard3",false)
shard4.visible = save.get_value(str(current_level),"Shard4",false)
shard5.visible = save.get_value(str(current_level),"Shard5",false)
shard6.visible = save.get_value(str(current_level),"Shard6",false)
shard7.visible = save.get_value(str(current_level),"Shard7",false)
shard8.visible = save.get_value(str(current_level),"Shard8",false)
shard9.visible = save.get_value(str(current_level),"Shard9",false)

218
maps/level_select.tscn Normal file
View file

@ -0,0 +1,218 @@
[gd_scene load_steps=12 format=2]
[ext_resource path="res://scripts/theme.tres" type="Theme" id=1]
[ext_resource path="res://graphics/hud/levelselect_border.png" type="Texture" id=2]
[ext_resource path="res://scripts/1px_border.gdshader" type="Shader" id=3]
[ext_resource path="res://graphics/hud/levelselect_arrow.png" type="Texture" id=4]
[ext_resource path="res://objects/collectibles/gold.tscn" type="PackedScene" id=5]
[ext_resource path="res://graphics/hud/levelselect_nexlevel.png" type="Texture" id=6]
[ext_resource path="res://maps/level_select.gd" type="Script" id=7]
[ext_resource path="res://graphics/collectibles/shard.png" type="Texture" id=8]
[ext_resource path="res://objects/collectibles/shard.tscn" type="PackedScene" id=9]
[sub_resource type="TileSet" id=1]
0/name = "levelselect_border.png 0"
0/texture = ExtResource( 2 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 0, 0, 24, 8 )
0/tile_mode = 2
0/autotile/icon_coordinate = Vector2( 0, 0 )
0/autotile/tile_size = Vector2( 8, 8 )
0/autotile/spacing = 0
0/autotile/occluder_map = [ ]
0/autotile/navpoly_map = [ ]
0/autotile/priority_map = [ ]
0/autotile/z_index_map = [ ]
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape_one_way = false
0/shape_one_way_margin = 0.0
0/shapes = [ ]
0/z_index = 0
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 3 )
shader_param/border_color = Color( 0, 0, 0, 1 )
shader_param/border_corners = false
[node name="LevelSelect" type="Node2D"]
script = ExtResource( 7 )
[node name="BackGround" type="ColorRect" parent="."]
margin_right = 256.0
margin_bottom = 192.0
color = Color( 0, 0, 0, 1 )
[node name="ColorRect2" type="ColorRect" parent="."]
margin_left = 43.0
margin_top = 48.0
margin_right = 213.0
margin_bottom = 144.0
color = Color( 0.239216, 0.239216, 0.443137, 1 )
[node name="Border" type="TileMap" parent="."]
tile_set = SubResource( 1 )
cell_size = Vector2( 8, 8 )
format = 1
tile_data = PoolIntArray( 327685, 0, 0, 327686, 536870912, 1, 327687, 0, 1, 327688, 0, 1, 327689, 0, 1, 327690, 0, 1, 327691, 0, 1, 327692, 0, 1, 327693, 0, 1, 327694, 0, 1, 327695, 0, 1, 327696, 0, 1, 327697, 0, 1, 327698, 0, 1, 327699, 0, 1, 327700, 0, 1, 327701, 0, 1, 327702, 0, 1, 327703, 0, 1, 327704, 0, 1, 327705, 0, 1, 327706, 536870912, 0, 393221, 1073741824, 2, 393242, 1610612736, 2, 458757, 1073741824, 2, 458778, 1610612736, 2, 524293, 1073741824, 2, 524314, 1610612736, 2, 589829, 1073741824, 2, 589850, 1610612736, 2, 655365, 1073741824, 2, 655386, 1610612736, 2, 720901, 1073741824, 2, 720922, 1610612736, 2, 786437, 1073741824, 2, 786458, 1610612736, 2, 851973, 1073741824, 2, 851994, 1610612736, 2, 917509, 1073741824, 2, 917530, 1610612736, 2, 983045, 1073741824, 2, 983066, 1610612736, 2, 1048581, 1073741824, 2, 1048602, 1610612736, 2, 1114117, 1073741824, 2, 1114138, 1610612736, 2, 1179653, 1073741824, 0, 1179654, 1073741824, 1, 1179655, 1610612736, 1, 1179656, 1610612736, 1, 1179657, 1610612736, 1, 1179658, 1610612736, 1, 1179659, 1610612736, 1, 1179660, 1610612736, 1, 1179661, 1610612736, 1, 1179662, 1610612736, 1, 1179663, 1610612736, 1, 1179664, 1610612736, 1, 1179665, 1610612736, 1, 1179666, 1610612736, 1, 1179667, 1610612736, 1, 1179668, 1610612736, 1, 1179669, 1610612736, 1, 1179670, 1610612736, 1, 1179671, 1610612736, 1, 1179672, 1610612736, 1, 1179673, 1073741824, 1, 1179674, 1610612736, 0 )
[node name="Title" type="Label" parent="."]
margin_left = 72.0
margin_top = 48.0
margin_right = 184.0
margin_bottom = 68.0
theme = ExtResource( 1 )
text = "test text"
align = 1
[node name="Golds" type="Label" parent="."]
margin_left = 120.0
margin_top = 88.0
margin_right = 136.0
margin_bottom = 108.0
theme = ExtResource( 1 )
text = "00"
align = 1
[node name="HighScoreText" type="Label" parent="."]
margin_left = 56.0
margin_top = 64.0
margin_right = 200.0
margin_bottom = 96.0
theme = ExtResource( 1 )
text = "High Score:"
align = 1
[node name="HighScore" type="Label" parent="."]
margin_left = 56.0
margin_top = 76.0
margin_right = 200.0
margin_bottom = 108.0
theme = ExtResource( 1 )
text = "000000"
align = 1
[node name="ShardTitle" type="Label" parent="."]
margin_left = 43.0
margin_top = 124.0
margin_right = 213.0
margin_bottom = 167.0
theme = ExtResource( 1 )
text = "Collect all coins
"
align = 1
[node name="ShardGraphics" type="Node2D" parent="."]
[node name="Shard11" type="Sprite" parent="ShardGraphics"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 2 )
position = Vector2( 61, 118 )
texture = ExtResource( 8 )
[node name="Shard12" type="Sprite" parent="ShardGraphics"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 2 )
position = Vector2( 76, 118 )
texture = ExtResource( 8 )
[node name="Shard13" type="Sprite" parent="ShardGraphics"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 2 )
position = Vector2( 91, 118 )
texture = ExtResource( 8 )
[node name="Shard14" type="Sprite" parent="ShardGraphics"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 2 )
position = Vector2( 106, 118 )
texture = ExtResource( 8 )
[node name="Shard15" type="Sprite" parent="ShardGraphics"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 2 )
position = Vector2( 121, 118 )
texture = ExtResource( 8 )
[node name="Shard16" type="Sprite" parent="ShardGraphics"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 2 )
position = Vector2( 136, 118 )
texture = ExtResource( 8 )
[node name="Shard17" type="Sprite" parent="ShardGraphics"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 2 )
position = Vector2( 151, 118 )
texture = ExtResource( 8 )
[node name="Shard18" type="Sprite" parent="ShardGraphics"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 2 )
position = Vector2( 166, 118 )
texture = ExtResource( 8 )
[node name="Shard19" type="Sprite" parent="ShardGraphics"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 2 )
position = Vector2( 181, 118 )
texture = ExtResource( 8 )
[node name="Shard20" type="Sprite" parent="ShardGraphics"]
modulate = Color( 0, 0, 0, 1 )
material = SubResource( 2 )
position = Vector2( 196, 118 )
texture = ExtResource( 8 )
[node name="Shard" parent="ShardGraphics" instance=ExtResource( 9 )]
position = Vector2( 56, 115 )
[node name="Shard2" parent="ShardGraphics" instance=ExtResource( 9 )]
position = Vector2( 71, 115 )
[node name="Shard3" parent="ShardGraphics" instance=ExtResource( 9 )]
position = Vector2( 86, 115 )
[node name="Shard4" parent="ShardGraphics" instance=ExtResource( 9 )]
position = Vector2( 101, 115 )
[node name="Shard5" parent="ShardGraphics" instance=ExtResource( 9 )]
position = Vector2( 116, 115 )
[node name="Shard6" parent="ShardGraphics" instance=ExtResource( 9 )]
position = Vector2( 131, 115 )
[node name="Shard7" parent="ShardGraphics" instance=ExtResource( 9 )]
position = Vector2( 146, 115 )
[node name="Shard8" parent="ShardGraphics" instance=ExtResource( 9 )]
position = Vector2( 161, 115 )
[node name="Shard9" parent="ShardGraphics" instance=ExtResource( 9 )]
position = Vector2( 176, 115 )
[node name="Shard10" parent="ShardGraphics" instance=ExtResource( 9 )]
position = Vector2( 191, 115 )
[node name="Gold" parent="." instance=ExtResource( 5 )]
position = Vector2( 111, 91 )
[node name="ShardArrow" type="Sprite" parent="."]
position = Vector2( 61, 106 )
texture = ExtResource( 4 )
[node name="LevelArrowUp" type="Sprite" parent="."]
visible = false
position = Vector2( 128, 40 )
texture = ExtResource( 6 )
region_enabled = true
region_rect = Rect2( 0, 0, 8, 8 )
[node name="LevelArrowDown" type="Sprite" parent="."]
position = Vector2( 128, 152 )
texture = ExtResource( 6 )
region_enabled = true
region_rect = Rect2( 8, 0, 8, 8 )

View file

@ -0,0 +1,9 @@
[gd_resource type="Resource" load_steps=2 format=2]
[ext_resource path="res://maps/leveldata/level_info.gd" type="Script" id=1]
[resource]
script = ExtResource( 1 )
level_title = "Level 0"
shard_title = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" ]
level_number = 0

View file

@ -0,0 +1,9 @@
[gd_resource type="Resource" load_steps=2 format=2]
[ext_resource path="res://maps/leveldata/level_info.gd" type="Script" id=1]
[resource]
script = ExtResource( 1 )
level_title = "Level 1"
shard_title = [ "Climb the big vine", "Next to the lone tree", "Slime's Treasure", "The snake pit", "5 Rainbow Stars", "All Shards + Beat 0:00", "Beat 000000 score", "Collect Everything", "Beat without dying", "No turning platforms" ]
level_number = 1

View file

@ -0,0 +1,5 @@
extends Resource
export var level_title = ""
export var shard_title = ["","","","","","","","","","",]
export var level_number = 0 #level number, used for saving not for level order

3
maps/leveldata/levels.gd Normal file
View file

@ -0,0 +1,3 @@
extends Resource
export var level = []

View file

@ -0,0 +1,9 @@
[gd_resource type="Resource" load_steps=4 format=2]
[ext_resource path="res://maps/leveldata/level1_info.tres" type="Resource" id=1]
[ext_resource path="res://maps/leveldata/levels.gd" type="Script" id=2]
[ext_resource path="res://maps/leveldata/level0_info.tres" type="Resource" id=3]
[resource]
script = ExtResource( 2 )
level = [ ExtResource( 3 ), ExtResource( 1 ) ]

View file

@ -2,3 +2,4 @@ extends Node2D
func _ready():
Game.play_sound(load("res://audio/music/rumble_loop.mp3"),Game.ac_music)
Game.current_level = 1

File diff suppressed because one or more lines are too long