#include "BulletManager.h"

BulletManager::BulletManager(MainState * state) : GameObject(state)
{
	for(int i = 0; i < BULLET_COUNT; i++)
		m_bullets[i] = new Bullet(state);
}

BulletManager::~BulletManager(void)
{
	for(int i = 0; i < BULLET_COUNT; i++)
		delete m_bullets[i];
}

void BulletManager::Update(float dt)
{
	for(int i = 0; i < BULLET_COUNT; i++)
		m_bullets[i]->Update(dt);
}

void BulletManager::Draw(float dt)
{
	for(int i = 0; i < BULLET_COUNT; i++)
		m_bullets[i]->Draw(dt);
}

bool BulletManager::Intersects(Daram *daram)
{
	for(int i = 0; i < BULLET_COUNT; i++)
	{
		if(powf(daram->x - m_bullets[i]->x, 2) + powf(daram->y - m_bullets[i]->y, 2) <= powf(daram->radius + m_bullets[i]->radius, 2))
			return true;
	}
	return false;
}