Ejemplo n.º 1
0
void ProjectileWeapon::fireBurst()
{
	if(getAmmoType()!=ammo_unlimited)
	{
		if(ammo==0)
			return;
		ammo--;
		owner->weapons.updateWeapons();
	}
	
	Position ownerPos(owner->getPosition());
	const Position *shotOffsets = owner->type->getWeaponMounts(numProjectiles());
	doSound();
	
	for(unsigned ii=0; ii<numProjectiles(); ii++)
	if(linkedFire() || ii==fireOrder)
	{
		Position shotPosition(ownerPos);

		shotPosition.setX(ownerPos.getX() + shotOffsets[ii].getX()*cos(ownerPos.getR()) + shotOffsets[ii].getY()*sin(ownerPos.getR()));
		shotPosition.setY(ownerPos.getY() - shotOffsets[ii].getX()*sin(ownerPos.getR()) + shotOffsets[ii].getY()*cos(ownerPos.getR()));
		
		shotPosition.setR_vel(0);
		if(!shotsGetShipVel) {
			shotPosition.setX_vel(0);
			shotPosition.setY_vel(0);
		}
		shotPosition.impulse( getSpeed()*cos(shotPosition.getR()), -getSpeed()*sin(shotPosition.getR()) );
		
		createProjectile(&shotPosition);
	}
	fireOrder++;
	if(fireOrder >= numProjectiles())
		fireOrder = 0;
}
Ejemplo n.º 2
0
//Play any music
void runMusic(GameVars* gameVars)
{
    //Execute music commands
    switch (gameVars->musicState) {
        case MSPlaying:
        case MSStopping:
        case MSPausing:
        {
            doSound();
        }
            break;
            
        default:
            break;
    }
    
    //Move transcient music states on
    switch (gameVars->musicState) {
        case MSStopping:
        {
            gameVars->musicState = MSStopped;
        }
            break;
            
        case MSPausing:
        {
            gameVars->musicState = MSPaused;
        }
            break;
            
        default:
            break;
    }

}