mirror of
https://codeberg.org/Melon-Bread/Comets.gd.git
synced 2024-11-24 21:18:21 -05:00
27 lines
499 B
GDScript
27 lines
499 B
GDScript
extends Node2D
|
|
|
|
signal shot
|
|
|
|
const INVADER = preload("res://scenes/invader.tscn")
|
|
|
|
var can_spawn = false
|
|
|
|
func _process(_delta: float) -> void:
|
|
if can_spawn:
|
|
spawn_invader()
|
|
$SpawnTimer.wait_time = randi_range(20, 40)
|
|
|
|
|
|
func _on_spawn_timer_timeout() -> void:
|
|
can_spawn = true
|
|
|
|
func spawn_invader() -> void:
|
|
var invader := INVADER.instantiate()
|
|
invader.shot.connect(player_shot)
|
|
$Invaders.add_child(invader)
|
|
can_spawn = false
|
|
$SpawnTimer.start()
|
|
|
|
func player_shot() -> void:
|
|
shot.emit()
|