summaryrefslogtreecommitdiff
path: root/Enemies/flying_enemy.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Enemies/flying_enemy.gd')
-rw-r--r--Enemies/flying_enemy.gd30
1 files changed, 30 insertions, 0 deletions
diff --git a/Enemies/flying_enemy.gd b/Enemies/flying_enemy.gd
new file mode 100644
index 0000000..701affc
--- /dev/null
+++ b/Enemies/flying_enemy.gd
@@ -0,0 +1,30 @@
+extends Enemy
+
+
+@export var angular_speed = 3.0
+var alpha = 0
+
+enum MovementType {
+ UP_DOWN,
+ FORWARD,
+}
+@export var movement_type: MovementType = MovementType.UP_DOWN
+
+
+func _physics_process(delta: float) -> void:
+ $AnimatedSprite2D.play()
+
+ if movement_type == MovementType.UP_DOWN:
+ velocity.y = sin(alpha) * 32
+ elif movement_type == MovementType.FORWARD:
+ velocity.x = direction * speed
+ velocity.y = sin(alpha) * 16
+
+ alpha += delta * angular_speed
+
+ move_and_slide()
+ if get_last_slide_collision():
+ if $RayLeft.is_colliding():
+ direction = 1
+ elif $RayRight.is_colliding():
+ direction = -1