#include "sprite.h"

int Sprite::m_tilesize = 0;

Sprite::Sprite(int id, int x, int y, QCanvasSprite* sprite)
{
	m_id = id;
	m_x = x;
	m_y = y;
	m_sprite = sprite;

	if (m_sprite) {
		m_sprite->move(m_tilesize * m_x, m_tilesize * m_y);
		m_sprite->show();
	}
	
	m_finished = 0;
	m_step = 0;
}

Sprite::~Sprite(void)
{
	if (m_sprite) {
		m_sprite->hide();
		delete m_sprite;
	}

	m_sprite = 0;
}

int Sprite::id()
{
	return m_id;
}

void Sprite::proceed()
{
	m_step++;
}

QCanvasSprite* Sprite::sprite(void)
{
	return m_sprite;
}

void Sprite::setSprite(QCanvasPixmapArray *a)
{
	m_sprite->setSequence(a);
}

int Sprite::x(void)
{
	return m_x;
}

int Sprite::y(void)
{
	return m_y;
}

void Sprite::move(int x, int y)
{
	m_x = x;
	m_y = y;

	m_sprite->move(m_tilesize * m_x, m_tilesize * m_y);
}

void Sprite::setStep(int step)
{
	m_step = step;
}

int Sprite::finished(void)
{
	return m_finished;
}

void Sprite::setTilesize(int tilesize)
{
	m_tilesize = tilesize;
}

