void SpawnFirework() {

	Firework * newFirework;

	//make 1 in 4 fireworks a dazzle firework
	if ((int)rand() % 4 == 1)
		newFirework = new DazzleFirework(_particleTexture);

	//and the rest just normal fireworks
	else
		newFirework = new Firework(_particleTexture);

	//place it at a random position around the point (-3, -3, -7)
	Vector3 pos = Vector3(-3, -3, -7);
	Vector3 randOffset;
	randOffset.random(5);
	//giving the variation in position added weight on the x axis so the fireworks spread out more
	randOffset.x *= 1.5f;
	pos = pos + randOffset;
	newFirework->Origin = pos;

	//make it a random colour
	RGBA randColour;
	randColour.random();
	randColour.a = 1;
	newFirework->ExplodeColour = randColour;

	//other poperties I like
	newFirework->ShouldEmitTrail = true;

	//make it a rare chance that some of the fireworks have different settings
	if ((int) rand() % 3 == 1) {

		newFirework->BlendFactor = GL_ONE_MINUS_SRC_COLOR;
		newFirework->TrailLifeModifier = 0.6;
		newFirework->ExplodeSpeed = 0.65f;
	}

	//make it launch for a random time
	float launchTime = (float)rand() / ((float)RAND_MAX / 1.5) + 1.7f;

	//add to list
	_fireworks.push_back(newFirework);

	//launch the firework
	newFirework->launchWithDuration(launchTime);

	_activeFireworks++;
}
//Spawn a particle according to the particle system's vars
void ParticleSystem::spawnParticle() {

	//create a new particle
	Particle * newParticle = new Particle();
	_activeParticles.push_back(newParticle);

	_totalActiveParticles++;

	//set particle variables by applying a random variance to the related variance

	//working out position with variance
	Vector3 randomOffset;
	randomOffset.random(2);
	randomOffset.z = 0;
	newParticle->Position = (Origin - OriginVariance) + (OriginVariance * randomOffset);

	//working out the various properties with variance
	newParticle->Scale = (StartScale - StartScaleVariance) + StartScaleVariance * ((float)rand() / ((float)RAND_MAX / 2));
	newParticle->EndScale = (EndScale - EndScaleVariance) + EndScaleVariance * ((float)rand() / ((float)RAND_MAX / 2));
	newParticle->MaxAge = (ParticleLife - ParticleLifeVariance) + ParticleLifeVariance * ((float)rand() / ((float)RAND_MAX / 2));

	//working out the colour variances
	RGBA randomColourOffset;
	randomColourOffset.random();
	newParticle->Colour = (StartColour - StartColourVariance) + StartColourVariance * randomColourOffset * 2;

	//if the end colours are all -1, then programmer wants the end colour to be the same as the calculated start colour
	if (EndColour.r == -1 && EndColour.g == -1 && EndColour.b == -1) {

		newParticle->EndColour = newParticle->Colour;
		newParticle->EndColour.a = EndColour.a;
	}

	else
		newParticle->EndColour = (EndColour - EndColourVariance) + EndColourVariance * randomColourOffset;

	//if the alpha chanel is -1 then programmer wants end alpha to be same as calculated start alpha
	if (EndColour.a == -1)
		newParticle->EndColour.a = newParticle->Colour.a;

	//work out the direction for the particle by adjusting the starting angle
	float randomAngle = (Angle - AngleVariance) + AngleVariance * ((float)rand() / ((float)RAND_MAX / 2));
	//convert to radians
	float radians = (3.141592 * (randomAngle + 90)) / 180;
	//convert radian angle to direction vector
	newParticle->MoveVector = Vector3(-cosf(radians), sinf(radians), 0);
	float randMoveSpeed = (MoveSpeed - MoveVariance) + MoveVariance * ((float)rand() / ((float)RAND_MAX / 2));
	newParticle->MoveVector = newParticle->MoveVector * randMoveSpeed;
}