mirror of
https://github.com/HarmonyHoney/tiny_crate.git
synced 2026-08-01 20:12:44 +00:00
more messy work, stage save data WIP
This commit is contained in:
parent
6f9529ca7a
commit
cbeeacdf98
13 changed files with 70 additions and 32 deletions
|
|
@ -136,6 +136,7 @@ func _process(delta):
|
|||
node_anim.play("box_jump")
|
||||
else:
|
||||
node_anim.play("jump")
|
||||
Shared.stage.metric_jump += 1
|
||||
|
||||
# jump height
|
||||
if is_jump:
|
||||
|
|
@ -219,6 +220,8 @@ func box_pickup(dx := 0, dy := 0):
|
|||
pickup_box.is_moving = false
|
||||
pickup_box.is_solid = false
|
||||
pickup_start = pickup_box.position
|
||||
|
||||
Shared.stage.metric_pickup += 1
|
||||
break
|
||||
|
||||
# ox, oy = offset x and y
|
||||
|
|
@ -244,7 +247,8 @@ func death():
|
|||
Shared.start_reset()
|
||||
queue_free()
|
||||
dev.out(name + " died")
|
||||
Shared.death()
|
||||
Shared.stage.death()
|
||||
#Shared.death()
|
||||
|
||||
func win():
|
||||
# explosion
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ var is_clear = false
|
|||
var _window_scale := 1.0
|
||||
var map_name := "hub"
|
||||
var hub_pos := Vector2(-16, -16)
|
||||
var death_count := 0
|
||||
#var death_count := 0
|
||||
|
||||
var stage_data := []
|
||||
var save_file := "box.save"
|
||||
|
|
@ -65,31 +65,35 @@ func do_reset():
|
|||
dev.out("loading scene: " + "res://Map/" + map_name + ".tscn")
|
||||
get_tree().change_scene("res://Map/" + map_name + ".tscn")
|
||||
|
||||
func death():
|
||||
death_count += 1
|
||||
HUD.node_death.text = "deaths: " + str(death_count)
|
||||
#func death():
|
||||
# death_count += 1
|
||||
# HUD.node_death.text = "deaths: " + str(death_count)
|
||||
|
||||
func win():
|
||||
if stage:
|
||||
stage.stop_timer()
|
||||
|
||||
var new_data = {
|
||||
"name": stage.stage_name,
|
||||
"time": stage.timer,
|
||||
"death": death_count,
|
||||
"file": stage.filename,
|
||||
"name": stage.stage_name,
|
||||
"complete": stage.is_complete,
|
||||
"time": stage.timer,
|
||||
"death": stage.metric_death,
|
||||
"jump": stage.metric_jump,
|
||||
"pickup": stage.metric_pickup,
|
||||
}
|
||||
|
||||
for i in stage_data:
|
||||
if i["name"] == new_data["name"]:
|
||||
if i["file"] == new_data["file"]:
|
||||
stage_data.erase(i)
|
||||
break
|
||||
stage_data.append(new_data)
|
||||
|
||||
save_data(save_file, JSON.print(stage_data, "\t"))
|
||||
dev.out("(box.save)")
|
||||
dev.out(load_data(save_file))
|
||||
#dev.out("(box.save)")
|
||||
#dev.out(load_data(save_file))
|
||||
|
||||
death_count = 0
|
||||
#death_count = 0
|
||||
|
||||
func save_data(save_file, arg):
|
||||
var file = File.new()
|
||||
|
|
|
|||
|
|
@ -19,23 +19,34 @@ func _ready():
|
|||
maps.append_array(map_list.split("\n", false))
|
||||
label_list.text = map_list
|
||||
|
||||
scroll()
|
||||
|
||||
func _process(delta):
|
||||
var btny = btn.p("down") - btn.p("up")
|
||||
if btny:
|
||||
cursor = clamp(cursor + btny, 0, maps.size() - 1)
|
||||
label_list.rect_position.y = 90 - (cursor * line_height)
|
||||
label_info.text = str(cursor) + " / " + maps[cursor] + "\n"
|
||||
|
||||
for i in Shared.stage_data:
|
||||
if i.has("file") and i.file == "res://Map/" + maps[cursor] + ".tscn":
|
||||
label_info.text += "name: " + str(i.name) + "\n"
|
||||
label_info.text += "file: " + str(i.file) + "\n"
|
||||
label_info.text += "time: " + str(i.time) + "\n"
|
||||
label_info.text += "deaths: " + str(i.death) + "\n"
|
||||
break
|
||||
scroll(btny)
|
||||
|
||||
if btn.p("action"):
|
||||
Shared.map_name = maps[cursor]
|
||||
get_tree().change_scene("res://Map/" + maps[cursor] + ".tscn")
|
||||
|
||||
|
||||
func scroll(arg = 0):
|
||||
cursor = clamp(cursor + arg, 0, maps.size() - 1)
|
||||
label_list.rect_position.y = 90 - (cursor * line_height)
|
||||
label_info.text = str(cursor) + " / " + maps[cursor] + "\n"
|
||||
|
||||
|
||||
for i in Shared.stage_data:
|
||||
if i.has("file") and i.file == "res://Map/" + maps[cursor] + ".tscn":
|
||||
label_info.text += "file: " + str(i.file) + "\n"
|
||||
if i.has("complete"):
|
||||
label_info.text += "complete: " + str(i.complete) + "\n"
|
||||
label_info.text += "name: " + str(i.name) + "\n"
|
||||
label_info.text += "time: " + str(i.time) + "\n"
|
||||
label_info.text += "deaths: " + str(i.death) + "\n"
|
||||
if i.has("pickup") and i.has("jump"):
|
||||
label_info.text += "boxes picked up: " + str(i.pickup) + "\n"
|
||||
label_info.text += "jumps: " + str(i.jump) + "\n"
|
||||
break
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,19 @@ export var stage_name := "1-1"
|
|||
|
||||
var timer := 0.0
|
||||
var is_timer = true
|
||||
var metric_pickup := 0
|
||||
var metric_jump := 0
|
||||
var metric_death := 0
|
||||
var is_complete = false
|
||||
|
||||
func _ready():
|
||||
Shared.stage = self
|
||||
|
||||
|
||||
for i in Shared.stage_data:
|
||||
if i.file == filename:
|
||||
if i.has("death"):
|
||||
metric_death = i.death
|
||||
|
||||
func _process(delta):
|
||||
if is_timer:
|
||||
|
|
@ -16,3 +26,8 @@ func _process(delta):
|
|||
|
||||
func stop_timer():
|
||||
is_timer = false
|
||||
|
||||
func death():
|
||||
metric_death += 1
|
||||
Shared.save_file
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue