Example #1
0
float Sun::randAngle(float min, float max, float exclMin, float exclMax)
{
	float angle = 0.0f;
	do
	{
		angle = randAngle(min, max);
	} while (angle > exclMin && angle < exclMax);

	return angle;
}
Example #2
0
float Sun::fireAngle()
{
	float spread = 20.0f;
	float angle = 270.0f - 2.0f * spread;

	switch (current_phase_)
	{
	case 0:
		break;
	case 1:
		return randAngle(185.0f, 215.0f);
	case 2:
		return 250.0f;
	case 3:
	case 4:
		return randAngle(250.0f, 290.0f, 255.0f, 285.0f);
	case 5:
		return 230.0f;
	case 6:
	case 7:
	case 8:
		return 180.0f;
	case 9:
	case 10:
	case 11:
	case 12:
	case 13:
	case 14:
		return randAngle(160.0f, 200.0f);
	case 29:
	case 30:
		return 180.0f;
	}

	return 0.0f;
}
Example #3
0
std::vector<Projectile> Hunter::shootBullets(long currentTime)
{
	std::mt19937 randEng;
	randEng.seed(SDL_GetTicks());
	std::uniform_real_distribution<float> randAngle(-4.0, 4.0);
	std::uniform_int_distribution<int> randX(0, 10);
	std::vector<Projectile> bullets;
	if (currentTime >= shootTime)
	{
		for (int i = 0; i < 5; i++)
		{
			MoveableObject newbulletBody;
			double angle = this->body->getDirection() + randAngle(randEng);
			newbulletBody.init(this->body->getPosition(), angle, 20, 20);
			Projectile bullet;
			bullet.init(newbulletBody, TYPE_BULLET, 600, "bulletTexture");
			bullets.push_back(bullet);
		}
		shootTime = currentTime + shootInterval;
	}
	status = WELL;
	action = TRACK;
	return bullets;
}
Example #4
0
int randRightAngle() {
   return randAngle() > 180 ? 0 : 90;
}