Map unlocking and score saving

This commit is contained in:
2025-08-31 20:24:35 +02:00
parent e60c3d7b72
commit 2f9b0623f4
12 changed files with 228 additions and 41 deletions

BIN
Assets/Maps/map3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://fevwxt4ody3f"
path="res://.godot/imported/map3.png-6e489377317fd68e888f70d6181b1e29.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Maps/map3.png"
dest_files=["res://.godot/imported/map3.png-6e489377317fd68e888f70d6181b1e29.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
Assets/Others/lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

View File

@ -0,0 +1,30 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d0ja03ueuex75"
valid=false
[deps]
source_file="res://Assets/Others/lock.png"
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
Assets/Others/padlock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://djv5n53tndiig"
path="res://.godot/imported/padlock.png-a1cb69617d9764387292a49ec452bf21.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/Others/padlock.png"
dest_files=["res://.godot/imported/padlock.png-a1cb69617d9764387292a49ec452bf21.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -3,10 +3,10 @@ extends Node
var waves = [ var waves = [
[ [
[10, 0.2, 0.8, 0.2, 0.0], #wave 1 #First path [10, 0.2, 0.8, 0.2, 0.0], #wave 1 #First path
[20, 0.4, 0.5, 0.5, 0.0], #wave 2 #[20, 0.4, 0.5, 0.5, 0.0], #wave 2
[30, 0.5, 0.4, 0.4, 0.1], #wave 3 #[30, 0.5, 0.4, 0.4, 0.1], #wave 3
[40, 0.8, 0.3, 0.2, 0.5], #wave 4 #[40, 0.8, 0.3, 0.2, 0.5], #wave 4
[50, 0.9, 0.1, 0.2, 0.7], #wave 5 #[50, 0.9, 0.1, 0.2, 0.7], #wave 5
] ]
] ]

View File

@ -1574,11 +1574,9 @@ scale = Vector2(0.238927, 0.171569)
texture = ExtResource("110_fb8td") texture = ExtResource("110_fb8td")
[node name="Path2D" type="Path2D" parent="."] [node name="Path2D" type="Path2D" parent="."]
visible = false
curve = SubResource("Curve2D_6abe5") curve = SubResource("Curve2D_6abe5")
[node name="Path2D2" type="Path2D" parent="."] [node name="Path2D2" type="Path2D" parent="."]
visible = false
curve = SubResource("Curve2D_xx2jp") curve = SubResource("Curve2D_xx2jp")
[node name="Timer" type="Timer" parent="."] [node name="Timer" type="Timer" parent="."]
@ -1586,7 +1584,6 @@ wait_time = 0.4
autostart = true autostart = true
[node name="TrapArea" type="Area2D" parent="."] [node name="TrapArea" type="Area2D" parent="."]
visible = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="TrapArea"] [node name="CollisionShape2D" type="CollisionShape2D" parent="TrapArea"]
position = Vector2(435, 187.5) position = Vector2(435, 187.5)
@ -1604,7 +1601,6 @@ shape = SubResource("RectangleShape2D_h3dak")
debug_color = Color(0.798903, 0.0385002, 1, 0.42) debug_color = Color(0.798903, 0.0385002, 1, 0.42)
[node name="TowerArea" type="Area2D" parent="."] [node name="TowerArea" type="Area2D" parent="."]
visible = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="TowerArea"] [node name="CollisionShape2D" type="CollisionShape2D" parent="TowerArea"]
position = Vector2(587, 48) position = Vector2(587, 48)
@ -1629,7 +1625,6 @@ shape = SubResource("RectangleShape2D_sglle")
[node name="CanvasLayer" type="CanvasLayer" parent="."] [node name="CanvasLayer" type="CanvasLayer" parent="."]
[node name="SidePanel" parent="CanvasLayer" instance=ExtResource("111_2ej3d")] [node name="SidePanel" parent="CanvasLayer" instance=ExtResource("111_2ej3d")]
visible = false
size_flags_horizontal = 6 size_flags_horizontal = 6
[node name="MusicPlayer" parent="." instance=ExtResource("112_yc4f2")] [node name="MusicPlayer" parent="." instance=ExtResource("112_yc4f2")]

View File

@ -23,7 +23,21 @@ func _ready() -> void:
get_node("VBoxContainer/HBoxContainer/second/Button").connect("button_up", LoadMap2) get_node("VBoxContainer/HBoxContainer/second/Button").connect("button_up", LoadMap2)
get_node("VBoxContainer/HBoxContainer/third/Button").connect("button_up", LoadMap3) get_node("VBoxContainer/HBoxContainer/third/Button").connect("button_up", LoadMap3)
var unlocker = true
for i in get_node("VBoxContainer").get_children():
for ii in i.get_children():
if ii.get_node("Label2").text == "Haven't finished yet":
if unlocker:
unlocker = false
ii.get_node("Button").get_child(0).hide()
ii.get_node("Button").disabled = false
else:
ii.get_node("Button").get_child(0).show()
ii.get_node("Button").disabled = true
else:
ii.get_node("Button").get_child(0).hide()
ii.get_node("Button").disabled = false
func loadData() -> void: func loadData() -> void:
if FileAccess.file_exists(save_path): if FileAccess.file_exists(save_path):
@ -49,3 +63,8 @@ func save_scores():
if file: if file:
file.store_var(map_scores) file.store_var(map_scores)
file.close() file.close()
func _on_button_pressed() -> void:
get_tree().change_scene_to_file("res://Game/Menu/main.tscn")
pass # Replace with function body.

View File

@ -1,37 +1,48 @@
[gd_scene load_steps=19 format=3 uid="uid://cxet2lvdco2ak"] [gd_scene load_steps=20 format=3 uid="uid://cxet2lvdco2ak"]
[ext_resource type="Script" uid="uid://duhi4pfoa45j1" path="res://Game/Menu/mapselector.gd" id="1_cnef1"] [ext_resource type="Script" uid="uid://duhi4pfoa45j1" path="res://Game/Menu/mapselector.gd" id="1_cnef1"]
[ext_resource type="Texture2D" uid="uid://bgy114b67j3kg" path="res://Assets/Others/8-bit-graphics-pixels-scene-with-castle.jpg" id="1_jteil"] [ext_resource type="Texture2D" uid="uid://bgy114b67j3kg" path="res://Assets/Others/8-bit-graphics-pixels-scene-with-castle.jpg" id="1_jteil"]
[ext_resource type="FontFile" uid="uid://bu44ne346ymoe" path="res://Assets/Others/Canterbury.ttf" id="2_2uj2s"] [ext_resource type="FontFile" uid="uid://bu44ne346ymoe" path="res://Assets/Others/Canterbury.ttf" id="2_2uj2s"]
[ext_resource type="Texture2D" uid="uid://cheweipqa125e" path="res://Assets/Maps/map1.png" id="3_2uj2s"] [ext_resource type="Texture2D" uid="uid://cheweipqa125e" path="res://Assets/Maps/map1.png" id="3_2uj2s"]
[ext_resource type="Texture2D" uid="uid://dffphf4kn5sk2" path="res://Assets/Maps/map2.png" id="5_mjmwi"] [ext_resource type="Texture2D" uid="uid://dffphf4kn5sk2" path="res://Assets/Maps/map2.png" id="5_mjmwi"]
[ext_resource type="Texture2D" uid="uid://fevwxt4ody3f" path="res://Assets/Maps/map3.png" id="6_5yqcp"]
[ext_resource type="Texture2D" uid="uid://djv5n53tndiig" path="res://Assets/Others/padlock.png" id="6_udeaf"]
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_cnef1"] [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_cnef1"]
texture = ExtResource("1_jteil") texture = ExtResource("1_jteil")
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_mjmwi"] [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_cg1t8"]
texture = ExtResource("3_2uj2s")
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_udeaf"]
texture = ExtResource("3_2uj2s") texture = ExtResource("3_2uj2s")
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_5yqcp"] [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_5yqcp"]
texture = ExtResource("3_2uj2s") texture = ExtResource("3_2uj2s")
texture_margin_left = 5.0
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_cg1t8"] texture_margin_top = 5.0
texture = ExtResource("3_2uj2s") texture_margin_right = 5.0
texture_margin_bottom = 5.0
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_losb8"]
texture = ExtResource("5_mjmwi")
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_rjq3w"] [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_rjq3w"]
texture = ExtResource("5_mjmwi") texture = ExtResource("5_mjmwi")
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_uvrvw"] [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_uvrvw"]
texture = ExtResource("5_mjmwi") texture = ExtResource("5_mjmwi")
texture_margin_left = 5.0
texture_margin_top = 5.0
texture_margin_right = 5.0
texture_margin_bottom = 5.0
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_hmthg"]
texture = ExtResource("5_mjmwi")
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_44oc2"] [sub_resource type="StyleBoxTexture" id="StyleBoxTexture_44oc2"]
texture = ExtResource("5_mjmwi") texture = ExtResource("6_5yqcp")
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_losb8"]
texture = ExtResource("6_5yqcp")
texture_margin_left = 5.0
texture_margin_top = 5.0
texture_margin_right = 5.0
texture_margin_bottom = 5.0
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_cnef1"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_cnef1"]
@ -130,11 +141,25 @@ text = "1st Level"
[node name="Button" type="Button" parent="VBoxContainer/HBoxContainer/first"] [node name="Button" type="Button" parent="VBoxContainer/HBoxContainer/first"]
custom_minimum_size = Vector2(120, 80) custom_minimum_size = Vector2(120, 80)
layout_mode = 2 layout_mode = 2
theme_override_styles/focus = SubResource("StyleBoxTexture_mjmwi") theme_override_styles/disabled = SubResource("StyleBoxTexture_cg1t8")
theme_override_styles/hover = SubResource("StyleBoxTexture_udeaf") theme_override_styles/hover = SubResource("StyleBoxTexture_5yqcp")
theme_override_styles/pressed = SubResource("StyleBoxTexture_5yqcp")
theme_override_styles/normal = SubResource("StyleBoxTexture_cg1t8") theme_override_styles/normal = SubResource("StyleBoxTexture_cg1t8")
[node name="TextureRect" type="TextureRect" parent="VBoxContainer/HBoxContainer/first/Button"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("6_udeaf")
[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/first"] [node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/first"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 4 size_flags_horizontal = 4
@ -152,10 +177,24 @@ text = "2nd Level"
[node name="Button" type="Button" parent="VBoxContainer/HBoxContainer/second"] [node name="Button" type="Button" parent="VBoxContainer/HBoxContainer/second"]
custom_minimum_size = Vector2(120, 80) custom_minimum_size = Vector2(120, 80)
layout_mode = 2 layout_mode = 2
theme_override_styles/focus = SubResource("StyleBoxTexture_losb8") theme_override_styles/disabled = SubResource("StyleBoxTexture_rjq3w")
theme_override_styles/hover = SubResource("StyleBoxTexture_rjq3w") theme_override_styles/hover = SubResource("StyleBoxTexture_uvrvw")
theme_override_styles/pressed = SubResource("StyleBoxTexture_uvrvw") theme_override_styles/normal = SubResource("StyleBoxTexture_hmthg")
theme_override_styles/normal = SubResource("StyleBoxTexture_44oc2")
[node name="TextureRect" type="TextureRect" parent="VBoxContainer/HBoxContainer/second/Button"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("6_udeaf")
[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/second"] [node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/second"]
layout_mode = 2 layout_mode = 2
@ -174,11 +213,25 @@ text = "3rd Level"
[node name="Button" type="Button" parent="VBoxContainer/HBoxContainer/third"] [node name="Button" type="Button" parent="VBoxContainer/HBoxContainer/third"]
custom_minimum_size = Vector2(120, 80) custom_minimum_size = Vector2(120, 80)
layout_mode = 2 layout_mode = 2
theme_override_styles/focus = SubResource("StyleBoxTexture_losb8") theme_override_styles/disabled = SubResource("StyleBoxTexture_44oc2")
theme_override_styles/hover = SubResource("StyleBoxTexture_rjq3w") theme_override_styles/hover = SubResource("StyleBoxTexture_losb8")
theme_override_styles/pressed = SubResource("StyleBoxTexture_uvrvw")
theme_override_styles/normal = SubResource("StyleBoxTexture_44oc2") theme_override_styles/normal = SubResource("StyleBoxTexture_44oc2")
[node name="TextureRect" type="TextureRect" parent="VBoxContainer/HBoxContainer/third/Button"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("6_udeaf")
[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/third"] [node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/third"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 4 size_flags_horizontal = 4

View File

@ -195,15 +195,33 @@ func GameOver() -> void:
get_node("GameOverAudio").play() get_node("GameOverAudio").play()
func GameWon() -> void: func GameWon() -> void:
get_node("Panel").hide() get_node("Panel").hide()
get_node("GameWon").show() get_node("GameWon").show()
map_scores[get_parent().get_parent().name] = int((lives / originallives) *10) var map_name = get_parent().get_parent().name
var file = FileAccess.open(save_path, FileAccess.WRITE) var new_score = int((lives / originallives) * 10)
file.store_var(map_scores)
var file
var old_scores = {}
# Try to load old scores if file exists
if FileAccess.file_exists(save_path):
file = FileAccess.open(save_path, FileAccess.READ)
if not file.eof_reached():
old_scores = file.get_var()
file.close() file.close()
get_parent().get_parent().get_node("MusicPlayer").PauseAudio()
get_node("VictoryAudio").play() var old_score = old_scores.get(map_name, 0)
if new_score > old_score:
old_scores[map_name] = new_score
file = FileAccess.open(save_path, FileAccess.WRITE)
file.store_var(old_scores)
file.close()
get_parent().get_parent().get_node("MusicPlayer").PauseAudio()
get_node("VictoryAudio").play()
func _on_button_3_pressed() -> void: func _on_button_3_pressed() -> void:
get_node("pausemenu").hide() get_node("pausemenu").hide()

View File

@ -72,7 +72,11 @@ shadow_size = 5
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_s7jra"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_s7jra"]
bg_color = Color(0.6, 0.6, 0.6, 0.392157) bg_color = Color(0.6, 0.6, 0.6, 0.392157)
border_color = Color(0, 0, 0, 1) border_width_left = 20
border_width_top = 20
border_width_right = 20
border_width_bottom = 20
border_color = Color(0.6, 0.6, 0.6, 0.392157)
corner_radius_top_left = 20 corner_radius_top_left = 20
corner_radius_top_right = 20 corner_radius_top_right = 20
corner_radius_bottom_right = 20 corner_radius_bottom_right = 20