#include "Entity.h"

Box::Box() : Sprite()
{
	marked = false;
}

void Box::setCellPosition(Vector2i position)
{
	cellPosition = position;
}

Vector2i Box::getCellPosition()
{
	return cellPosition;
}

void Box::mark()
{
	marked = true;
	setTextureRect(IntRect(48, 0, CELL_SIZE, CELL_SIZE));
}

bool Box::isMarked()
{
	return marked;
}

void Box::moveUp()
{
	if (cellPosition.y > 0)
	{
		cellPosition.y--;

		Vector2f position = getPosition();
		position.y -= CELL_SIZE;
		setPosition(position);

		marked = false;
		setTextureRect(IntRect(36, 0, CELL_SIZE, CELL_SIZE));
	}
}

void Box::moveRight()
{
	if (cellPosition.x < MAP_SIZE_X - 1)
	{
		cellPosition.x++;

		Vector2f position = getPosition();
		position.x += CELL_SIZE;
		setPosition(position);

		marked = false;
		setTextureRect(IntRect(36, 0, CELL_SIZE, CELL_SIZE));
	}
}

void Box::moveDown()
{
	if (cellPosition.y < MAP_SIZE_Y - 1)
	{
		cellPosition.y++;

		Vector2f position = getPosition();
		position.y += CELL_SIZE;
		setPosition(position);

		marked = false;
		setTextureRect(IntRect(36, 0, CELL_SIZE, CELL_SIZE));
	}
}

void Box::moveLeft()
{
	if (cellPosition.x > 0)
	{
		cellPosition.x--;

		Vector2f position = getPosition();
		position.x -= CELL_SIZE;
		setPosition(position);

		marked = false;
		setTextureRect(IntRect(36, 0, CELL_SIZE, CELL_SIZE));
	}
}
	
void Box::update()
{
	//Vector2f position = getPosition();
}


Player::Player() : Sprite()
{

}

void Player::setCellPosition(Vector2i position)
{
	cellPosition = position;
}

Vector2i Player::getCellPosition()
{
	return cellPosition;
}

void Player::moveUp()
{
	if (cellPosition.y > 0)
	{
		cellPosition.y--;

		Vector2f position = getPosition();
		position.y -= CELL_SIZE;
		setPosition(position);
	}
}

void Player::moveRight()
{
	if (cellPosition.x < MAP_SIZE_X - 1)
	{
		cellPosition.x++;

		Vector2f position = getPosition();
		position.x += CELL_SIZE;
		setPosition(position);
	}
}

void Player::moveDown()
{
	if (cellPosition.y < MAP_SIZE_Y - 1)
	{
		cellPosition.y++;

		Vector2f position = getPosition();
		position.y += CELL_SIZE;
		setPosition(position);
	}
}

void Player::moveLeft()
{
	if (cellPosition.x > 0)
	{
		cellPosition.x--;

		Vector2f position = getPosition();
		position.x -= CELL_SIZE;
		setPosition(position);
	}
}
	
void Player::update()
{
	//Vector2f position = getPosition();
}