class_name Bullet extends Area2D
@onready var bulletGraphic: Sprite2D = $Sprite2D

var speed = 750

signal hit(bullet, body)

func setSpeed(value):
	speed = value
	if speed <0:
		bulletGraphic.flip_h = true
	if speed >0:
		bulletGraphic.flip_h = false
	
#animation
func _physics_process(delta: float) -> void:
	position += transform.x * speed * delta


func _on_body_entered(body: Node2D) -> void:
	if not body is Player:
		hit.emit(self, body)


func _on_area_entered(area: Area2D) -> void:
	if area is Slime:
		hit.emit(self, area)
