From 0f6f75ea44bc049bca7c656a27bf9eea883febd1 Mon Sep 17 00:00:00 2001 From: txrpe Date: Sun, 6 Oct 2024 15:57:47 +0200 Subject: [PATCH] Adds better folder structure, and adds simple dialogue system --- {Buttons => Assets/Buttons}/ERROR.png | Bin {Buttons => Assets/Buttons}/ERROR.png.import | 6 +-- {Buttons => Assets/Buttons}/FORBIDDEN.png | Bin .../Buttons}/FORBIDDEN.png.import | 6 +-- {Buttons => Assets/Buttons}/FullPressed.png | Bin .../Buttons}/FullPressed.png.import | 6 +-- {Buttons => Assets/Buttons}/Idle.png | Bin {Buttons => Assets/Buttons}/Idle.png.import | 6 +-- {Buttons => Assets/Buttons}/PressedIn1.png | Bin .../Buttons}/PressedIn1.png.import | 6 +-- {Buttons => Assets/Buttons}/PressedOut.png | Bin .../Buttons}/PressedOut.png.import | 6 +-- {Worm => Assets/Worm}/1.png | Bin {Worm => Assets/Worm}/1.png.import | 6 +-- {Worm => Assets/Worm}/2.png | Bin {Worm => Assets/Worm}/2.png.import | 6 +-- {Worm => Assets/Worm}/3.png | Bin {Worm => Assets/Worm}/3.png.import | 6 +-- {Worm => Assets/Worm}/4.png | Bin {Worm => Assets/Worm}/4.png.import | 6 +-- Assets/dialogs.json | 5 +++ Assets/dialogue_box.png | Bin 0 -> 156 bytes Assets/dialogue_box.png.import | 34 +++++++++++++++ button.gd => Scenes/Button/button.gd | 2 +- button.tscn => Scenes/Button/button.tscn | 14 +++---- enemy.gd => Scenes/Worm/enemy.gd | 0 enemy.tscn => Scenes/Worm/enemy.tscn | 24 +++++------ Scenes/dialog.gd | 35 ++++++++++++++++ Scenes/dialog.tscn | 39 ++++++++++++++++++ game.gd | 9 ++++ game.tscn | 9 ++-- 31 files changed, 178 insertions(+), 53 deletions(-) rename {Buttons => Assets/Buttons}/ERROR.png (100%) rename {Buttons => Assets/Buttons}/ERROR.png.import (72%) rename {Buttons => Assets/Buttons}/FORBIDDEN.png (100%) rename {Buttons => Assets/Buttons}/FORBIDDEN.png.import (71%) rename {Buttons => Assets/Buttons}/FullPressed.png (100%) rename {Buttons => Assets/Buttons}/FullPressed.png.import (71%) rename {Buttons => Assets/Buttons}/Idle.png (100%) rename {Buttons => Assets/Buttons}/Idle.png.import (73%) rename {Buttons => Assets/Buttons}/PressedIn1.png (100%) rename {Buttons => Assets/Buttons}/PressedIn1.png.import (71%) rename {Buttons => Assets/Buttons}/PressedOut.png (100%) rename {Buttons => Assets/Buttons}/PressedOut.png.import (71%) rename {Worm => Assets/Worm}/1.png (100%) rename {Worm => Assets/Worm}/1.png.import (74%) rename {Worm => Assets/Worm}/2.png (100%) rename {Worm => Assets/Worm}/2.png.import (74%) rename {Worm => Assets/Worm}/3.png (100%) rename {Worm => Assets/Worm}/3.png.import (74%) rename {Worm => Assets/Worm}/4.png (100%) rename {Worm => Assets/Worm}/4.png.import (74%) create mode 100644 Assets/dialogs.json create mode 100644 Assets/dialogue_box.png create mode 100644 Assets/dialogue_box.png.import rename button.gd => Scenes/Button/button.gd (98%) rename button.tscn => Scenes/Button/button.tscn (88%) rename enemy.gd => Scenes/Worm/enemy.gd (100%) rename enemy.tscn => Scenes/Worm/enemy.tscn (76%) create mode 100644 Scenes/dialog.gd create mode 100644 Scenes/dialog.tscn diff --git a/Buttons/ERROR.png b/Assets/Buttons/ERROR.png similarity index 100% rename from Buttons/ERROR.png rename to Assets/Buttons/ERROR.png diff --git a/Buttons/ERROR.png.import b/Assets/Buttons/ERROR.png.import similarity index 72% rename from Buttons/ERROR.png.import rename to Assets/Buttons/ERROR.png.import index e8c1a32..8e57fa3 100644 --- a/Buttons/ERROR.png.import +++ b/Assets/Buttons/ERROR.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://cw6je7hakttbq" -path="res://.godot/imported/ERROR.png-b61259a9cd49f5cf3869c7af0d132956.ctex" +path="res://.godot/imported/ERROR.png-bb4a153740a394e385a559c916c4984d.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Buttons/ERROR.png" -dest_files=["res://.godot/imported/ERROR.png-b61259a9cd49f5cf3869c7af0d132956.ctex"] +source_file="res://Assets/Buttons/ERROR.png" +dest_files=["res://.godot/imported/ERROR.png-bb4a153740a394e385a559c916c4984d.ctex"] [params] diff --git a/Buttons/FORBIDDEN.png b/Assets/Buttons/FORBIDDEN.png similarity index 100% rename from Buttons/FORBIDDEN.png rename to Assets/Buttons/FORBIDDEN.png diff --git a/Buttons/FORBIDDEN.png.import b/Assets/Buttons/FORBIDDEN.png.import similarity index 71% rename from Buttons/FORBIDDEN.png.import rename to Assets/Buttons/FORBIDDEN.png.import index 95dcb60..8934402 100644 --- a/Buttons/FORBIDDEN.png.import +++ b/Assets/Buttons/FORBIDDEN.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://chckt1ppwsjq" -path="res://.godot/imported/FORBIDDEN.png-2caecaec5473cc18ee219ff66f0d7332.ctex" +path="res://.godot/imported/FORBIDDEN.png-ab7de870cf2ea37485fe159e85cf294e.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Buttons/FORBIDDEN.png" -dest_files=["res://.godot/imported/FORBIDDEN.png-2caecaec5473cc18ee219ff66f0d7332.ctex"] +source_file="res://Assets/Buttons/FORBIDDEN.png" +dest_files=["res://.godot/imported/FORBIDDEN.png-ab7de870cf2ea37485fe159e85cf294e.ctex"] [params] diff --git a/Buttons/FullPressed.png b/Assets/Buttons/FullPressed.png similarity index 100% rename from Buttons/FullPressed.png rename to Assets/Buttons/FullPressed.png diff --git a/Buttons/FullPressed.png.import b/Assets/Buttons/FullPressed.png.import similarity index 71% rename from Buttons/FullPressed.png.import rename to Assets/Buttons/FullPressed.png.import index ea8deee..d309217 100644 --- a/Buttons/FullPressed.png.import +++ b/Assets/Buttons/FullPressed.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://4c7qtuk0exng" -path="res://.godot/imported/FullPressed.png-f20f7171b0bcb8d71198a38c00af8073.ctex" +path="res://.godot/imported/FullPressed.png-c0a1078a7a0d22d30101653763c94f71.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Buttons/FullPressed.png" -dest_files=["res://.godot/imported/FullPressed.png-f20f7171b0bcb8d71198a38c00af8073.ctex"] +source_file="res://Assets/Buttons/FullPressed.png" +dest_files=["res://.godot/imported/FullPressed.png-c0a1078a7a0d22d30101653763c94f71.ctex"] [params] diff --git a/Buttons/Idle.png b/Assets/Buttons/Idle.png similarity index 100% rename from Buttons/Idle.png rename to Assets/Buttons/Idle.png diff --git a/Buttons/Idle.png.import b/Assets/Buttons/Idle.png.import similarity index 73% rename from Buttons/Idle.png.import rename to Assets/Buttons/Idle.png.import index 21a61bb..d8c4f7e 100644 --- a/Buttons/Idle.png.import +++ b/Assets/Buttons/Idle.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://q85jhjrqsrxk" -path="res://.godot/imported/Idle.png-b446be287cb4debe9b9c6ef9fd0fd194.ctex" +path="res://.godot/imported/Idle.png-f1928d4d3971727d33c44035adc1a594.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Buttons/Idle.png" -dest_files=["res://.godot/imported/Idle.png-b446be287cb4debe9b9c6ef9fd0fd194.ctex"] +source_file="res://Assets/Buttons/Idle.png" +dest_files=["res://.godot/imported/Idle.png-f1928d4d3971727d33c44035adc1a594.ctex"] [params] diff --git a/Buttons/PressedIn1.png b/Assets/Buttons/PressedIn1.png similarity index 100% rename from Buttons/PressedIn1.png rename to Assets/Buttons/PressedIn1.png diff --git a/Buttons/PressedIn1.png.import b/Assets/Buttons/PressedIn1.png.import similarity index 71% rename from Buttons/PressedIn1.png.import rename to Assets/Buttons/PressedIn1.png.import index b64bae5..18ea72f 100644 --- a/Buttons/PressedIn1.png.import +++ b/Assets/Buttons/PressedIn1.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://blatwufdrwqml" -path="res://.godot/imported/PressedIn1.png-569043e67dd3e7c3f7e994945b5057a8.ctex" +path="res://.godot/imported/PressedIn1.png-8136f4e114c56d7ef74e3cd563202045.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Buttons/PressedIn1.png" -dest_files=["res://.godot/imported/PressedIn1.png-569043e67dd3e7c3f7e994945b5057a8.ctex"] +source_file="res://Assets/Buttons/PressedIn1.png" +dest_files=["res://.godot/imported/PressedIn1.png-8136f4e114c56d7ef74e3cd563202045.ctex"] [params] diff --git a/Buttons/PressedOut.png b/Assets/Buttons/PressedOut.png similarity index 100% rename from Buttons/PressedOut.png rename to Assets/Buttons/PressedOut.png diff --git a/Buttons/PressedOut.png.import b/Assets/Buttons/PressedOut.png.import similarity index 71% rename from Buttons/PressedOut.png.import rename to Assets/Buttons/PressedOut.png.import index 6622553..b26313b 100644 --- a/Buttons/PressedOut.png.import +++ b/Assets/Buttons/PressedOut.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://ncd65m8iq7l0" -path="res://.godot/imported/PressedOut.png-9796e7372947b19c113dcbcbde6b5b56.ctex" +path="res://.godot/imported/PressedOut.png-fafb11808cd442da9cd321af11d67ce1.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Buttons/PressedOut.png" -dest_files=["res://.godot/imported/PressedOut.png-9796e7372947b19c113dcbcbde6b5b56.ctex"] +source_file="res://Assets/Buttons/PressedOut.png" +dest_files=["res://.godot/imported/PressedOut.png-fafb11808cd442da9cd321af11d67ce1.ctex"] [params] diff --git a/Worm/1.png b/Assets/Worm/1.png similarity index 100% rename from Worm/1.png rename to Assets/Worm/1.png diff --git a/Worm/1.png.import b/Assets/Worm/1.png.import similarity index 74% rename from Worm/1.png.import rename to Assets/Worm/1.png.import index dd36765..8a8b862 100644 --- a/Worm/1.png.import +++ b/Assets/Worm/1.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://bjb6konwfdwma" -path="res://.godot/imported/1.png-247616084d8c6df5f824301570c7e3df.ctex" +path="res://.godot/imported/1.png-d59e84433910eecfa2e5220e6ec5b5b4.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Worm/1.png" -dest_files=["res://.godot/imported/1.png-247616084d8c6df5f824301570c7e3df.ctex"] +source_file="res://Assets/Worm/1.png" +dest_files=["res://.godot/imported/1.png-d59e84433910eecfa2e5220e6ec5b5b4.ctex"] [params] diff --git a/Worm/2.png b/Assets/Worm/2.png similarity index 100% rename from Worm/2.png rename to Assets/Worm/2.png diff --git a/Worm/2.png.import b/Assets/Worm/2.png.import similarity index 74% rename from Worm/2.png.import rename to Assets/Worm/2.png.import index ee3f805..44313fc 100644 --- a/Worm/2.png.import +++ b/Assets/Worm/2.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://cowon23pejcb6" -path="res://.godot/imported/2.png-9f90c34ea3a109bedf7c22efae8619ce.ctex" +path="res://.godot/imported/2.png-90fe91be8b8400834bfb6934ea879095.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Worm/2.png" -dest_files=["res://.godot/imported/2.png-9f90c34ea3a109bedf7c22efae8619ce.ctex"] +source_file="res://Assets/Worm/2.png" +dest_files=["res://.godot/imported/2.png-90fe91be8b8400834bfb6934ea879095.ctex"] [params] diff --git a/Worm/3.png b/Assets/Worm/3.png similarity index 100% rename from Worm/3.png rename to Assets/Worm/3.png diff --git a/Worm/3.png.import b/Assets/Worm/3.png.import similarity index 74% rename from Worm/3.png.import rename to Assets/Worm/3.png.import index 3c37ed5..55a8c99 100644 --- a/Worm/3.png.import +++ b/Assets/Worm/3.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://dl0wp6buga4d" -path="res://.godot/imported/3.png-3c71a66973d42fb571c23be36a651538.ctex" +path="res://.godot/imported/3.png-0463e07c1bea2f543f4c3653457283e4.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Worm/3.png" -dest_files=["res://.godot/imported/3.png-3c71a66973d42fb571c23be36a651538.ctex"] +source_file="res://Assets/Worm/3.png" +dest_files=["res://.godot/imported/3.png-0463e07c1bea2f543f4c3653457283e4.ctex"] [params] diff --git a/Worm/4.png b/Assets/Worm/4.png similarity index 100% rename from Worm/4.png rename to Assets/Worm/4.png diff --git a/Worm/4.png.import b/Assets/Worm/4.png.import similarity index 74% rename from Worm/4.png.import rename to Assets/Worm/4.png.import index f22f3e0..91b58f9 100644 --- a/Worm/4.png.import +++ b/Assets/Worm/4.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://c6cj6t3538iox" -path="res://.godot/imported/4.png-b38296328fae3e4fe3ee9cdb239540c5.ctex" +path="res://.godot/imported/4.png-4b049625170874896147063dd9a56363.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://Worm/4.png" -dest_files=["res://.godot/imported/4.png-b38296328fae3e4fe3ee9cdb239540c5.ctex"] +source_file="res://Assets/Worm/4.png" +dest_files=["res://.godot/imported/4.png-4b049625170874896147063dd9a56363.ctex"] [params] diff --git a/Assets/dialogs.json b/Assets/dialogs.json new file mode 100644 index 0000000..bf3f1fc --- /dev/null +++ b/Assets/dialogs.json @@ -0,0 +1,5 @@ +[ + + {"name":"Commandant", "text":"Hello Commrade, please do not press anything yet"}, + {"name":"Commandant", "text":"Have fun"} +] diff --git a/Assets/dialogue_box.png b/Assets/dialogue_box.png new file mode 100644 index 0000000000000000000000000000000000000000..f8f3f0567919cd09fc4bf6fcfa4ffec0bc1a8c64 GIT binary patch literal 156 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}VV*9IArY-_ zuWRx#DDb#k)GR+#SR>QUiJ`_!`IRnU){*` void: + if !is_dialog_active: + return + if event.is_action_pressed("A"): + if(dialog_step >= dialogue.size()-1): + visible = false + is_dialog_active = false + dialogue_over.emit() + return + dialog_step +=1 + handle_dialog_change() + +func handle_dialog_change(): + $NinePatchRect/Name.text = dialogue[dialog_step].name + $NinePatchRect/Text.text = dialogue[dialog_step].text + + +func load_dialogue(): + var file = FileAccess.open(d_file, FileAccess.READ) + var content = JSON.parse_string(file.get_as_text()) + return content diff --git a/Scenes/dialog.tscn b/Scenes/dialog.tscn new file mode 100644 index 0000000..f27ec6e --- /dev/null +++ b/Scenes/dialog.tscn @@ -0,0 +1,39 @@ +[gd_scene load_steps=3 format=3 uid="uid://du2jgrreaylhr"] + +[ext_resource type="Script" path="res://Scenes/dialog.gd" id="1_lru6p"] +[ext_resource type="Texture2D" uid="uid://61did6cf2bnh" path="res://Assets/dialogue_box.png" id="2_cuk8x"] + +[node name="Dialog" type="CanvasLayer"] +script = ExtResource("1_lru6p") +d_file = "res://Assets/dialogs.json" + +[node name="NinePatchRect" type="NinePatchRect" parent="."] +offset_right = 101.0 +offset_bottom = 35.0 +scale = Vector2(5.08, 5.08) +texture = ExtResource("2_cuk8x") +region_rect = Rect2(0.0332336, 0.310051, 31.9668, 31.6899) +patch_margin_left = 7 +patch_margin_top = 9 +patch_margin_right = 7 +patch_margin_bottom = 10 + +[node name="Name" type="RichTextLabel" parent="NinePatchRect"] +layout_mode = 0 +offset_left = 4.33071 +offset_top = 0.787402 +offset_right = 227.331 +offset_bottom = 26.7874 +scale = Vector2(0.450723, 0.450723) +theme_override_colors/default_color = Color(0, 0, 0, 1) +text = "Name" + +[node name="Text" type="RichTextLabel" parent="NinePatchRect"] +layout_mode = 0 +offset_left = 6.29921 +offset_top = 7.87402 +offset_right = 214.299 +offset_bottom = 59.874 +scale = Vector2(0.450723, 0.450723) +theme_override_colors/default_color = Color(0, 0, 0, 1) +text = "Text" diff --git a/game.gd b/game.gd index cd5d231..aa7ca82 100644 --- a/game.gd +++ b/game.gd @@ -23,12 +23,17 @@ func _unhandled_input(event: InputEvent) -> void: $SpawnTimer.paused = false func _ready() -> void: + $Dialog.start() + +func start_game(): + $SpawnTimer.start() change_red_button() first_time = false $SpawnTimer.wait_time = spawn_interval for button in get_tree().get_nodes_in_group("button_group"): button.enemy_killed.connect(on_enemy_killed) + func _process(delta: float) -> void: health = minf(health + RECOVERY_RATE * delta ,MAX_HEALTH) @@ -87,3 +92,7 @@ func _on_spawn_timer_timeout() -> void: func on_enemy_killed(): player_score+=1 print_debug(player_score) + + +func _on_dialog_dialogue_over() -> void: + start_game() diff --git a/game.tscn b/game.tscn index 506fbf4..684ed5b 100644 --- a/game.tscn +++ b/game.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=4 format=3 uid="uid://decsef3jj3lt5"] +[gd_scene load_steps=5 format=3 uid="uid://decsef3jj3lt5"] [ext_resource type="Script" path="res://game.gd" id="1_bhcvq"] -[ext_resource type="PackedScene" uid="uid://bhvihrt8dipll" path="res://button.tscn" id="1_j4pve"] +[ext_resource type="PackedScene" uid="uid://bhvihrt8dipll" path="res://Scenes/Button/button.tscn" id="1_j4pve"] +[ext_resource type="PackedScene" uid="uid://du2jgrreaylhr" path="res://Scenes/dialog.tscn" id="3_s0nfr"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_sesmb"] size = Vector2(995, 433.534) @@ -77,6 +78,8 @@ debug_color = Color(0, 0.6, 0.701961, 0.14902) [node name="SpawnTimer" type="Timer" parent="."] wait_time = 0.5 -autostart = true + +[node name="Dialog" parent="." instance=ExtResource("3_s0nfr")] [connection signal="timeout" from="SpawnTimer" to="." method="_on_spawn_timer_timeout"] +[connection signal="dialogue_over" from="Dialog" to="." method="_on_dialog_dialogue_over"]