extends CharacterBody2D


const SPEED = 300.0


func _physics_process(_delta: float) -> void:
	# Add the gravity.
	
	var direction = Vector2(0, 0)
	if Input.is_action_pressed("ui_up"):
		direction.y -= 1
	if Input.is_action_pressed("ui_down"):
		direction.y += 1
	if Input.is_action_pressed("ui_right"):
		direction.x += 1
	if Input.is_action_pressed("ui_left"):
		direction.x -= 1

	#var direction := Input.get_axis("ui_left", "ui_right")
	if direction:
		velocity = direction * SPEED
	else:
		#velocity.x = move_toward(velocity, Vector2(0,0), Vector2(SPEED, SPEED))
		velocity = Vector2(0,0)
	print(velocity)
	move_and_slide()
