Game #3: Space Shooter
This commit is contained in:
parent
a00e9b59c9
commit
f785a24c14
45 changed files with 927 additions and 0 deletions
21
space-shooter/Scenes/EnemySpawner.gd
Normal file
21
space-shooter/Scenes/EnemySpawner.gd
Normal file
|
@ -0,0 +1,21 @@
|
|||
extends Node2D
|
||||
|
||||
const Enemy = preload("res://Scenes/Objects/Enemy.tscn")
|
||||
onready var spawnPoints = $SpawnPoints
|
||||
|
||||
|
||||
func get_random_spawnpoint():
|
||||
var points = spawnPoints.get_children()
|
||||
points.shuffle()
|
||||
return points[0].global_position
|
||||
|
||||
|
||||
func spawn_enemy():
|
||||
var spawn_location = get_random_spawnpoint()
|
||||
var enemy = Enemy.instance()
|
||||
enemy.global_position = spawn_location
|
||||
get_tree().current_scene.add_child(enemy)
|
||||
|
||||
|
||||
func _on_Timer_timeout():
|
||||
spawn_enemy()
|
Loading…
Add table
Add a link
Reference in a new issue