Import test project as example

TODO: update gitlab-ci template to also use the test-project
This commit is contained in:
abarichello
2020-05-18 16:17:43 -03:00
parent 3e18735be5
commit 9fd1c3aee0
50 changed files with 2453 additions and 16 deletions

View File

@@ -0,0 +1,40 @@
extends Node2D
onready var EnemyScene: PackedScene = preload("res://scenes/Projectile.tscn")
signal start
signal stop
var Enemy
func _ready():
self.setup_enemy()
self.emit_signal("stop")
func setup_enemy() -> void:
self.Enemy = EnemyScene.instance()
Enemy.setup(GLOBAL.MISSILE, GLOBAL.MISSILE_SPEED["max"])
func spawn_and_shoot_enemy() -> void:
var Duplicate = Enemy.duplicate(Node.DUPLICATE_USE_INSTANCING)
Duplicate.set_random_color()
Duplicate.update_collision_layer()
$Enemies.add_child(Duplicate)
$SpawnArea/SpawnLocation.set_offset(randi())
Duplicate.global_position = $SpawnArea/SpawnLocation.position
var direction: Vector2 = (Vector2(0, 1080) - Duplicate.global_position).normalized()
var angle: float = Vector2(1, 0).angle_to(direction)
Duplicate.rotation = angle
Duplicate.shoot_missile(direction)
# --- Signals ---
func _on_SpawnTimer_timeout():
self.spawn_and_shoot_enemy()
func _on_EnemyGenerator_start():
$SpawnTimer.start()
func _on_EnemyGenerator_stop():
$SpawnTimer.stop()