extends Node2D


const SPEED = 50.0
var direction = 1.0

@onready var ray_left = $raycastleft
@onready var ray_right = $raycastright
@onready var mysprite = $AnimatedSprite2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	print("slime..ready to eat.")


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	if ray_right.is_colliding():
		direction = -1
		mysprite.flip_h = true
	if ray_left.is_colliding():
		direction = 1 
		mysprite.flip_h = false

	position.x += direction * SPEED * delta
