Add basic enemy behavior and spawning system
The changes introduce enemy mechanics and management - including spawning, movement patterns, shooting timers, and death handling.
This commit is contained in:
parent
85155b1c7d
commit
996a0bb8f7
8 changed files with 300 additions and 7 deletions
20
scenes/main.gd
Normal file
20
scenes/main.gd
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
var enemy = preload("res://scenes/enemy.tscn")
|
||||
var score = 0
|
||||
|
||||
func _ready():
|
||||
spawn_enemies()
|
||||
|
||||
func spawn_enemies():
|
||||
for x in range(9):
|
||||
for y in range(3):
|
||||
var e = enemy.instantiate()
|
||||
var pos = Vector2(x * (16 + 8) + 24, 16 * 4 + y * 16)
|
||||
add_child(e)
|
||||
e.start(pos)
|
||||
e.died.connect(_on_enemy_died)
|
||||
|
||||
func _on_enemy_died(value):
|
||||
score += value
|
||||
Loading…
Add table
Add a link
Reference in a new issue