summaryrefslogtreecommitdiff
path: root/Player/arrow.gd
blob: f6cce57dfd836c4ce1082d1d913513aa713aa225 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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()