From 635e191d0a4f8f705c8a43b47f43e13b93b58348 Mon Sep 17 00:00:00 2001 From: BardicSoulkeeper <164677640+BardicSoulkeeper@users.noreply.github.com> Date: Tue, 29 Jul 2025 20:50:29 -0600 Subject: [PATCH] EndScreen First I zoomed the camera out a little, and then I created an End menu to show how many crystals the player collected, how many enemies died, and how many levels the player made it to. The level counting is not connected anywhere yet since I don't know where the level changing script it. Also, this scene is not yet connected. The button to go back to title screen is connected though. --- resources/text_overlay.tres | 2 +- scenes/enemies/enemy.gd | 1 + scenes/globals.gd | 4 ++ scenes/hero.tscn | 36 +++++----- scenes/utility/end_screen.gd | 18 +++++ scenes/utility/end_screen.gd.uid | 1 + scenes/utility/end_screen.tscn | 106 ++++++++++++++++++++++++++++ scenes/utility/menu.tscn | 12 +--- scenes/utility/menu_theme_blue.tres | 9 +++ scenes/utility/text_overlay.tscn | 4 +- 10 files changed, 163 insertions(+), 30 deletions(-) create mode 100644 scenes/utility/end_screen.gd create mode 100644 scenes/utility/end_screen.gd.uid create mode 100644 scenes/utility/end_screen.tscn create mode 100644 scenes/utility/menu_theme_blue.tres diff --git a/resources/text_overlay.tres b/resources/text_overlay.tres index b7d9168..927ad6e 100644 --- a/resources/text_overlay.tres +++ b/resources/text_overlay.tres @@ -4,4 +4,4 @@ [resource] font = ExtResource("1_0pp1u") -font_size = 32 +font_size = 28 diff --git a/scenes/enemies/enemy.gd b/scenes/enemies/enemy.gd index e1d26ee..1a9833e 100644 --- a/scenes/enemies/enemy.gd +++ b/scenes/enemies/enemy.gd @@ -116,6 +116,7 @@ func switch_state(state_enum) -> void: state = PURSUIT speed = pursuit_speed DEAD: + Globals.enemies_killed += 1 state = DEAD speed = 0 navigating = false diff --git a/scenes/globals.gd b/scenes/globals.gd index ef687ea..94cf789 100644 --- a/scenes/globals.gd +++ b/scenes/globals.gd @@ -13,6 +13,8 @@ var player_health: int = 100 var player_max_health: int = 100 var player_armor: int = 0 var player_max_armor: int = 100 +var crystals_collected: int = 0 +var enemies_killed: int = 0 func player_invulnerable_timer(): await get_tree().create_timer(0.5).timeout @@ -23,6 +25,8 @@ func add_screenshake(amount: float): func collectable_collected(type: String) -> void: collected.emit(type) + if type == "crystal": + crystals_collected += 1 func place_acid_aoe(position: Vector2, scaling: float) -> void: acid_aoe.emit(position, scaling) diff --git a/scenes/hero.tscn b/scenes/hero.tscn index 4073c06..3df67c9 100644 --- a/scenes/hero.tscn +++ b/scenes/hero.tscn @@ -25,10 +25,8 @@ height = 116.0 [sub_resource type="Environment" id="Environment_n40cg"] glow_enabled = true -[sub_resource type="Animation" id="Animation_n40cg"] -resource_name = "hit" -length = 0.2 -step = 0.05 +[sub_resource type="Animation" id="Animation_txblw"] +length = 0.001 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -36,10 +34,10 @@ tracks/0/path = NodePath("Sprite2D:material:shader_parameter/flash_active") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { -"times": PackedFloat32Array(0, 0.100339, 0.2), -"transitions": PackedFloat32Array(1, 1, 1), +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), "update": 1, -"values": [true, false, false] +"values": [false] } tracks/1/type = "value" tracks/1/imported = false @@ -54,8 +52,10 @@ tracks/1/keys = { "values": [Color(1, 1, 1, 1)] } -[sub_resource type="Animation" id="Animation_txblw"] -length = 0.001 +[sub_resource type="Animation" id="Animation_d6xj2"] +resource_name = "acidic" +length = 0.2 +step = 0.05 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -63,10 +63,10 @@ tracks/0/path = NodePath("Sprite2D:material:shader_parameter/flash_active") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), +"times": PackedFloat32Array(0, 0.1, 0.2), +"transitions": PackedFloat32Array(1, 1, 1), "update": 1, -"values": [false] +"values": [true, false, false] } tracks/1/type = "value" tracks/1/imported = false @@ -78,7 +78,7 @@ tracks/1/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 0, -"values": [Color(1, 1, 1, 1)] +"values": [Color(0, 0.659891, 0.178913, 1)] } [sub_resource type="Animation" id="Animation_n5qna"] @@ -110,8 +110,8 @@ tracks/1/keys = { "values": [Color(1, 0.298039, 0, 1)] } -[sub_resource type="Animation" id="Animation_d6xj2"] -resource_name = "acidic" +[sub_resource type="Animation" id="Animation_n40cg"] +resource_name = "hit" length = 0.2 step = 0.05 tracks/0/type = "value" @@ -121,7 +121,7 @@ tracks/0/path = NodePath("Sprite2D:material:shader_parameter/flash_active") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { -"times": PackedFloat32Array(0, 0.1, 0.2), +"times": PackedFloat32Array(0, 0.100339, 0.2), "transitions": PackedFloat32Array(1, 1, 1), "update": 1, "values": [true, false, false] @@ -136,7 +136,7 @@ tracks/1/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 0, -"values": [Color(0, 0.659891, 0.178913, 1)] +"values": [Color(1, 1, 1, 1)] } [sub_resource type="AnimationLibrary" id="AnimationLibrary_n5qna"] @@ -172,7 +172,7 @@ horizontal_alignment = 1 [node name="Camera2D" type="Camera2D" parent="."] offset = Vector2(25, 15) -zoom = Vector2(0.8, 0.8) +zoom = Vector2(0.7, 0.7) script = ExtResource("3_mo806") [node name="PlasmaRifle" parent="." instance=ExtResource("3_06baw")] diff --git a/scenes/utility/end_screen.gd b/scenes/utility/end_screen.gd new file mode 100644 index 0000000..9bafefd --- /dev/null +++ b/scenes/utility/end_screen.gd @@ -0,0 +1,18 @@ +extends Control + +@onready var TitleScreenButton: Button = $MarginContainer/VBoxContainer/TitleScreenButton +@onready var RestartButton: Button = $MarginContainer/VBoxContainer/RestartButton + +# Called when the node enters the scene tree for the first time. +func _ready(): + $MarginContainer/VBoxContainer/HBoxContainer/BugsKilledLabel.text = str(Globals.enemies_killed) + $MarginContainer/VBoxContainer/HBoxContainer2/CrystalsCollectedLabel.text = str(Globals.crystals_collected) + + + +func _on_title_screen_button_pressed(): + get_tree().change_scene_to_file("res://scenes/utility/title.tscn") + + +func _on_restart_button_pressed(): + get_tree().change_scene_to_file("res://scenes/levels/level1.tscn") diff --git a/scenes/utility/end_screen.gd.uid b/scenes/utility/end_screen.gd.uid new file mode 100644 index 0000000..e9dd03e --- /dev/null +++ b/scenes/utility/end_screen.gd.uid @@ -0,0 +1 @@ +uid://bbyeq7oncm6lp diff --git a/scenes/utility/end_screen.tscn b/scenes/utility/end_screen.tscn new file mode 100644 index 0000000..b08047b --- /dev/null +++ b/scenes/utility/end_screen.tscn @@ -0,0 +1,106 @@ +[gd_scene load_steps=6 format=3 uid="uid://b665roenfn8fk"] + +[ext_resource type="Texture2D" uid="uid://3xsncjue460g" path="res://assets/BlueTechPanel.png" id="1_bqxyb"] +[ext_resource type="Theme" uid="uid://c8kkdp01b836k" path="res://resources/swarmed_theme.tres" id="1_euf3j"] +[ext_resource type="Script" uid="uid://bbyeq7oncm6lp" path="res://scenes/utility/end_screen.gd" id="2_dcpoi"] +[ext_resource type="Theme" uid="uid://c5v72c25vwjor" path="res://scenes/utility/menu_theme_blue.tres" id="2_tb0yk"] +[ext_resource type="LabelSettings" uid="uid://bbdyaw8jp0amn" path="res://resources/text_overlay.tres" id="3_euf3j"] + +[node name="EndScreen" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_euf3j") +script = ExtResource("2_dcpoi") + +[node name="NinePatchRect" type="NinePatchRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("1_bqxyb") +region_rect = Rect2(0, 0, 601.333, 600) +patch_margin_left = 55 +patch_margin_top = 139 +patch_margin_right = 84 +patch_margin_bottom = 111 + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 300 +theme_override_constants/margin_top = 100 +theme_override_constants/margin_right = 300 +theme_override_constants/margin_bottom = 100 + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 +theme = ExtResource("2_tb0yk") +theme_override_constants/separation = 30 + +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="BugsText" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Total Bugs Killed:" +label_settings = ExtResource("3_euf3j") + +[node name="BugsKilledLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "0" + +[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="CrystalsText" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer2"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Total Crystals Collected:" +label_settings = ExtResource("3_euf3j") + +[node name="CrystalsCollectedLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer2"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "0" + +[node name="HBoxContainer3" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="LastLevelText" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Total Levels Reached:" +label_settings = ExtResource("3_euf3j") + +[node name="LevelNumberLabel" type="Label" parent="MarginContainer/VBoxContainer/HBoxContainer3"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "0" + +[node name="TitleScreenButton" type="Button" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +text = "Back to Title Screen" + +[node name="RestartButton" type="Button" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +text = "Restart" + +[connection signal="pressed" from="MarginContainer/VBoxContainer/TitleScreenButton" to="." method="_on_title_screen_button_pressed"] +[connection signal="pressed" from="MarginContainer/VBoxContainer/RestartButton" to="." method="_on_restart_button_pressed"] diff --git a/scenes/utility/menu.tscn b/scenes/utility/menu.tscn index 7863de2..2468084 100644 --- a/scenes/utility/menu.tscn +++ b/scenes/utility/menu.tscn @@ -1,17 +1,11 @@ -[gd_scene load_steps=7 format=3 uid="uid://bi4nry6akri6x"] +[gd_scene load_steps=6 format=3 uid="uid://bi4nry6akri6x"] -[ext_resource type="FontFile" uid="uid://cf01kekac2ysj" path="res://assets/fonts/orange-kid/Orange Kid.otf" id="1_l1drq"] +[ext_resource type="Theme" uid="uid://c5v72c25vwjor" path="res://scenes/utility/menu_theme_blue.tres" id="1_l1drq"] [ext_resource type="Texture2D" uid="uid://3xsncjue460g" path="res://assets/BlueTechPanel.png" id="1_y1yol"] [ext_resource type="Script" uid="uid://c2woi6pbsujj6" path="res://scenes/utility/menu.gd" id="2_el1m6"] [ext_resource type="Texture2D" uid="uid://bq01vggk4yab7" path="res://assets/BlueSimplePanel.png" id="4_4ea3p"] [ext_resource type="LabelSettings" uid="uid://bbdyaw8jp0amn" path="res://resources/text_overlay.tres" id="5_c4hkh"] -[sub_resource type="Theme" id="Theme_g3wkw"] -default_font = ExtResource("1_l1drq") -default_font_size = 32 -Button/fonts/font = ExtResource("1_l1drq") -Label/fonts/font = ExtResource("1_l1drq") - [node name="Menu" type="Control"] layout_mode = 3 anchors_preset = 15 @@ -19,7 +13,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -theme = SubResource("Theme_g3wkw") +theme = ExtResource("1_l1drq") script = ExtResource("2_el1m6") [node name="MarginContainer" type="MarginContainer" parent="."] diff --git a/scenes/utility/menu_theme_blue.tres b/scenes/utility/menu_theme_blue.tres new file mode 100644 index 0000000..5277639 --- /dev/null +++ b/scenes/utility/menu_theme_blue.tres @@ -0,0 +1,9 @@ +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://c5v72c25vwjor"] + +[ext_resource type="FontFile" uid="uid://cf01kekac2ysj" path="res://assets/fonts/orange-kid/Orange Kid.otf" id="1_q7qeu"] + +[resource] +default_font = ExtResource("1_q7qeu") +default_font_size = 32 +Button/fonts/font = ExtResource("1_q7qeu") +Label/fonts/font = ExtResource("1_q7qeu") diff --git a/scenes/utility/text_overlay.tscn b/scenes/utility/text_overlay.tscn index 1e42e8b..ff6b3d9 100644 --- a/scenes/utility/text_overlay.tscn +++ b/scenes/utility/text_overlay.tscn @@ -30,9 +30,9 @@ patch_margin_bottom = 100 [node name="MarginContainer" type="MarginContainer" parent="TextPopUp"] layout_mode = 2 theme_override_constants/margin_left = 50 -theme_override_constants/margin_top = 100 +theme_override_constants/margin_top = 50 theme_override_constants/margin_right = 50 -theme_override_constants/margin_bottom = 100 +theme_override_constants/margin_bottom = 50 [node name="Label" type="Label" parent="TextPopUp/MarginContainer"] layout_mode = 2