#include "Daram.h"
#include "MainState.h"

Daram::Daram(MainState *mainState) : GameObject(mainState)
{
	m_daram.Create(GetGameState()->GetWindow()->GetGraphics(), GetResource(RC_Daram));
	m_target.Create(GetGameState()->GetWindow()->GetGraphics(), GetResource(RC_Target));
	x = 200; y = 200;
	radius = 4;
}

Daram::~Daram(void)
{
	m_target.Destroy();
	m_daram.Destroy();
}

void Daram::Update(float dt)
{
	float moverange = dt * 2;
	if(GetGameState()->GetWindow()->IsKeyDown(VK_UP))
	{
		if(y > 0)
			y -= moverange;
		if(y < 0)
			y = 0;
	}
	if(GetGameState()->GetWindow()->IsKeyDown(VK_DOWN))
	{
		if(y < 400)
			y += moverange;
		if(y > 400)
			y = 400;
	}
	if(GetGameState()->GetWindow()->IsKeyDown(VK_LEFT))
	{
		if(x > 0)
			x -= moverange;
		if(x < 0)
			x = 0;
	}
	if(GetGameState()->GetWindow()->IsKeyDown(VK_RIGHT))
	{
		if(x < 400)
			x += moverange;
		if(x > 400)
			x = 400;
	}
}

void Daram::Draw(float dt)
{
	m_daram.Draw(x - 23 / 2, y - 23 / 2);
	m_target.Draw(x - 4, y - 4, 100);
}