当前位置: 首页>>代码示例>>C++>>正文


C++ Aircraft类代码示例

本文整理汇总了C++中Aircraft的典型用法代码示例。如果您正苦于以下问题:C++ Aircraft类的具体用法?C++ Aircraft怎么用?C++ Aircraft使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Aircraft类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getAircraft

void World::removeAircraft(int identifier) {
    Aircraft* aircraft = getAircraft(identifier);
    if (aircraft) {
        aircraft->destroy();
        mPlayerAircrafts.erase(std::find(mPlayerAircrafts.begin(), mPlayerAircrafts.end(), aircraft));
    }
}
开发者ID:WillSams,项目名称:SFML-Book-Exercises,代码行数:7,代码来源:World.cpp

示例2: GetAircraft

void World::RemoveAircraft( int identifier )
{
	Aircraft* aircraft = GetAircraft( identifier );
	if ( aircraft )
	{
		aircraft->Destroy();
		pImpl->mPlayerAircrafts.erase( std::find( pImpl->mPlayerAircrafts.begin(), pImpl->mPlayerAircrafts.end(), aircraft ) );
	}
}
开发者ID:chehob,项目名称:SFMLDev,代码行数:9,代码来源:World.cpp

示例3: Aircraft

Aircraft * Aircraft::createAircraft(const std::string & filename) {
    Aircraft * aircraft = new Aircraft();
    if (aircraft && aircraft->initWithSpriteFrameName(filename)) {
        aircraft->autorelease();
        return aircraft;
    }
    CC_SAFE_DELETE(aircraft);
    return nullptr;
}
开发者ID:LucienLIUFL,项目名称:Project,代码行数:9,代码来源:Aircraft.cpp

示例4: evolve

void Simulation::evolve(Aircraft& aircraft, UnitTime time) {
    Coordinate coordiante = aircraft.evolve(time);

    std::vector<SimulationListener>::iterator iterator = simulationListeners.begin();
    while (iterator != simulationListeners.end()) {
        SimulationListener simulationListener = *iterator;
        simulationListener.notify(aircraft.getName(), coordiante);
    }
}
开发者ID:pinheirofs,项目名称:ats,代码行数:9,代码来源:simulation.cpp

示例5: while

/**
 * Clean up a station by clearing vehicle orders and invalidating windows.
 * Aircraft-Hangar orders need special treatment here, as the hangars are
 * actually part of a station (tiletype is STATION), but the order type
 * is OT_GOTO_DEPOT.
 */
Station::~Station()
{
	if (CleaningPool()) {
		for (CargoID c = 0; c < NUM_CARGO; c++) {
			this->goods[c].cargo.OnCleanPool();
		}
		return;
	}

	while (!this->loading_vehicles.empty()) {
		this->loading_vehicles.front()->LeaveStation();
	}

	Aircraft *a;
	FOR_ALL_AIRCRAFT(a) {
		if (!a->IsNormalAircraft()) continue;
		if (a->targetairport == this->index) a->targetairport = INVALID_STATION;
	}

	Vehicle *v;
	FOR_ALL_VEHICLES(v) {
		/* Forget about this station if this station is removed */
		if (v->last_station_visited == this->index) {
			v->last_station_visited = INVALID_STATION;
		}
	}

	/* Clear the persistent storage. */
	delete this->airport.psa;

	if (this->owner == OWNER_NONE) {
		/* Invalidate all in case of oil rigs. */
		InvalidateWindowClassesData(WC_STATION_LIST, 0);
	} else {
		InvalidateWindowData(WC_STATION_LIST, this->owner, 0);
	}

	DeleteWindowById(WC_STATION_VIEW, index);

	/* Now delete all orders that go to the station */
	RemoveOrderFromAllVehicles(OT_GOTO_STATION, this->index);

	/* Remove all news items */
	DeleteStationNews(this->index);

	for (CargoID c = 0; c < NUM_CARGO; c++) {
		this->goods[c].cargo.Truncate(0);
	}

	CargoPacket::InvalidateAllFrom(this->index);
}
开发者ID:davidwlewis,项目名称:openttd-cargodist,代码行数:57,代码来源:station.cpp

示例6: guideMissiles

void World::guideMissiles()
{
    // Setup command that stores all enemies in mActiveEnemies
	Command enemyCollector;
	enemyCollector.category = Category::EnemyAircraft;
	enemyCollector.action = derivedAction<Aircraft>([this] (Aircraft& enemy, sf::Time)
	{
	    if(!enemy.isDestroyed())
		{
		    mActiveEnemies.push_back(&enemy);
		}
	});
	
	// Setup command that guides all missiles to the enemy which is currently closest to the player
	Command missileGuider;
	missileGuider.category = Category::AlliedProjectile;
	missileGuider.action = derivedAction<Projectile>([this] (Projectile& missile, sf::Time)
	{
	    // Ignore unguided bullets
		if(!missile.isGuided())
		{
		    return;
		}
		
		float minDistance = std::numeric_limits<float>::max();
		Aircraft* closestEnemy = nullptr;
		
		// Find closest enemy
		for(Aircraft* enemy : mActiveEnemies)
		{
	        float enemyDistance = distance(missile, *enemy);
			
			if(enemyDistance < minDistance)
			{
			    closestEnemy = enemy;
			    minDistance = enemyDistance;
			}
		}
		
		if(closestEnemy)
		{
		    missile.guideTowards(closestEnemy->getWorldPosition());
		}
	});
	
	// Push commands, reset active enemies
	mCommandQueue.push(enemyCollector);
	mCommandQueue.push(missileGuider);
	mActiveEnemies.clear();
}
开发者ID:jimmybeer,项目名称:TAGEngine,代码行数:50,代码来源:World.cpp

示例7: while

void Simulation::evolveAllAircarft() {
    vector<Aircraft>::iterator iterator = aircrafts.begin();
    while (iterator != aircrafts.end()) {
        Aircraft aircraft = *iterator;

        UnitTime deltaTime = getTime() - startedTime;
        if (!aircraft.isFlying(deltaTime)) {
            aircrafts.erase(iterator);
        } else {
            evolve(aircraft, deltaTime);
        }

        iterator++;
    }
}
开发者ID:pinheirofs,项目名称:ats,代码行数:15,代码来源:simulation.cpp

示例8: main

int main(int argc, char* argv[]) {
	Aircraft* pac;

	pac = new First;
	pac->Normal();
	delete pac;
	cout <<"----------" <<endl;

	pac = new Second;
	pac->Normal();
	delete pac;
	cout <<"----------" <<endl;

	return 0;
} ///:~
开发者ID:turmary,项目名称:smalls,代码行数:15,代码来源:T15-15.cpp

示例9: Colliding

bool Aircraft::Colliding(const Aircraft &Other) const
{
    const sf::Vector2f &Me = Shape.getPosition();
    const sf::Vector2f &Pos = Other.Shape.getPosition();
    return OnRunway() == Other.OnRunway() &&
           InRange(Me, Pos, (Radius + Other.Radius) / 1.3f);
}
开发者ID:sim642,项目名称:AirTraffic,代码行数:7,代码来源:Aircraft.cpp

示例10: while

/**
 * Clean up a station by clearing vehicle orders and invalidating windows.
 * Aircraft-Hangar orders need special treatment here, as the hangars are
 * actually part of a station (tiletype is STATION), but the order type
 * is OT_GOTO_DEPOT.
 */
Station::~Station()
{
	if (CleaningPool()) return;

	while (!this->loading_vehicles.empty()) {
		this->loading_vehicles.front()->LeaveStation();
	}

	Aircraft *a;
	FOR_ALL_AIRCRAFT(a) {
		if (!a->IsNormalAircraft()) continue;
		if (a->targetairport == this->index) a->targetairport = INVALID_STATION;
	}

	Vehicle *v;
	FOR_ALL_VEHICLES(v) {
		/* Forget about this station if this station is removed */
		if (v->last_station_visited == this->index) {
			v->last_station_visited = INVALID_STATION;
		}
	}

	this->sign.MarkDirty();
	InvalidateWindowData(WC_STATION_LIST, this->owner, 0);

	DeleteWindowById(WC_STATION_VIEW, index);
	WindowNumber wno = (this->index << 16) | VLW_STATION_LIST | this->owner;
	DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
	DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11));
	DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
	DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11));

	/* Now delete all orders that go to the station */
	RemoveOrderFromAllVehicles(OT_GOTO_STATION, this->index);

	/* Remove all news items */
	DeleteStationNews(this->index);

	for (CargoID c = 0; c < NUM_CARGO; c++) {
		this->goods[c].cargo.Truncate(0);
	}

	CargoPacket::InvalidateAllFrom(this->index);
}
开发者ID:Voxar,项目名称:OpenTTD,代码行数:50,代码来源:station.cpp

示例11: Distance

void
World::guideMissiles() {
    Command enemyCollector;
    enemyCollector.category = Category::EnemyAircraft;
    enemyCollector.action   = derivedAction<Aircraft>(
        [this] ( Aircraft& enemy, sf::Time ) {
            if ( !enemy.IsDestroyed() ) {
                mActiveEnemies.push_back( &enemy );
            }
        }
    );

    Command missileGuider;
    missileGuider.category  = Category::AlliedProjectile;
    missileGuider.action    = derivedAction<Projectile>(
        // TODO: outsource this function into separate method
        [this] ( Projectile& missile, sf::Time ) {
            // Ignore unguided bullets
            if ( !missile.IsGuided() ) {
                return;
            }

            float minDistance       = std::numeric_limits<float>::max();
            Aircraft* closestEnemy  = nullptr;

            for( Aircraft* enemy : mActiveEnemies ) {
                float enemyDistance = Distance( missile, *enemy );

                if ( enemyDistance < minDistance ) {
                    closestEnemy    = enemy;
                    minDistance     = enemyDistance;
                }
            }
            if ( closestEnemy ) {
                missile.GuideTowards( closestEnemy->GetWorldPosition() );
            }
        }
    );

    mCommandQueue.push( enemyCollector );
    mCommandQueue.push( missileGuider );
    mActiveEnemies.clear();
}
开发者ID:montreal91,项目名称:workshop,代码行数:43,代码来源:World.cpp

示例12: UpdateOldAircraft

/** need to be called to load aircraft from old version */
void UpdateOldAircraft()
{
	/* set airport_flags to 0 for all airports just to be sure */
	Station *st;
	FOR_ALL_STATIONS(st) {
		st->airport.flags = 0; // reset airport
	}

	Aircraft *a;
	FOR_ALL_AIRCRAFT(a) {
		/* airplane has another vehicle with subtype 4 (shadow), helicopter also has 3 (rotor)
		 * skip those */
		if (a->IsNormalAircraft()) {
			/* airplane in terminal stopped doesn't hurt anyone, so goto next */
			if ((a->vehstatus & VS_STOPPED) && a->state == 0) {
				a->state = HANGAR;
				continue;
			}

			AircraftLeaveHangar(a, a->direction); // make airplane visible if it was in a depot for example
			a->vehstatus &= ~VS_STOPPED; // make airplane moving
			UpdateAircraftCache(a);
			a->cur_speed = a->vcache.cached_max_speed; // so aircraft don't have zero speed while in air
			if (!a->current_order.IsType(OT_GOTO_STATION) && !a->current_order.IsType(OT_GOTO_DEPOT)) {
				/* reset current order so aircraft doesn't have invalid "station-only" order */
				a->current_order.MakeDummy();
			}
			a->state = FLYING;
			AircraftNextAirportPos_and_Order(a); // move it to the entry point of the airport
			GetNewVehiclePosResult gp = GetNewVehiclePos(a);
			a->tile = 0; // aircraft in air is tile=0

			/* correct speed of helicopter-rotors */
			if (a->subtype == AIR_HELICOPTER) a->Next()->Next()->cur_speed = 32;

			/* set new position x,y,z */
			SetAircraftPosition(a, gp.x, gp.y, GetAircraftFlyingAltitude(a));
		}
	}
}
开发者ID:dolly22,项目名称:openttd-sai,代码行数:41,代码来源:vehicle_sl.cpp

示例13: guideMissiles

void World::guideMissiles()
{
    Command enemyCollector;
    enemyCollector.category = Category::EnemyAircraft;
    enemyCollector.action = derivedAction<Aircraft>(
            [this](Aircraft& enemy, sf::Time)
                {
                    if(!enemy.isDestroyed())
                        mActiveEnemies.push_back(&enemy);
                });
    Command missileGuider;
    missileGuider.category = Category::AlliedProjectile;
    missileGuider.action = derivedAction<Projectile>(
            [this](Projectile& missile, sf::Time)
                 {
                     if(!missile.isGuided())
                         return;
                     float minDistance = std::numeric_limits<float>::max();
                     Aircraft* closestEnemy = nullptr;
                     
                     for(auto* enemy : mActiveEnemies)
                     {
                         float enemyDistance = distance(missile, *enemy);
                         
                         if(enemyDistance < minDistance)
                         {
                             closestEnemy = enemy;
                             minDistance = enemyDistance;
                         }
                     }
                     if (closestEnemy)
                     {
                         missile.guideTowards(closestEnemy->getWorldPosition());
                     }
                 });
    mCommandQueue.push(enemyCollector);
    mCommandQueue.push(missileGuider);
    mActiveEnemies.clear();
}
开发者ID:kevin5396,项目名称:Hellfire,代码行数:39,代码来源:World.cpp

示例14: calculate_forces

// calculate rotational and linear accelerations
void Frame::calculate_forces(const Aircraft &aircraft,
                             const Aircraft::sitl_input &input,
                             Vector3f &rot_accel,
                             Vector3f &body_accel)
{
    Vector3f thrust; // newtons

    for (uint8_t i=0; i<num_motors; i++) {
        Vector3f mraccel, mthrust;
        motors[i].calculate_forces(input, thrust_scale, motor_offset, mraccel, mthrust);
        rot_accel += mraccel;
        thrust += mthrust;
    }

    body_accel = thrust/aircraft.gross_mass();

    if (terminal_rotation_rate > 0) {
        // rotational air resistance
        const Vector3f &gyro = aircraft.get_gyro();
        rot_accel.x -= gyro.x * radians(400.0) / terminal_rotation_rate;
        rot_accel.y -= gyro.y * radians(400.0) / terminal_rotation_rate;
        rot_accel.z -= gyro.z * radians(400.0) / terminal_rotation_rate;
    }

    if (terminal_velocity > 0) {
        // air resistance
        Vector3f air_resistance = -aircraft.get_velocity_air_ef() * (GRAVITY_MSS/terminal_velocity);
        body_accel += aircraft.get_dcm().transposed() * air_resistance;
    }

    // add some noise
    const float gyro_noise = radians(0.1);
    const float accel_noise = 0.3;
    const float noise_scale = thrust.length() / (thrust_scale * num_motors);
    rot_accel += Vector3f(aircraft.rand_normal(0, 1),
                          aircraft.rand_normal(0, 1),
                          aircraft.rand_normal(0, 1)) * gyro_noise * noise_scale;
    body_accel += Vector3f(aircraft.rand_normal(0, 1),
                           aircraft.rand_normal(0, 1),
                           aircraft.rand_normal(0, 1)) * accel_noise * noise_scale;
}
开发者ID:ArmaJo,项目名称:ardupilot,代码行数:42,代码来源:SIM_Frame.cpp

示例15: calculate_forces

// calculate rotational and linear accelerations
void Frame::calculate_forces(const Aircraft &aircraft,
                             const Aircraft::sitl_input &input,
                             Vector3f &rot_accel,
                             Vector3f &body_accel)
{
    // rotational acceleration, in rad/s/s, in body frame
    float thrust = 0.0f; // newtons

    for (uint8_t i=0; i<num_motors; i++) {
        float motor_speed = constrain_float((input.servos[motor_offset+motors[i].servo]-1100)/900.0, 0, 1);
        rot_accel.x  += -radians(5000.0) * sinf(radians(motors[i].angle)) * motor_speed;
        rot_accel.y  +=  radians(5000.0) * cosf(radians(motors[i].angle)) * motor_speed;
        rot_accel.z += motors[i].yaw_factor * motor_speed * radians(400.0);
        thrust += motor_speed * thrust_scale; // newtons
    }

    body_accel = Vector3f(0, 0, -thrust / mass);

    if (terminal_rotation_rate > 0) {
        // rotational air resistance
        const Vector3f &gyro = aircraft.get_gyro();
        rot_accel.x -= gyro.x * radians(400.0) / terminal_rotation_rate;
        rot_accel.y -= gyro.y * radians(400.0) / terminal_rotation_rate;
        rot_accel.z -= gyro.z * radians(400.0) / terminal_rotation_rate;
    }

    if (terminal_velocity > 0) {
        // air resistance
        Vector3f air_resistance = -aircraft.get_velocity_ef() * (GRAVITY_MSS/terminal_velocity);
        body_accel += aircraft.get_dcm().transposed() * air_resistance;
    }

    // add some noise
    const float gyro_noise = radians(0.1);
    const float accel_noise = 0.3;
    const float noise_scale = thrust / (thrust_scale * num_motors);
    rot_accel += Vector3f(aircraft.rand_normal(0, 1),
                          aircraft.rand_normal(0, 1),
                          aircraft.rand_normal(0, 1)) * gyro_noise * noise_scale;
    body_accel += Vector3f(aircraft.rand_normal(0, 1),
                           aircraft.rand_normal(0, 1),
                           aircraft.rand_normal(0, 1)) * accel_noise * noise_scale;
}
开发者ID:9DSmart,项目名称:ardupilot,代码行数:44,代码来源:SIM_Multicopter.cpp


注:本文中的Aircraft类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。