added attacks
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user