re-written save and level data system :)
This commit is contained in:
parent
f3debf74cf
commit
45ddbd5c04
13 changed files with 177 additions and 93 deletions
|
@ -29,7 +29,6 @@ extents = Vector2( 4, 128 )
|
|||
[node name="Map" type="Node2D" groups=["map"]]
|
||||
pause_mode = 1
|
||||
script = ExtResource( 2 )
|
||||
save_location = 2
|
||||
music = ExtResource( 22 )
|
||||
|
||||
[node name="Camera2D" parent="." instance=ExtResource( 1 )]
|
||||
|
|
|
@ -31,7 +31,6 @@ extents = Vector2( 4, 96 )
|
|||
[node name="Map2" type="Node2D" groups=["map"]]
|
||||
pause_mode = 1
|
||||
script = ExtResource( 11 )
|
||||
save_location = 2
|
||||
music = ExtResource( 12 )
|
||||
|
||||
[node name="Camera2D" parent="." instance=ExtResource( 6 )]
|
||||
|
|
|
@ -1,27 +1,25 @@
|
|||
extends Node2D
|
||||
|
||||
##Onreadys
|
||||
onready var levels = preload("res://maps/leveldata/levels.tres")
|
||||
#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 high_score_any = $HighScoreAny
|
||||
onready var high_score_100 = $HighScore100
|
||||
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
|
||||
onready var shards = [
|
||||
$ShardGraphics/Shard,
|
||||
$ShardGraphics/Shard2,
|
||||
$ShardGraphics/Shard3,
|
||||
$ShardGraphics/Shard4,
|
||||
$ShardGraphics/Shard5,
|
||||
$ShardGraphics/Shard6,
|
||||
$ShardGraphics/Shard7,
|
||||
$ShardGraphics/Shard8
|
||||
]
|
||||
##Runtime
|
||||
var save = 0
|
||||
var current_level = 0
|
||||
|
@ -29,20 +27,24 @@ var current_shard = 0
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
change_current_level(1)
|
||||
change_current_level(0)
|
||||
Game.ac_music.stop()
|
||||
|
||||
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)
|
||||
# get current level's data
|
||||
var level = LevelData.levels[current_level]
|
||||
#Draw level title
|
||||
title.text = levels.level[current_level].level_title
|
||||
title.text = level.title
|
||||
#Draw Shard Title
|
||||
shard_title.text = levels.level[current_level].shard_title[current_shard]
|
||||
shard_title.text = level.shard_titles[current_shard]
|
||||
#Select level
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
Game.change_map(levels.level[current_level].scene)
|
||||
Game.current_level = current_level
|
||||
Game.change_map(level.scene)
|
||||
|
||||
func change_current_shard(amount):
|
||||
if current_shard + amount != -1 && current_shard + amount != 8: #Check if in range
|
||||
|
@ -51,13 +53,13 @@ func change_current_shard(amount):
|
|||
|
||||
func change_current_level(amount):
|
||||
#Change level
|
||||
if current_level + amount != 0 && current_level + amount != levels.level.size(): #Check if in range
|
||||
if current_level + amount >= 0 && current_level + amount < LevelData.levels.size(): #Check if in range
|
||||
current_level += amount
|
||||
#Show arrows or don't
|
||||
if current_level == 1:
|
||||
if current_level == 0:
|
||||
levelarrow_up.visible = false
|
||||
levelarrow_down.visible = true
|
||||
elif current_level == levels.level.size() - 1:
|
||||
elif current_level == LevelData.levels.size() - 1:
|
||||
levelarrow_up.visible = true
|
||||
levelarrow_down.visible = false
|
||||
else:
|
||||
|
@ -67,23 +69,18 @@ func change_current_level(amount):
|
|||
current_shard = 0
|
||||
shard_arrow.position.x = 76
|
||||
#Load new data
|
||||
var save = ConfigFile.new()
|
||||
save.load(str("user://file") + str(Game.current_file) + str(".pr"))
|
||||
var str_level = str(current_level)
|
||||
#Draw score and golds
|
||||
# high_score.text = str("%04d" % save.get_value(str_level,"High Score",0))
|
||||
# golds.text = str("%02d" % save.get_value(str_level,"Golds",0))
|
||||
#Draw High Scores
|
||||
high_score_any.text = "Any%\n" + str("%05d" % save.get_value(str_level,"Any% High Score",0)) + "\n" + str(Game.timeify(save.get_value(str_level,"Any% Time",0)))
|
||||
high_score_100.text = "100%\n" + str("%05d" % save.get_value(str_level,"100% High Score",0)) + "\n" + str(Game.timeify(save.get_value(str_level,"100% Time",0)))
|
||||
#Draw shards collected
|
||||
shard0.visible = save.get_value(str_level,"Shard0",false)
|
||||
shard1.visible = save.get_value(str_level,"Shard1",false)
|
||||
shard2.visible = save.get_value(str_level,"Shard2",false)
|
||||
shard3.visible = save.get_value(str_level,"Shard3",false)
|
||||
shard4.visible = save.get_value(str_level,"Shard4",false)
|
||||
shard5.visible = save.get_value(str_level,"Shard5",false)
|
||||
shard6.visible = save.get_value(str_level,"Shard6",false)
|
||||
shard7.visible = save.get_value(str_level,"Shard7",false)
|
||||
shard8.visible = save.get_value(str_level,"Shard8",false)
|
||||
shard9.visible = save.get_value(str_level,"Shard9",false)
|
||||
var save_id = LevelData.levels[current_level].save_id
|
||||
var save_data = Save.get_level_data(save_id)
|
||||
# set any% scores
|
||||
high_score_any.text = "Any%%\n%05d\n%s" % [
|
||||
save_data.score_any,
|
||||
Game.timeify(save_data.time_any)
|
||||
]
|
||||
# set 100% scores
|
||||
high_score_100.text = "100%%\n%05d\n%s" % [
|
||||
save_data.score_100,
|
||||
Game.timeify(save_data.time_100)
|
||||
]
|
||||
# set collected shards
|
||||
for i in 8:
|
||||
shards[i].visible = save_data.shards[i]
|
||||
|
|
|
@ -46,16 +46,6 @@ text = "test text
|
|||
"
|
||||
align = 1
|
||||
|
||||
[node name="Golds" type="Label" parent="."]
|
||||
visible = false
|
||||
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 = 62.0
|
||||
|
@ -91,16 +81,6 @@ text = "100%
|
|||
"
|
||||
align = 1
|
||||
|
||||
[node name="HighScore" type="Label" parent="."]
|
||||
visible = false
|
||||
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 = 130.0
|
||||
|
@ -177,37 +157,37 @@ position = Vector2( 196, 118 )
|
|||
texture = ExtResource( 8 )
|
||||
|
||||
[node name="Shard" parent="ShardGraphics" instance=ExtResource( 9 )]
|
||||
visible = false
|
||||
position = Vector2( 71, 115 )
|
||||
|
||||
[node name="Shard2" parent="ShardGraphics" instance=ExtResource( 9 )]
|
||||
visible = false
|
||||
position = Vector2( 86, 115 )
|
||||
|
||||
[node name="Shard3" parent="ShardGraphics" instance=ExtResource( 9 )]
|
||||
visible = false
|
||||
position = Vector2( 101, 115 )
|
||||
|
||||
[node name="Shard4" parent="ShardGraphics" instance=ExtResource( 9 )]
|
||||
visible = false
|
||||
position = Vector2( 116, 115 )
|
||||
|
||||
[node name="Shard5" parent="ShardGraphics" instance=ExtResource( 9 )]
|
||||
visible = false
|
||||
position = Vector2( 131, 115 )
|
||||
|
||||
[node name="Shard6" parent="ShardGraphics" instance=ExtResource( 9 )]
|
||||
visible = false
|
||||
position = Vector2( 146, 115 )
|
||||
|
||||
[node name="Shard7" parent="ShardGraphics" instance=ExtResource( 9 )]
|
||||
visible = false
|
||||
position = Vector2( 161, 115 )
|
||||
|
||||
[node name="Shard8" parent="ShardGraphics" instance=ExtResource( 9 )]
|
||||
position = Vector2( 176, 115 )
|
||||
|
||||
[node name="Shard9" parent="ShardGraphics" instance=ExtResource( 9 )]
|
||||
visible = false
|
||||
position = Vector2( 176, 115 )
|
||||
|
||||
[node name="Shard10" parent="ShardGraphics" instance=ExtResource( 9 )]
|
||||
visible = false
|
||||
position = Vector2( 191, 115 )
|
||||
|
||||
[node name="Gold" parent="." instance=ExtResource( 5 )]
|
||||
visible = false
|
||||
position = Vector2( 111, 91 )
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
extends Node2D
|
||||
export var target_time_any = 0
|
||||
export var target_time_100 = 0
|
||||
export var save_location = 0
|
||||
export (AudioStream) var music
|
||||
|
||||
#Bonuses
|
||||
|
@ -11,7 +10,6 @@ var collectible_bonus = false
|
|||
|
||||
func _ready():
|
||||
Game.play_sound(music,Game.ac_music)
|
||||
Game.current_level = save_location
|
||||
|
||||
func _physics_process(delta):
|
||||
if Game.golds == 50 && Game.shards == 5:
|
||||
|
|
|
@ -29,7 +29,6 @@ pause_mode = 1
|
|||
script = ExtResource( 18 )
|
||||
target_time_any = 70
|
||||
target_time_100 = 180
|
||||
save_location = 1
|
||||
music = ExtResource( 19 )
|
||||
|
||||
[node name="Camera2D" parent="." instance=ExtResource( 8 )]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue