aboutsummaryrefslogtreecommitdiffstats
path: root/Main.gd
diff options
context:
space:
mode:
authorfreddie-a <57713959+freddie-a@users.noreply.github.com>2022-10-29 17:43:42 +0100
committerfreddie-a <57713959+freddie-a@users.noreply.github.com>2022-10-29 17:43:42 +0100
commite8204e78a292551bbb363d53411ba959cdc737b4 (patch)
tree9839cde235d31896900cf20f9240ab063d8b0d4d /Main.gd
parent1f7f6c8dc3e55e906ed5f933088c2d1d5fda4923 (diff)
Add homing projectiles
Diffstat (limited to 'Main.gd')
-rw-r--r--Main.gd29
1 files changed, 29 insertions, 0 deletions
diff --git a/Main.gd b/Main.gd
new file mode 100644
index 0000000..958a7a7
--- /dev/null
+++ b/Main.gd
@@ -0,0 +1,29 @@
+extends Node2D
+
+export(PackedScene) var enemy_scene
+# Declare member variables here. Examples:
+# var a = 2
+# var b = "text"
+onready var globals = get_node("/root/Global")
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+ randomize()
+ $EnemySpawnTimer.start()
+
+
+# Called every frame. 'delta' is the elapsed time since the previous frame.
+#func _process(delta):
+# pass
+
+
+func _on_EnemySpawnTimer_timeout():
+ var enemy = enemy_scene.instance()
+ var spawn_loc = get_node("EnemySpawn/EnemySpawnLocation")
+ spawn_loc.offset = randi()
+ #var direction = spawn_loc.rotation + PI / 2
+ enemy.position = spawn_loc.position
+ #enemy.rotation = enemy.position.angle_to_point(globals.playerPos)
+ #var velocity = Vector2(rand_range(150.0, 250.0), 0.0)
+ #enemy.linear_velocity = velocity.rotated(direction)
+ add_child(enemy)