summaryrefslogtreecommitdiff
path: root/Scenes/Entities/Enemies/Projectile.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Scenes/Entities/Enemies/Projectile.gd')
-rw-r--r--Scenes/Entities/Enemies/Projectile.gd28
1 files changed, 28 insertions, 0 deletions
diff --git a/Scenes/Entities/Enemies/Projectile.gd b/Scenes/Entities/Enemies/Projectile.gd
new file mode 100644
index 0000000..af283b4
--- /dev/null
+++ b/Scenes/Entities/Enemies/Projectile.gd
@@ -0,0 +1,28 @@
+extends CharacterBody2D
+
+
+signal hit
+
+@export var target: Vector2
+var direction: Vector2
+
+@export var speed: int = 50
+
+
+func _ready():
+ velocity = position.direction_to(target) * speed
+
+
+func _physics_process(delta):
+ $AnimatedSprite2D.play("default")
+ move_and_slide()
+
+
+func _on_area_2d_body_entered(body):
+ if body is Player:
+ hit.emit()
+ queue_free()
+
+
+func _on_visible_on_screen_notifier_2d_screen_exited():
+ queue_free()