class_name Slime extends Area2D
@onready var right_side_cast: RayCast2D = $rightSideCast
@onready var left_side_cast: RayCast2D = $leftSideCast
@onready var right_down_cast: RayCast2D = $rightDownCast
@onready var left_down_cast: RayCast2D = $leftDownCast
var direction = 1
var speed = 100

@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D

signal playerDamageSignal

func _process(delta: float) -> void:
	if not right_down_cast.is_colliding():
		#about to fall on the right....
		direction = -1
		sprite.flip_h = true
	if not left_down_cast.is_colliding():
		direction = 1
		sprite.flip_h = false
		
	position.x += direction * speed * delta
	
func _on_body_entered(body: Node2D) -> void:
	playerDamageSignal.emit(body, self)
