#include "bomb.h"
#include "player.h"

Bomb::Bomb(int id, int x, int y, QCanvasSprite *sprite, Player *player)
	: Sprite(id, x, y, sprite)
{
	m_step = 30;
	m_player = player;
	m_delayed = false;
	m_moveable = false;
	m_flash = false;
}

void Bomb::proceed()
{
	if(m_delayed) return;

	if (m_step != 0)
		m_step--;

	if (!finished()) {
		if((m_sprite) && (m_sprite->frameCount() > 1))
			m_sprite->setFrame(!m_sprite->frame());
	}
}

int Bomb::finished()
{
	if (m_step > 0)
		return 0;
	else {
		if(m_sprite) m_sprite->hide();
		return 1;
	}
}

Player *Bomb::player(void)
{
	return m_player;
}

void Bomb::delay(bool delayed)
{
	if((m_delayed) && (!delayed)) m_step = 0;
	m_delayed = delayed;

}

void Bomb::setMoveable(bool moveable)
{
	m_moveable = moveable;
}

bool Bomb::moveable()
{
	return m_moveable;
}

void Bomb::setFlash(bool flash)
{
	m_flash = flash;
}

bool Bomb::flash()
{
	return m_flash;
}
