added attacks

This commit is contained in:
2024-02-14 07:09:32 -06:00
parent 8fc0ed9218
commit e6d1f5a8df
12 changed files with 251 additions and 20 deletions

View File

@@ -8,6 +8,7 @@ var spawn_locations: Array[Vector2] = []
@onready var hud: HUD = $HUD
@onready var spawn_zones: Node2D = $SpawnZones
@onready var entity_container: Node = $EntityContainer
func _ready() -> void:
var spawn_zone_array := spawn_zones.get_children()
@@ -17,6 +18,7 @@ func _ready() -> void:
for x in range(zone.shape.size.x / 16):
for y in range(zone.shape.size.y / 16):
spawn_locations.append(top_left + Vector2(x * 16, y * 16))
hud.update_entity_count(spawn_locations.size())
var player_loc: Vector2 = spawn_locations.pick_random()
for spawn in spawn_locations:
var entity
@@ -27,4 +29,9 @@ func _ready() -> void:
else:
entity = ENEMY.instantiate()
entity.position = spawn
add_child(entity)
entity.death.connect(_on_entity_death)
entity_container.add_child(entity)
func _on_entity_death():
var entities = entity_container.get_child_count()
hud.update_entity_count(entities)