void keyboard(unsigned char key, int x, int y)
{
	if (key == 'q')
	{
		tank1.RotateBarrel(-5);
	}
	else if (key == 'e')
	{
		tank1.RotateBarrel(5);
	}
	else if (key == 'a')
	{
		tank1.ChangeBulletPower(1);
		std::cout << "Bullet power: " << tank1.GetBulletPower() << std::endl;
	}
	else if (key == 'd')
	{
		tank1.ChangeBulletPower(-1);
		std::cout << "Bullet power: " << tank1.GetBulletPower() << std::endl;
	}
	else if (key == 'z')
	{
		bullet.Fire(
			tank1.GetEndOfBarrelPosition(),
			tank1.GetBulletPower(),
			tank1.GetBarrelAngle()
			);
	}
}
Esempio n. 2
0
void keyboard(unsigned char key, int x, int y)//poszukac czegos na wzor qt
{
	if (tank1.GetLife() > 0 && tank2.GetLife() > 0)
	{
		//przód
		if (key == 'w')
		{
			tank1.Move(0, +0.1, 0);
		}
		if (key == 'i')
		{
			tank2.Move(0, +0.1, 0);
		}
		//ty³
		if (key == 's')
		{
			tank1.Move(0, -0.1, 0);
		}
		if (key == 'k')
		{
			tank2.Move(0, -0.1, 0);
		}
		//prawo
		if (key == 'd')
		{
			tank1.switchAngle(-5);
		}
		if (key == 'l')
		{
			tank2.switchAngle(-5);
		}
		//lewo
		if (key == 'a')
		{
			tank1.switchAngle(5);
		}
		if (key == 'j')
		{
			tank2.switchAngle(5);
		}
		// zmiana mocy pocisku dla czolgu pierwszego
		if (key == 'q')
		{
			tank1.ChangeBulletPower(1);
			std::cout << "Bullet power: " << tank1.GetBulletPower() << std::endl;
		}
		else if (key == 'z')
		{
			tank1.ChangeBulletPower(-1);
			std::cout << "Bullet power: " << tank1.GetBulletPower() << std::endl;
		}
		// strzal dla czolgu pierwszego
		else if (key == 'e')
		{
			tank1.FireBullet();
		}
		// si³a pocisku drugiego
		if (key == 'u')
		{
			tank2.ChangeBulletPower(1);
			std::cout << "Bullet power: " << tank2.GetBulletPower() << std::endl;
		}
		else if (key == 'n')
		{
			tank2.ChangeBulletPower(-1);
			std::cout << "Bullet power: " << tank2.GetBulletPower() << std::endl;
		}
		// strzal drugiego pocisku
		else if (key == 'o')
		{

			tank2.FireBullet();
		}
	}
}