class_name Projectile
extends Area2D

# constants
@export var speed = 10
@export var damage = 5
@export var friendly = false

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	body_entered.connect(_on_projectile_body_entered)


func _physics_process(delta: float) -> void:
	position += transform.x * speed * delta

func _on_projectile_body_entered(target):
	if target is Flyer && friendly != target.friendly:
		target.deal_damage(damage)
		queue_free()
