#include "player.h"
#include "graphics.h"
#include "mouse.h"
#include "bullet.h"
#include "enemy.h"
#include "stage.h"
#include "explodies.h"
#include "sound.h"


gxSprite explosionSprite;//The explosion
sxSound ExplodiesSound;

Explosion explodies[30];


void InitExplodies()
{
	for(int i = 0; i < 30; i++)
	{
		explodies[i].active = false;
	}

	gxLoadBmp( "explosion.tga", &explosionSprite, 0 );
	sxLoadWav ( "explodies.wav", &ExplodiesSound );
}

void UpdateExplodies()
{
	for(int i = 0; i < 30; i++)
	{
		if(explodies[i].active == true)
		{
			explodies[i].timer += 10;
			if (explodies[i].timer > 200)
				explodies[i].active = false;
			gxDrawSpriteScaledAlphaAdd(
				(explodies[i].x - explodies[i].timer*10 / 2)-xAxis, (explodies[i].y - explodies[i].timer*10 / 2)-yAxis, 
				&explosionSprite, 
				explodies[i].timer*10, explodies[i].timer*10,
				255-explodies[i].timer);
		}
	}
}



void CreateExplodies(int x, int y)
{
	for(int j = 0; j < 30; j++)
	{
		if(explodies[j].active == false)//finds whether or not the explosion is false, if it is we explode it.
		{
			sxPlaySound ( &ExplodiesSound );
			explodies[j].timer = 0;
			explodies[j].active = true;
			explodies[j].x = x;
			explodies[j].y = y;
			break;
		}
	}
}