class_name Arrow
extends Node2D

@onready var sprite: Sprite2D = $Sprite2D

var _direction: Vector2i
var _speed: int = 50

func _ready():
	if _direction.x > 0:
		sprite.flip_h = true
	if _direction.y < 0:
		rotation_degrees = 90
	if _direction.y > 0:
		rotation_degrees = -90

func shoot(dir: Vector2i, speed: int):
	_direction = dir
	_speed = speed

func _physics_process(delta):
	var move = _direction * _speed * delta
	position = position + move


func _on_area_2d_body_entered(body):
	if body is Player:
		body.die()
	queue_free()
