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


C++ Missile类代码示例

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


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

示例1: getTransform

void BasicEnemy::fire(std::list<Missile*>& missiles) {
    if (!mCanSee) return;
    if (mCooldown > 0) return;

    mCooldown = COOLDOWN;

    sf::Vector2f pos;
    Missile* missile;

    pos = getTransform().transformPoint(30, 80);
    missile = new Missile(getScreen(), this);
    missile->setPosition(pos);
    missile->setRotation(180+getRotation());
    missile->damage = DAMAGE;
    missiles.push_back(missile);

    pos = getTransform().transformPoint(70, 80);
    missile = new Missile(getScreen(), this);
    missile->setPosition(pos);
    missile->setRotation(180+getRotation());
    missile->damage = DAMAGE;
    missiles.push_back(missile);

    mSFX.play();
}
开发者ID:asalahli,项目名称:Bombardier,代码行数:25,代码来源:BasicEnemy.cpp

示例2: GameMissile

Missile* UnitFactory::createMissile( const char * filename,
                                     int faction,
                                     const string &modifications,
                                     const float damage,
                                     float phasedamage,
                                     float time,
                                     float radialeffect,
                                     float radmult,
                                     float detonation_radius, ObjSerial netcreate )
{
//  double startime= queryTime();
    Missile * un =new GameMissile( filename,
                        faction,
                        modifications,
                        damage,
                        phasedamage,
                        time,
                        radialeffect,
                        radmult,
                        detonation_radius );
	if( netcreate) {
		KillDuplicateUnits( netcreate);
		un->SetSerial( netcreate);
	}
	return un;
//  double endtime= queryTime();
//  printf ("mcr %f ",endtime-startime);
}
开发者ID:bsmr-games,项目名称:Privateer-Gemini-Gold,代码行数:28,代码来源:unit_factory.cpp

示例3: assert

bool Ship::FireMissile(int idx, Ship *target)
{
	assert(target);

	const Equip::Type t = m_equipment.Get(Equip::SLOT_MISSILE, idx);
	if (t == Equip::NONE) {
		return false;
	}

	m_equipment.Set(Equip::SLOT_MISSILE, idx, Equip::NONE);
	CalcStats();

	matrix4x4d m;
	GetRotMatrix(m);
	vector3d dir = m*vector3d(0,0,-1);
	
	ShipType::Type mtype;
	switch (t) {
		case Equip::MISSILE_SMART: mtype = ShipType::MISSILE_SMART; break;
		case Equip::MISSILE_NAVAL: mtype = ShipType::MISSILE_NAVAL; break;
		case Equip::MISSILE_UNGUIDED: mtype = ShipType::MISSILE_UNGUIDED; break;
		default:
		case Equip::MISSILE_GUIDED: mtype = ShipType::MISSILE_GUIDED; break;
	}
	Missile *missile = new Missile(mtype, this, target);
	missile->SetRotMatrix(m);
	missile->SetFrame(GetFrame());
	// XXX DODGY! need to put it in a sensible location
	missile->SetPosition(GetPosition()+50.0*dir);
	missile->SetVelocity(GetVelocity());
	Space::AddBody(missile);
	return true;
}
开发者ID:GAlexx,项目名称:pioneer,代码行数:33,代码来源:Ship.cpp

示例4: Missile

Missile* UnitFactory::createMissile( const char *filename,
                                     int faction,
                                     const string &modifications,
                                     const float damage,
                                     float phasedamage,
                                     float time,
                                     float radialeffect,
                                     float radmult,
                                     float detonation_radius,
                                     ObjSerial netcreate )
{
    _Universe->netLock( true );
    Missile *un = new Missile( filename,
                               faction,
                               modifications,
                               damage,
                               phasedamage,
                               time,
                               radialeffect,
                               radmult,
                               detonation_radius );
    _Universe->netLock( false );
    if (netcreate)
        un->SetSerial( netcreate );
/*
 *               if (!_Universe->netLocked()) {
 *                       NetBuffer netbuf;
 *                       addMissileBuffer( netbuf, un );
 *                       endBuffer( netbuf );
 *                       VSServer->broadcast( netbuf, 0, _Universe->activeStarSystem()->GetZone(), CMD_ENTERCLIENT, true);
 *               }
 *               VSServer->invalidateSnapshot();
 */
    return un;
}
开发者ID:vegastrike,项目名称:Vega-Strike-Engine-Source,代码行数:35,代码来源:unit_factory_server.cpp

示例5: GameMissile

Missile* UnitFactory::createMissile( const char *filename,
                                     int faction,
                                     const string &modifications,
                                     const float damage,
                                     float phasedamage,
                                     float time,
                                     float radialeffect,
                                     float radmult,
                                     float detonation_radius,
                                     ObjSerial netcreate )
{
    Missile *un = new GameMissile( filename,
                                   faction,
                                   modifications,
                                   damage,
                                   phasedamage,
                                   time,
                                   radialeffect,
                                   radmult,
                                   detonation_radius );
    if (netcreate) {
        KillDuplicateUnits( netcreate );
        un->SetSerial( netcreate );
    }
    return un;
}
开发者ID:Ezeer,项目名称:VegaStrike_win32FR,代码行数:26,代码来源:unit_factory.cpp

示例6: assert

bool Ship::FireMissile(int idx, Ship *target)
{
	assert(target);

	if (GetFlightState() != FLYING) return false;

	const Equip::Type t = m_equipment.Get(Equip::SLOT_MISSILE, idx);
	if (t == Equip::NONE) {
		return false;
	}

	m_equipment.Set(Equip::SLOT_MISSILE, idx, Equip::NONE);
	UpdateEquipStats();

	ShipType::Id mtype;
	switch (t) {
		case Equip::MISSILE_SMART: mtype = ShipType::MISSILE_SMART; break;
		case Equip::MISSILE_NAVAL: mtype = ShipType::MISSILE_NAVAL; break;
		case Equip::MISSILE_UNGUIDED: mtype = ShipType::MISSILE_UNGUIDED; break;
		default:
		case Equip::MISSILE_GUIDED: mtype = ShipType::MISSILE_GUIDED; break;
	}
	Missile *missile = new Missile(mtype, this, target);
	missile->SetOrient(GetOrient());
	missile->SetFrame(GetFrame());
	// XXX DODGY! need to put it in a sensible location
	vector3d dir = -GetOrient().VectorZ();
	missile->SetPosition(GetPosition()+50.0*dir);
	missile->SetVelocity(GetVelocity());
	Pi::game->GetSpace()->AddBody(missile);
	return true;
}
开发者ID:Metamartian,项目名称:pioneer,代码行数:32,代码来源:Ship.cpp

示例7: getWeapons

// Get the next free missile of type 'missileType'
Missile* SimpleStoresMgr::getSpecificMissile(const base::String* const missileType)
{
   Missile* msl = nullptr;
   if (missileType != nullptr) {

      base::PairStream* list = getWeapons();
      if (list != nullptr) {

         // Find the first free (inactive) missile of type weaponType
         base::List::Item* item = list->getFirstItem();
         while (item != nullptr && msl == nullptr) {
            base::Pair* pair = static_cast<base::Pair*>(item->getValue());
            Missile* p = dynamic_cast<Missile*>(pair->object());
            if (p != nullptr && p->isInactive()) {
               // Ok, we have a missile, but is it the type we want?
               if (*p->getType() == *missileType) {
                  p->ref();
                  msl = p;
               }
            }
            item = item->getNext();
         }

         list->unref();
      }

   }
   return msl;
}
开发者ID:wangfeilong321,项目名称:OpenEaagles,代码行数:30,代码来源:StoresMgr.cpp

示例8: ofVec2f

void testApp::mouseReleased(int x, int y, int button){

	ofVec2f target = ofVec2f(x,y);

	if(state==START_SCREEN){

		ofRectangle startb = ofRectangle(START_BUTTON_POS);
		if( startb.inside(x, y)){
			currentLevel = 0;
			nextLevel();
			return;
		}else{

			lines[currentLine].push_back( ofVec2f(x ,y ));
		}
	}

	if(state==PLAYING){
		Silo * silo = bestSiloForTarget( target );

		if (silo != NULL){
			Missile *m = silo->launchMissile();
			if(m != NULL){
				launch.play();
				m->startGood( target );
				playerMissiles.push_back(m);
			}else{
				empty.play();
			}
		}else{
			empty.play();
		}
	}
}
开发者ID:armadillu,项目名称:MissileCommand,代码行数:34,代码来源:testApp.cpp

示例9: Missile

void testApp::nextLevel(){

	currentLevel++;
	startup.play();
	e.stopPostExplosionSmoke();
	state = PLAYING;
	levelTime = LEVEL_TIME;
	playerMissiles.clear();
	badMissiles.clear();
	
	for(int i = 0; i < NUM_BAD_MISSILES + 4 * currentLevel; i++){
		Missile *m = new Missile();
		m->startBad();
		badMissiles.push_back(m);
	}

	for(int i = 0; i < silos.size(); i++){
		silos[i]->revive();
		silos[i]->resetMissiles();
	}

	for(int i = 0; i < cities.size(); i++){
		cities[i].revive();
	}
}
开发者ID:armadillu,项目名称:MissileCommand,代码行数:25,代码来源:testApp.cpp

示例10: createMissile

Missile* GameObjectFactory::createMissile(Leukocyte* from, Leukocyte* to)
{
    Missile* missile = Missile::createWithFrom(from, to);
    missile->setPosition(from->getPosition());
    
    return missile;
}
开发者ID:MKomiya,项目名称:Leukocyte,代码行数:7,代码来源:GameObjectFactory.cpp

示例11: runTerrainDestructionDemo

void runTerrainDestructionDemo()
{
	isRunning = true;
	EngineInterface::createEngine("Data/Scripts/config.lua");
	EngineInterface::addRenderTask("renderSprites");
	EngineInterface::addUpdateTask("performFrustumCulling");
	EngineInterface::addGameLoopTask("updateTerrain",updateTerrain);

	EngineInterface::connectKeyboardAction(Escape,exitTerrainDestructionDemo);
	EngineInterface::connectMouseAction(LeftButton,fireMissile);

	FlightCamera* camera = new FlightCamera(Vector3D(0.0f,2000.0f,0.0f),Vector3D(0.0f,0.0f,-1.0f));
	EngineInterface::connectKeyboardAction(W,boost::bind(&FlightCamera::moveCameraForward,camera));
	EngineInterface::connectMouseMoveAction(boost::bind(&FlightCamera::changeViewTarget,camera,_1,_2));
	EngineInterface::addSceneCamera(camera);

	SceneEntity* terrain = new SceneEntity("Terrain","Terrain","Terrain");
	terrain->initializeSceneEntity();
	terrain->setEntityPosition(-128.0f*50.0f,0.0f,-128.0f*50.0f);
	EngineInterface::addIndependentToScene(terrain);

	SceneEntity* skyDome = new SceneEntity("Sky","SkyDome","SkyDome");
	skyDome->initializeSceneEntity();
	skyDome->setEntityOrientation(-90.0f,0.0f,0.0f);
	skyDome->setEntityScale(10000.0f,10000.0f,10000.0f);
	EngineInterface::addIndependentToScene(skyDome);
	
	SceneEntity* flight = new SceneEntity("F16","F16","F16");
	flight->initializeSceneEntity();
	flight->setEntityScale(0.1f,0.1f,0.1f);
	flight->setEntityPosition(0.0f,1600.0f,-10.0f);
	flight->setEntityOrientation(0.0f,180.0f,180.0f);
	flight->setFunctionUpdating(updateFlight);
	flight->entityPhysics.velocity.set(20.0f,20.0f,20.0f);
	flight->entityPhysics.isKinematic = true;
	EngineInterface::addEntityToScene(flight);
	
	Missile* missile = new Missile("Missile","Missile","Missile");
	missile->initializeSceneEntity();
	missile->setEntityScale(20.0f,20.0f,20.0f);
	missile->setExtendingUpdating();
	missile->entityPhysics.isKinematic = true;
	missile->entityPhysics.velocity.set(200.0f,200.0f,200.0f);
	EngineInterface::addEntityToScene(missile);
	
	EngineInterface::initializeFont("Font",32);
	EngineInterface::addSprite("AyumiLogo",Vector3D(-500.0f,-500.0f,0.0f),Vector3D(256.0f,47.0f,0.0f));
	EngineInterface::addSprite("Crosshair",Vector3D(0.0f,0.0f,0.0f),Vector3D(64.0f,64.0f,0.0f));

	EngineInterface::addDynamicActor(flight,BOX,CollisionFilter::AIRCRAFT,CollisionFilter::TERRAIN);
	EngineInterface::addDynamicActor(missile,BOX,CollisionFilter::MISSILE,CollisionFilter::TERRAIN);
	EngineInterface::addCollisionCallback("F16","Terrain",flightCollision);
	EngineInterface::addCollisionCallback("Missile","Terrain",missileCollision);
	destruction = EngineInterface::createDestructibleTerrain(terrain,"Data/Mesh/terrainDemo.raw",Vector4D(256.0,50.0,50.0,1500.0),CollisionFilter::TERRAIN,CollisionFilter::MISSILE | CollisionFilter::AIRCRAFT);

	EngineInterface::runGameLoop(&isRunning);
	EngineInterface::releaseDestructibleTerrain(destruction);
	EngineInterface::releaseEngine();	
}
开发者ID:veldrinlab,项目名称:ayumiEngine,代码行数:59,代码来源:TerrainDestructionDemo.cpp

示例12: onContactBegin

bool MonsterDevil::onContactBegin(cocos2d::PhysicsContact& contact)
{
	auto bodyA = contact.getShapeA()->getBody();
	auto bodyB = contact.getShapeB()->getBody();
	auto componentA = (BaseComponent*)bodyA->getNode();
	auto componentB = (BaseComponent*)bodyB->getNode();
	BaseComponent* enemyComponent;
	bool isComponentA = true;


	//어떤것 끼리 부딪혔는지는 안가르쳐주기 때문에
	//여기서 어느쪽이 monsterDevil인지 밝혀낸다.
	if (componentA->getType() == getType())
	{
		enemyComponent = componentB;
		isComponentA = true;
	}
	else
	{
		enemyComponent = componentA;
		isComponentA = false;
	}


	//FLOOR 충돌 무시 
	if (enemyComponent->getType() == OT_FLOOR)
	{
		return false;
	}

	//미사일이랑 충돌 처리
	if (enemyComponent->getPhysicsBody()->getCategoryBitmask() == PHYC_MISSILE)
	{
		Missile* missile = static_cast<Missile*>(enemyComponent);

		//수류탄은 뎀 안 입음
		if (missile->getType() == OT_MISSILE_GRENADE)
		{
			return false;
		}

		//몹이 쏜 건 안 맞음.
		if (!missile->isPlayerMissile())
		{
			return false;
		}

		float damage = missile->getDamage();

		m_Info.m_CurrentHp -= damage * 100 / (100 + m_Info.m_DefensivePower);

		//사망
		if (m_Info.m_CurrentHp <= 0)
		{
			m_IsDead = true;
		}
	}
	return true;
}
开发者ID:highjin,项目名称:ProjectArthas,代码行数:59,代码来源:MonsterDevil.cpp

示例13: getPosition

 void Enemy::fire(float delta) {
     Missile* m;
     glm::vec3 forward = glm::normalize(glm::mat3_cast(getRotation()) * glm::vec3(0, 0, 1));
     glm::vec3 position = getPosition() + 2.0f * forward;
     m = new Missile(position, 2.0f * forward);
     m->setRotation(getRotation());
     m->rotate(glm::vec3(1, 0, 0), 3.1415920f / 2.0f);
     Game::getGame().addMissile(m);
 }
开发者ID:hdt80,项目名称:SSS,代码行数:9,代码来源:Enemy.cpp

示例14: update

void MissileMovementLoop::update(float delta){
Missile* parent = (Missile*)getOwner();
if(parent==NULL)
{
    return;
}else{
    auto moveDown = MoveTo::create(missileFlyDuration, Point(0,parent->getPosition().x));
    parent->runAction(moveDown);
}
}
开发者ID:bowbahdoe,项目名称:Kablewey,代码行数:10,代码来源:MissileMovementLoop.cpp

示例15: rand

//Check if the Marauder should shoot. Create and initialize a missile and push it to missiles vector.
void Marauder::shoot(sf::RenderWindow &window, Player &player, vector <Enemy *> &enemies, vector <Bullet *> &bullets, vector <Missile *> &missiles) {

	int random = rand() % 500 + 1;
	if (random == 1) {
		Missile* missile = new Missile(this->getPosition());
		missile->velocity = (sf::Vector2f(5, 5));
		missile->damage = (this->damage);
		missile->calculateRotation(window, player);
		missiles.push_back(missile);
	}

}
开发者ID:Crowmoore,项目名称:T.E.A.R,代码行数:13,代码来源:Marauder.cpp


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