summaryrefslogtreecommitdiff
path: root/Enemies/enemy.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Enemies/enemy.gd')
-rw-r--r--Enemies/enemy.gd23
1 files changed, 23 insertions, 0 deletions
diff --git a/Enemies/enemy.gd b/Enemies/enemy.gd
new file mode 100644
index 0000000..5818fb4
--- /dev/null
+++ b/Enemies/enemy.gd
@@ -0,0 +1,23 @@
+extends CharacterBody2D
+
+
+const SPEED = 30
+
+
+func _ready() -> void:
+ set_physics_process(false)
+
+
+func _physics_process(delta: float) -> void:
+ $AnimatedSprite2D.play()
+
+ if not is_on_floor():
+ velocity += get_gravity() * delta
+
+ velocity.x = -SPEED
+
+ move_and_slide()
+
+
+func _on_visible_on_screen_notifier_2d_screen_entered() -> void:
+ set_physics_process(true)