Files
Defensaria/Game/Maps/map_1.gd
2025-03-17 11:30:18 +01:00

40 lines
861 B
GDScript

extends Node2D
@onready var path_2d: Path2D = $Path2D
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 lives = 20
func _ready() -> void:
get_node("SidePanel").Update_Lives(lives)
func _on_timer_timeout() -> void:
spawnMonster()
func spawnMonster():
var path = PathFollow2D.new()
var monster = enemies.pick_random().instantiate()
path.add_child(monster)
path_2d.add_child(path)
func decrease_life(damage) -> void:
lives -= damage
get_node("SidePanel").Update_Lives(lives)
if lives <= 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)
i.get_children()[0].name