Second Map, and sound effects
This commit is contained in:
@ -9,26 +9,34 @@ func _on_button_pressed() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_button_map1_pressed() -> void:
|
||||
func LoadMap1() -> void:
|
||||
get_tree().change_scene_to_file("res://Game/Maps/map_1.tscn")
|
||||
pass # Replace with function body.
|
||||
|
||||
func LoadMap2() -> void:
|
||||
get_tree().change_scene_to_file("res://Game/Maps/map_2.tscn")
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
loadData()
|
||||
get_node("VBoxContainer/HBoxContainer/first/Button").connect("button_up", LoadMap1)
|
||||
get_node("VBoxContainer/HBoxContainer/second/Button").connect("button_up", LoadMap2)
|
||||
|
||||
|
||||
|
||||
func loadData() -> void:
|
||||
if FileAccess.file_exists(save_path):
|
||||
var file = FileAccess.open(save_path, FileAccess.READ)
|
||||
if file:
|
||||
map_scores = file.get_var()
|
||||
file.close()
|
||||
get_node("VBoxContainer/HBoxContainer/first/Label2").text = "Haven't played yet" if map_scores["Map1"] == 0 else "Scored: " + str(map_scores["Map1"]) + " out of 10"
|
||||
print(map_scores)
|
||||
get_node("VBoxContainer/HBoxContainer/first/Label2").text = "Haven't finished yet" if map_scores["Map1"] == 0 else "Scored: " + str(map_scores["Map1"]) + " out of 10"
|
||||
get_node("VBoxContainer/HBoxContainer/second/Label2").text = "Haven't finished yet" if map_scores["Map2"] == 0 else "Scored: " + str(map_scores["Map2"]) + " out of 10"
|
||||
|
||||
else:
|
||||
map_scores["Map1"] = 0
|
||||
map_scores["Map2"] = 0
|
||||
|
||||
save_scores()
|
||||
loadData()
|
||||
|
@ -127,6 +127,28 @@ layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Score: 10 / "
|
||||
|
||||
[node name="second" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer/second"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "2nd Level"
|
||||
|
||||
[node name="Button" type="Button" parent="VBoxContainer/HBoxContainer/second"]
|
||||
custom_minimum_size = Vector2(120, 80)
|
||||
layout_mode = 2
|
||||
theme_override_styles/focus = SubResource("StyleBoxTexture_mjmwi")
|
||||
theme_override_styles/hover = SubResource("StyleBoxTexture_udeaf")
|
||||
theme_override_styles/pressed = SubResource("StyleBoxTexture_5yqcp")
|
||||
theme_override_styles/normal = SubResource("StyleBoxTexture_cg1t8")
|
||||
|
||||
[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/second"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
text = "Score: 10 / "
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 12
|
||||
|
Reference in New Issue
Block a user