summaryrefslogtreecommitdiff
path: root/air_shot.gd
diff options
context:
space:
mode:
Diffstat (limited to 'air_shot.gd')
-rw-r--r--air_shot.gd34
1 files changed, 34 insertions, 0 deletions
diff --git a/air_shot.gd b/air_shot.gd
new file mode 100644
index 0000000..ba2688d
--- /dev/null
+++ b/air_shot.gd
@@ -0,0 +1,34 @@
+extends Area2D
+
+
+signal hit(node: Node2D)
+signal end_of_life
+
+var tween: Tween
+
+@export var direction: float
+
+
+func _ready() -> void:
+ $Sound.play()
+ $Sprite2D.flip_h = direction < 0
+
+ tween = get_tree().create_tween()
+ tween.tween_property(
+ self,
+ "global_position",
+ global_position + Vector2(sign(direction) * 64, 0),
+ 0.3
+ ).set_ease(Tween.EASE_OUT)
+ tween.tween_callback(func():
+ end_of_life.emit()
+ )
+
+
+func _on_area_entered(area: Area2D) -> void:
+ tween.stop()
+ hit.emit(area)
+
+func _on_body_entered(body: Node2D) -> void:
+ tween.stop()
+ hit.emit(body)