Second Map, and sound effects

This commit is contained in:
2025-08-27 22:31:00 +02:00
parent 8108485091
commit 4ff651ff8f
21 changed files with 1863 additions and 48 deletions

View File

@ -8,10 +8,11 @@ const COBOLD = preload("res://Game/Mobs/cobold.tscn")
const enemies = [FORKMAN, COBOLD, ORK]
var pause = 40
func _ready() -> void:
get_node("CanvasLayer/SidePanel").set_Lifes(20)
get_node("CanvasLayer/SidePanel").Update_Coins(2000)
get_node("CanvasLayer/SidePanel").Update_Coins(250)
#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
@ -27,23 +28,26 @@ var currentwave = 0
var endwave = false
func _on_timer_timeout() -> void:
if endwave:
if not get_node("Path2D").get_children():
endwave = false
get_node("CanvasLayer/SidePanel").Update_waves(currentwave + 1) #updating waves
if currentwave >= 4: #!!!!! CHECKS FOR THE LAST WAVE IF NEW WAVES ARE ADDED CHANGE ACCORDINGLY!!!
get_node("CanvasLayer/SidePanel").GameWon()
if pause <= 0:
if endwave:
if not get_node("Path2D").get_children():
endwave = false
get_node("CanvasLayer/SidePanel").Update_waves(currentwave + 1) #updating waves
if currentwave >= 4: #!!!!! CHECKS FOR THE LAST WAVE IF NEW WAVES ARE ADDED CHANGE ACCORDINGLY!!!
get_node("CanvasLayer/SidePanel").GameWon()
else:
spawnMonster()
else:
spawnMonster()
pause -= 1
func spawnMonster():
currentwave = 0
for w in waves:
if w[0] > 0:
if randf() < w[1]: #chance of generating any kind of enemy
w[0] -= 1
if w[0] <= 0:
endwave = true
currentwave += 1
var chosen = randf()
var sum = 0.0
for i in range(2,5):
@ -55,9 +59,7 @@ func spawnMonster():
path_2d.add_child(path)
break
break
else:
currentwave += 1
func decrease_life(damage) -> void:
get_node("CanvasLayer/SidePanel").Update_Lifes(-damage)

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=186 format=4 uid="uid://bgme05i7taycc"]
[gd_scene load_steps=186 format=4 uid="uid://dql8q1od3r32h"]
[ext_resource type="Texture2D" uid="uid://f1npbjsw71nk" path="res://Assets/Tiles/Fields/FieldsTile_01.png" id="1_fdpq6"]
[ext_resource type="Script" uid="uid://xo6vbicdva8d" path="res://Game/Maps/map_1.gd" id="1_rec5e"]
@ -531,6 +531,7 @@ size = Vector2(163, 334)
script = ExtResource("1_rec5e")
[node name="Decoration" type="Node2D" parent="."]
visible = false
[node name="6" type="Sprite2D" parent="Decoration"]
position = Vector2(386, 348)

88
Game/Maps/map_2.gd Normal file
View File

@ -0,0 +1,88 @@
extends Node2D
@onready var path_2d: Path2D = $Path2D
@onready var path_2d_2: Path2D = $Path2D2
@onready var paths = [path_2d, path_2d_2]
const FORKMAN = preload("res://Game/Mobs/forkman.tscn")
const ORK = preload("res://Game/Mobs/ork.tscn")
const COBOLD = preload("res://Game/Mobs/cobold.tscn")
const enemies = [FORKMAN, COBOLD, ORK]
var pause = 40
func _ready() -> void:
get_node("CanvasLayer/SidePanel").set_Lifes(20)
get_node("CanvasLayer/SidePanel").Update_Coins(500)
#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 #First path
[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
],
[
[5, 0.1, 0.8, 0.2, 0.0], #wave 1 #Second Path
[10, 0.2, 0.5, 0.5, 0.0], #wave 2
[20, 0.3, 0.4, 0.4, 0.1], #wave 3
[30, 0.4, 0.3, 0.2, 0.5], #wave 4
[40, 0.7, 0.1, 0.2, 0.7], #wave 5
]
]
var currentwave = 0
var endwave = false
func _on_timer_timeout() -> void:
if pause <= 0:
if endwave:
if not get_node("Path2D").get_children():
endwave = false
get_node("CanvasLayer/SidePanel").Update_waves(currentwave + 1) #updating waves
if currentwave >= 4: #!!!!! CHECKS FOR THE LAST WAVE IF NEW WAVES ARE ADDED CHANGE ACCORDINGLY!!!
get_node("CanvasLayer/SidePanel").GameWon()
else:
spawnMonster()
else:
pause -= 1
func spawnMonster():
for ROUTE in range(2):
for w in waves[ROUTE]:
if w[0] > 0:
if randf() < w[1]: #chance of generating any kind of enemy
w[0] -= 1
for i in waves:
if i[currentwave][0] > 0:
break
endwave = true
currentwave += 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)
paths[ROUTE].add_child(path)
break
break
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()
for i in enemy:
i.get_children()[0].set_process(false)

1
Game/Maps/map_2.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://cjoybvdfv0bk7

1628
Game/Maps/map_2.tscn Normal file

File diff suppressed because one or more lines are too long