extends CharacterBody2D

@export var speed = 100
var last_dpad: Array[Vector2] = [Vector2.ZERO,Vector2.ZERO]
const FACING_ANGLE_EPSILON = 15

#func _physics_process(_delta):
	#get_input()
	#move_and_slide()
	#
#func xor(a:bool, b:bool):
	#return a != b
#
#func get_input():
	#var vertical = Input.get_axis("up", "down")
	#var horizontal = Input.get_axis("left", "right")
	#var input_direction = Vector2(horizontal, vertical)
	#var input_angle = rad_to_deg(atan2(vertical,horizontal))
	#
	#var test = xor(abs(input_direction.dot(Vector2.RIGHT)) > 0.5, abs(input_direction.dot(Vector2.UP)) > 0.5)
	#
	## Keep lateral directions when moving diagonally
	## if the player moves in one direction and then diagonally
	## (i.e. first left then up-left)
	#if test or input_direction == Vector2.ZERO:
		#last_dpad[1] = last_dpad[0]
		#last_dpad[0] = input_direction
	#if last_dpad[0] == Vector2.ZERO and input_direction != Vector2.ZERO:
		#last_dpad[0] = input_direction
		#
	#velocity = input_direction * speed
#
	#if input_direction == Vector2.ZERO:
		#$AnimationTree.set("parameters/conditions/is_moving", false)
	#else:
		#$AnimationTree.set("parameters/conditions/is_moving", true)
		#$AnimationTree.set("parameters/idle/blend_position", last_dpad[0])
		#$AnimationTree.set("parameters/walk/blend_position", last_dpad[0])


func _on_player_attack_did_hit(other: Area2D):
	if other.get_parent().get_instance_id() == get_instance_id() :
		print(other.get_parent().name + " OUCHHHHH")
