Add visual indicator for used slots, reset player position to the middle of slot platform on slot reset
This commit is contained in:
parent
c6b91c31f2
commit
4f96c1f0a3
2 changed files with 14 additions and 1 deletions
|
@ -75,6 +75,9 @@ func reset_slot(idx: int):
|
||||||
if FileAccess.file_exists(slot_path):
|
if FileAccess.file_exists(slot_path):
|
||||||
DirAccess.remove_absolute(slot_path)
|
DirAccess.remove_absolute(slot_path)
|
||||||
|
|
||||||
|
func is_slot_used(idx: int):
|
||||||
|
return FileAccess.file_exists("user://slot%s.save" % idx)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
func quit(code: int):
|
func quit(code: int):
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
|
const COLOR_NORMAL = Color.DARK_SLATE_GRAY
|
||||||
|
const COLOR_USED = Color.WHITE
|
||||||
|
|
||||||
@export var slot_idx: int
|
@export var slot_idx: int
|
||||||
@export var slot_label: String = ""
|
@export var slot_label: String = ""
|
||||||
|
|
||||||
|
func update_color():
|
||||||
|
if Gamestate.is_slot_used(slot_idx):
|
||||||
|
$StaticBody2D/platform.color = COLOR_USED
|
||||||
|
else:
|
||||||
|
$StaticBody2D/platform.color = COLOR_NORMAL
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$Label.text = str(slot_label)
|
$Label.text = str(slot_label)
|
||||||
|
update_color()
|
||||||
|
|
||||||
func _on_area_2d_load_body_entered(body: Node2D) -> void:
|
func _on_area_2d_load_body_entered(body: Node2D) -> void:
|
||||||
# load slot & start game
|
# load slot & start game
|
||||||
|
@ -18,4 +27,5 @@ func _on_area_2d_delete_body_entered(body: Node2D) -> void:
|
||||||
# reset slot on disk
|
# reset slot on disk
|
||||||
if body == NodeRegistry.player:
|
if body == NodeRegistry.player:
|
||||||
Gamestate.reset_slot(slot_idx)
|
Gamestate.reset_slot(slot_idx)
|
||||||
NodeRegistry.player.position = Levels.mainmenu_player_pos
|
update_color()
|
||||||
|
NodeRegistry.player.position = self.global_position - Vector2(0, 32)
|
||||||
|
|
Reference in a new issue