summaryrefslogtreecommitdiff
path: root/Player/arrow.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Player/arrow.gd')
-rw-r--r--Player/arrow.gd27
1 files changed, 27 insertions, 0 deletions
diff --git a/Player/arrow.gd b/Player/arrow.gd
new file mode 100644
index 0000000..f6cce57
--- /dev/null
+++ b/Player/arrow.gd
@@ -0,0 +1,27 @@
+extends CharacterBody2D
+
+
+var deacceleration := 10.0
+var flying := false
+
+
+func _ready():
+ if OS.has_feature("mobile"):
+ scale = Vector2(2, 2)
+
+
+func _physics_process(delta: float) -> void:
+ velocity = velocity.move_toward(Vector2.ZERO, deacceleration * delta)
+
+ if abs(velocity) > Vector2.ZERO:
+ flying = true
+ $ArrowHead/CollisionShape2D.disabled = false
+
+ if flying and velocity == Vector2.ZERO:
+ queue_free()
+
+ move_and_slide()
+
+
+func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
+ queue_free()