Adds better folder structure, and adds simple dialogue system

This commit is contained in:
txrpe 2024-10-06 15:57:47 +02:00
parent 2cf9884f9d
commit 0f6f75ea44
31 changed files with 178 additions and 53 deletions

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@ -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]

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -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]

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -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]

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -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]

View File

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

@ -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]

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -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]

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -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]

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -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]

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -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]

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -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]

5
Assets/dialogs.json Normal file
View File

@ -0,0 +1,5 @@
[
{"name":"Commandant", "text":"Hello Commrade, please do not press anything yet"},
{"name":"Commandant", "text":"Have fun"}
]

BIN
Assets/dialogue_box.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://61did6cf2bnh"
path="res://.godot/imported/dialogue_box.png-44428d683d811a011da29d134c2a81ea.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Assets/dialogue_box.png"
dest_files=["res://.godot/imported/dialogue_box.png-44428d683d811a011da29d134c2a81ea.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

@ -2,7 +2,7 @@ extends Node2D
@export var input_name = ""
@export var color_mix:Color = Color(1,1,1)
const ENEMY = preload("res://enemy.tscn")
const ENEMY = preload("res://Scenes/Worm/enemy.tscn")
const DISTANCE = 40
var red_button = false
var should_move = false

View File

@ -1,12 +1,12 @@
[gd_scene load_steps=10 format=3 uid="uid://bhvihrt8dipll"]
[ext_resource type="Script" path="res://button.gd" id="1_fkyus"]
[ext_resource type="Texture2D" uid="uid://q85jhjrqsrxk" path="res://Buttons/Idle.png" id="2_01nlj"]
[ext_resource type="Texture2D" uid="uid://blatwufdrwqml" path="res://Buttons/PressedIn1.png" id="3_180hi"]
[ext_resource type="Texture2D" uid="uid://4c7qtuk0exng" path="res://Buttons/FullPressed.png" id="4_5m7c4"]
[ext_resource type="Texture2D" uid="uid://ncd65m8iq7l0" path="res://Buttons/PressedOut.png" id="5_3xqo8"]
[ext_resource type="Texture2D" uid="uid://chckt1ppwsjq" path="res://Buttons/FORBIDDEN.png" id="6_p5821"]
[ext_resource type="Texture2D" uid="uid://cw6je7hakttbq" path="res://Buttons/ERROR.png" id="7_3w6j8"]
[ext_resource type="Script" path="res://Scenes/Button/button.gd" id="1_fkyus"]
[ext_resource type="Texture2D" uid="uid://q85jhjrqsrxk" path="res://Assets/Buttons/Idle.png" id="2_01nlj"]
[ext_resource type="Texture2D" uid="uid://blatwufdrwqml" path="res://Assets/Buttons/PressedIn1.png" id="3_180hi"]
[ext_resource type="Texture2D" uid="uid://4c7qtuk0exng" path="res://Assets/Buttons/FullPressed.png" id="4_5m7c4"]
[ext_resource type="Texture2D" uid="uid://ncd65m8iq7l0" path="res://Assets/Buttons/PressedOut.png" id="5_3xqo8"]
[ext_resource type="Texture2D" uid="uid://chckt1ppwsjq" path="res://Assets/Buttons/FORBIDDEN.png" id="6_p5821"]
[ext_resource type="Texture2D" uid="uid://cw6je7hakttbq" path="res://Assets/Buttons/ERROR.png" id="7_3w6j8"]
[sub_resource type="SpriteFrames" id="SpriteFrames_leuex"]
animations = [{

View File

@ -1,11 +1,11 @@
[gd_scene load_steps=8 format=3 uid="uid://cuvoq65ec58jk"]
[ext_resource type="Script" path="res://enemy.gd" id="1_bn0a2"]
[ext_resource type="Texture2D" uid="uid://7a1smbkaiutn" path="res://icon.svg" id="1_rhutm"]
[ext_resource type="Texture2D" uid="uid://bjb6konwfdwma" path="res://Worm/1.png" id="3_owy1m"]
[ext_resource type="Texture2D" uid="uid://cowon23pejcb6" path="res://Worm/2.png" id="4_tiked"]
[ext_resource type="Texture2D" uid="uid://dl0wp6buga4d" path="res://Worm/3.png" id="5_vmogp"]
[ext_resource type="Texture2D" uid="uid://c6cj6t3538iox" path="res://Worm/4.png" id="6_h1mxl"]
[ext_resource type="Script" path="res://Scenes/Worm/enemy.gd" id="1_t2xh1"]
[ext_resource type="Texture2D" uid="uid://7a1smbkaiutn" path="res://icon.svg" id="2_qu5u7"]
[ext_resource type="Texture2D" uid="uid://bjb6konwfdwma" path="res://Assets/Worm/1.png" id="3_6av35"]
[ext_resource type="Texture2D" uid="uid://cowon23pejcb6" path="res://Assets/Worm/2.png" id="4_x02e0"]
[ext_resource type="Texture2D" uid="uid://dl0wp6buga4d" path="res://Assets/Worm/3.png" id="5_eqhaj"]
[ext_resource type="Texture2D" uid="uid://c6cj6t3538iox" path="res://Assets/Worm/4.png" id="6_v8bp8"]
[sub_resource type="SpriteFrames" id="SpriteFrames_5w8q8"]
animations = [{
@ -16,16 +16,16 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_owy1m")
"texture": ExtResource("3_6av35")
}, {
"duration": 3.0,
"texture": ExtResource("4_tiked")
"texture": ExtResource("4_x02e0")
}, {
"duration": 1.0,
"texture": ExtResource("5_vmogp")
"texture": ExtResource("5_eqhaj")
}, {
"duration": 1.0,
"texture": ExtResource("6_h1mxl")
"texture": ExtResource("6_v8bp8")
}],
"loop": false,
"name": &"new_animation",
@ -34,12 +34,12 @@ animations = [{
[node name="Enemy" type="Node2D" groups=["enemy_group"]]
position = Vector2(10, 9)
script = ExtResource("1_bn0a2")
script = ExtResource("1_t2xh1")
[node name="Icon" type="Sprite2D" parent="."]
visible = false
scale = Vector2(0.4, 0.4)
texture = ExtResource("1_rhutm")
texture = ExtResource("2_qu5u7")
[node name="FirstTimer" type="Timer" parent="."]
one_shot = true

35
Scenes/dialog.gd Normal file
View File

@ -0,0 +1,35 @@
extends CanvasLayer
@export_file("*.json") var d_file
var dialogue = []
var dialog_step = 0
var is_dialog_active = false
signal dialogue_over
func start():
visible = true
is_dialog_active = true
dialogue = load_dialogue()
handle_dialog_change()
func _unhandled_input(event: InputEvent) -> 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

39
Scenes/dialog.tscn Normal file
View File

@ -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"

View File

@ -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()

View File

@ -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"]