extends Node2D

export(PackedScene) var enemy_ = preload('res://enemy.tscn')
export var spawnspeed = 5.0

func _ready():
	while true:
		yield(Timergen.createtime(self,spawnspeed),'timeout')
		_spawn()
		if get_tree().paused: break

func _spawn():
	var enemy = enemy_.instance()
	add_child(enemy)
	var play = get_tree().get_nodes_in_group('player')[0]
	enemy.global_position.x = play.global_position.x + rand_range(-360,360)
	enemy.global_position.y = play.global_position.y + rand_range(-640,640)
