#include "cPaddle.hpp"

using Equipment::cPaddle;

cPaddle::cPaddle( const signed long int xpos /*= 0*/, const signed long int ypos /*= 0*/, const signed long int xarea /*= 0*/,
		const signed long int yarea /*= 0*/, const unsigned long int warea /*= 0*/, const unsigned long int harea /*= 0*/,
		VideoEngine::cImage** image /*= nullptr*/, VideoEngine::cCamera** camera /*= nullptr*/ )
: cSprite( xpos, ypos, xarea, yarea, warea, harea, image, camera ), m_speed(0.0), m_pause(false), m_state(Still)
{}

cPaddle::~cPaddle()
{}

///Functions
void cPaddle::Move()
{
	if (m_pause == false)
	{
		float frameTime = TimingEngine::cTiming::Inst().getFrameTime();

		AddPosY((signed long int)(m_speed * frameTime));
	}
}

void cPaddle::Pause()
{
	m_pause = !m_pause;
}

const bool cPaddle::isPaused()
{
	return m_pause;
}

void cPaddle::Reset()
{}

///Sets
void cPaddle::setSpeed( const double speed /*= 0.0*/ )
{
	m_speed = speed;
}

void cPaddle::setState( const eState state /*= eState::Still*/ )
{
	m_state = state;
	switch (m_state)
	{
	case Up:
		m_speed = -25.0;
		break;
	case Still:
		m_speed = 0.0;
		break;
	case Down:
		m_speed = 25.0;
		break;
	default:
		break;
	}
}

const cPaddle::eState cPaddle::getState() const
{
	return m_state;
}