Compare commits

...

2 Commits

Author SHA1 Message Date
bc6e06237c Waves and menu update 2025-08-26 11:11:50 +02:00
6c1a3d54bd Wave generation 2025-07-31 21:02:49 +02:00
6 changed files with 78 additions and 14 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -12,23 +12,55 @@ const enemies = [FORKMAN, COBOLD, ORK]
func _ready() -> void:
get_node("CanvasLayer/SidePanel").Update_Lifes(20)
get_node("CanvasLayer/SidePanel").Update_Coins(2000)
#the meaning of the columns inside my wave generation matris:
# Number of enemies need to be spawned, chance of spawn an enemy, chance of forkman, chance of gobline, chance of ork
var waves = [
[10, 0.2, 0.8, 0.2, 0.0], #wave 1
[20, 0.4, 0.5, 0.5, 0.0], #wave 2
[30, 0.5, 0.4, 0.4, 0.1], #wave 3
[40, 0.8, 0.3, 0.2, 0.5], #wave 4
[50, 0.9, 0.1, 0.2, 0.7], #wave 5
]
var currentwave = 0
var endwave = false
func _on_timer_timeout() -> void:
spawnMonster()
if endwave:
if not get_node("Path2D").get_children():
endwave = false
get_node("CanvasLayer/SidePanel").Update_waves(currentwave + 1) #updating waves
else:
spawnMonster()
func spawnMonster():
var path = PathFollow2D.new()
var monster = enemies.pick_random().instantiate()
path.add_child(monster)
path_2d.add_child(path)
currentwave = 0
for w in waves:
if w[0] > 0:
if randf() < w[1]: #chance of generating any kind of enemy
w[0] -= 1
var chosen = randf()
var sum = 0.0
for i in range(2,5):
sum += w[i]
if chosen < sum:
var monster = enemies[i-2].instantiate()
var path = PathFollow2D.new()
path.add_child(monster)
path_2d.add_child(path)
break
break
else:
currentwave += 1
endwave = true
func decrease_life(damage) -> void:
get_node("CanvasLayer/SidePanel").Update_Lifes(-damage)
if get_node("CanvasLayer/SidePanel").get_Lifes() <= 0:
game_over()
func game_over()-> void:
get_node("Timer").stop()
var enemy = get_node("Path2D").get_children()

View File

@ -1549,7 +1549,7 @@ texture = ExtResource("65_ef8wx")
curve = SubResource("Curve2D_6abe5")
[node name="Timer" type="Timer" parent="."]
wait_time = 1.5
wait_time = 0.5
autostart = true
[node name="TrapArea" type="Area2D" parent="."]

View File

@ -83,6 +83,7 @@ collision_mask = 2
shape = SubResource("CircleShape2D_be2t6")
[node name="Timer" type="Timer" parent="."]
wait_time = 0.5
autostart = true
[node name="Area2D" type="Area2D" parent="."]

View File

@ -67,6 +67,9 @@ func get_Lifes():
func Update_Lifes(amount) -> void:
lives += amount
func Update_waves(wavecount) -> void:
get_node("WaveCounter/HBoxContainer/Label").text = "Current wave: "+ str(wavecount)
func Update_Coins(amount) -> void:
coins += amount

View File

@ -1,10 +1,8 @@
[gd_scene load_steps=17 format=3 uid="uid://ddn64i6logtw0"]
[gd_scene load_steps=16 format=3 uid="uid://ddn64i6logtw0"]
[ext_resource type="Script" uid="uid://c6sh5em844tx2" path="res://Game/sidepanel.gd" id="1_klyhg"]
[ext_resource type="FontFile" uid="uid://bu44ne346ymoe" path="res://Assets/Others/Canterbury.ttf" id="2_4l4p2"]
[sub_resource type="Theme" id="Theme_4l4p2"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4l4p2"]
bg_color = Color(1, 1, 1, 0.447059)
corner_radius_top_left = 20
@ -133,7 +131,6 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = SubResource("Theme_4l4p2")
theme_override_constants/separation = 60
alignment = 1
@ -322,6 +319,37 @@ theme_override_styles/pressed = SubResource("StyleBoxFlat_dgw1d")
theme_override_styles/normal = SubResource("StyleBoxFlat_nctfw")
text = "Exit"
[node name="WaveCounter" type="Panel" parent="."]
custom_minimum_size = Vector2(160, 0)
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -20.0
offset_right = 20.0
offset_bottom = 40.0
grow_horizontal = 2
[node name="HBoxContainer" type="HBoxContainer" parent="WaveCounter"]
custom_minimum_size = Vector2(150, 0)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -75.0
offset_top = -20.0
offset_right = 75.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
alignment = 1
[node name="Label" type="Label" parent="WaveCounter/HBoxContainer"]
layout_mode = 2
text = "Current wave: 1"
[connection signal="pressed" from="Panel/HBoxContainer4/HBoxContainer4/Button3" to="." method="_on_button_3_pressed"]
[connection signal="pressed" from="pausemenu/VBoxContainer/Button3" to="." method="_on_button_3_pressed"]
[connection signal="pressed" from="pausemenu/VBoxContainer/Button2" to="." method="_on_button_2_pressed"]