static void think(void)
{
	float dir;
	int wantedAngle;

	if (--self->aiActionTime <= 0)
	{
		findAITarget();
	}

	wantedAngle = steer();

	if (fabs(wantedAngle - self->angle) > TURN_THRESHOLD)
	{
		dir = ((int)(wantedAngle - self->angle + 360)) % 360 > 180 ? -1 : 1;

		dir *= TURN_SPEED;

		self->angle += dir;

		self->angle = mod(self->angle, 360);
	}

	applyFighterThrust();
}
Exemple #2
0
static void handleMouse(void)
{
	faceMouse();
	
	if (battle.status == MS_IN_PROGRESS)
	{
		if (isControl(CONTROL_FIRE) && !player->reload && player->guns[0].type)
		{
			if (player->selectedGunType != BT_ROCKET)
			{
				fireGuns(player);
			}
			else
			{
				fireRocket(player);
			}
			
			if (battle.hasSuspicionLevel && !battle.numEnemies && !battle.suspicionCoolOff)
			{
				battle.suspicionLevel += (MAX_SUSPICION_LEVEL * 0.05);
			}
		}
		
		if (isControl(CONTROL_ACCELERATE))
		{
			if (battle.boostTimer > BOOST_FINISHED_TIME || game.currentMission->challengeData.noBoost)
			{
				applyFighterThrust();
			}
		}
		
		if (isControl(CONTROL_MISSILE))
		{
			preFireMissile();
			
			app.mouse.button[SDL_BUTTON_MIDDLE] = 0;
		}
		
		if (isControl(CONTROL_GUNS))
		{
			switchGuns();
			
			app.mouse.button[SDL_BUTTON_X1] = 0;
		}
		
		if (isControl(CONTROL_RADAR))
		{
			cycleRadarZoom();
			
			app.mouse.button[SDL_BUTTON_X2] = 0;
		}
	}
}