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


C++ Shot类代码示例

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


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

示例1: checkCollisionVsEnemyShots

void GameWorld::checkCollisionVsEnemyShots(GameObject* go)
{
	Shot* shot;
	Rect goRect = go->getRectangle();

	for (int i = 0; i < m_gameObjectManager->getEnemyShotsInUse(); i++)
	{
		shot = m_gameObjectManager->getEnemyShot(i);

		// Check that the shot is on screen. If not, remove.
		shot->setActive(shot->collide(m_physicsComponent, m_cameraView));
		if (!shot->getActive())
		{
			m_gameObjectManager->removeEnemyShot(i);
			i--;
			continue;
		}

		if ( shot->collide(m_physicsComponent, goRect) )
		{
			go->Health -= shot->Damage;
			m_gameObjectManager->removeEnemyShot(i);
			i--;
			continue;
		}
	}
}
开发者ID:em-mo,项目名称:blacklagoon,代码行数:27,代码来源:GameWorld.cpp

示例2: FireBarrel

Shot*
Weapon::NetFireSecondary(SimObject* tgt, System* sub, DWORD objid)
{
    Shot* shot = 0;

    if (IsPrimary() || Game::Paused())
    return shot;

    if (active_barrel < 0 || active_barrel >= nbarrels)
    active_barrel = 0;

    target    = tgt;
    subtarget = sub;
    aim_time  = 0;

    shot = FireBarrel(active_barrel++);

    if (active_barrel >= nbarrels) {
        active_barrel = 0;
        refire += design->salvo_delay;
    }

    if (shot)
    shot->SetObjID(objid);

    if (target)
    Observe(target);

    return shot;
}
开发者ID:Banbury,项目名称:starshatter-open,代码行数:30,代码来源:Weapon.cpp

示例3: checkCollisionVsPlayersShots

void GameWorld::checkCollisionVsPlayersShots(GameObject* go)
{
	Shot* shot;
	for (int j = 0; j < m_gameObjectManager->getPlayerShotsInUse(); j ++)
	{
		shot = m_gameObjectManager->getPlayerShot(j);

		// Check that the shot is on screen. If not, remove.
		shot->setActive(shot->collide(m_physicsComponent, m_cameraView));
		if (!shot->getActive())
		{
			m_gameObjectManager->removePlayerShot(j);
			j--;
			continue;
		}

		// check if shot hits enemy.
		if ( shot->collide(m_physicsComponent, go->getRectangle()))
		{
			go->Health -= shot->Damage;
			m_gameObjectManager->removePlayerShot(j);
			j--;
			continue;
		}
	}
}
开发者ID:em-mo,项目名称:blacklagoon,代码行数:26,代码来源:GameWorld.cpp

示例4: simulateShot

bool simulateShot(fastfiz_msgs::SimulateShotRequest& req, fastfiz_msgs::SimulateShotResponse& res)
{
  TableState ts = msgToFiz(req.state);
  ShotParams shot = msgToFiz(req.shot);
  Shot* s = ts.executeShot(shot, false, false);

  typedef std::vector<Event*> V_Event;
  const V_Event& events = s->getEventList();
  V_Event::const_iterator it = events.begin();
  V_Event::const_iterator end = events.end();
  for (; it != end; ++it)
  {
    Event* e = *it;
    fastfiz_msgs::Event event;
    event.type = e->getType();
    event.ball1 = fizToMsg(e->getBall1());
    event.ball2 = fizToMsg(e->getBall2());
    event.string_rep = e->toString();

    res.events.push_back(event);
  }

  delete s;

  res.state = fizToMsg(ts);

  return true;
}
开发者ID:ashokzg,项目名称:billiards,代码行数:28,代码来源:fastfiz_node.cpp

示例5: while

void GamePage::MoveShots(list<Shot> &shotsList)
{
	list<Shot>::iterator it = shotsList.begin();

	while (it != shotsList.end())
	{
		if (it->IsPossibleToMove())
		{
			it->Move(this->m_counter);
			it++;
		}
		else
		{
			if (g_pScreen->GetObjectAt(it->GetNextX(), it->GetNextY()) == OBJECT_TYPE_SHOT)
			{
				Shot *s = this->GetShotAt(it->GetNextX(), it->GetNextY());
				
				if (s->GetLastMove() == this->m_counter)
				{
					it++;
					continue;
				}
			}

			this->RemoveObject(it->GetNextX(), it->GetNextY());

			list<Shot>::iterator temp = it;
			it++;

			temp->Clear();
			shotsList.erase(temp);
		}
	}
}
开发者ID:saber2014,项目名称:MathGame,代码行数:34,代码来源:game_page.cpp

示例6: sonicDeflectorEffect

void Game::sonicDeflectorEffect() {
  for ( unsigned int i = 0; i < racers->getNrRacers(); i++) {
    if ( racers->getRacer(i)->getShipType() == LIGHT_FIGHTER ) {
      Shot* nearestRocket = shots->getNearestRocket( racers->getRacer(i)->getPos() );
      // a rocket exists and it is in range of the sonic
      if ( nearestRocket != NULL &&
        (nearestRocket->getPos() - racers->getRacer(i)->getPos()).getLength() < 
        RACER_SONIC_ACTIVATION_DIST ) {
        // activate the correct sonic
        if (i == 0) {
          sonic1->setPos( racers->getRacer(i)->getPos(), nearestRocket->getPos() );
          nearestRocket->deflectedBySonicFromPlayer1 = true;
        } else {
          sonic2->setPos( racers->getRacer(i)->getPos(), nearestRocket->getPos() );
          nearestRocket->deflectedBySonicFromPlayer2 = true;
        }
      // no rocket is in sonic-range
      } else {
        // deactivate the sonic
        if (i == 0) {
          sonic1->setActive( false );
        } else {
          sonic2->setActive( false );
        }
      }
    }
  }
}
开发者ID:Haryaalcar,项目名称:vcmi-build,代码行数:28,代码来源:game.cpp

示例7:

void
Dissolve::postComplete(Shot& initialShot, Shot& finalShot)
{
  initialShot.getCamera()._alpha = UNITY;
  finalShot.getCamera()._alpha = UNITY;
  _timeElapsed = ZERO;
  _timeStarted = ZERO;
}
开发者ID:williamwaterson,项目名称:protolayer,代码行数:8,代码来源:WhiteOutDissolve.cpp

示例8: AllAct

void Troop::AllAct() {
  Shot *tmpsh;
  tmpsh->AllAct();
  int ctr=0;
  for(ctr=0; ctr<maxtr; ++ctr) if (trp[ctr] != NULL) {
    trp[ctr]->Act();
    }
  }
开发者ID:steaphangreene,项目名称:cosmos-lander,代码行数:8,代码来源:troop.cpp

示例9: DeleteAll

void Troop::DeleteAll() {
  Shot *tmpsh;
  tmpsh->DeleteAll();
  int ctr=0;
  for(ctr=0; ctr<maxtr; ++ctr) if (trp[ctr] != NULL) {
    delete trp[ctr];
    }
  }
开发者ID:steaphangreene,项目名称:cosmos-lander,代码行数:8,代码来源:troop.cpp

示例10: FindPlayerByObjID

void
NetGameClient::DoWepRelease(NetMsg* msg)
{
	if (!msg) return;

	NetWepRelease release;
	release.Unpack(msg->Data());

	NetPlayer* player = FindPlayerByObjID(release.GetObjID());
	if (player) {
		player->DoWepRelease(&release);
	}

	else {
		Ship* shooter = FindShipByObjID(release.GetObjID());
		if (shooter) {
			int   index = release.GetIndex();
			DWORD tgtid = release.GetTgtID();
			DWORD wepid = release.GetWepID();
			int   subid = release.GetSubtarget();
			bool  decoy = release.GetDecoy();
			bool  probe = release.GetProbe();

			Weapon* w = 0;

			if (decoy)        w = shooter->GetDecoy();
			else if (probe)   w = shooter->GetProbeLauncher();
			else              w = shooter->GetWeaponByIndex(index);

			if (w && !w->IsPrimary()) {
				SimObject*  target = FindShipByObjID(tgtid);
				System*     subtgt = 0;

				if (target) {
					if (subid >= 0) {
						Ship* tgt_ship = (Ship*) target;
						subtgt = tgt_ship->Systems().at(subid);
					}
				}
				else {
					target = FindShotByObjID(tgtid);
				}

				Shot* shot = w->NetFireSecondary(target, subtgt, wepid);

				if (shot && shot->IsDrone()) {
					if (probe)
					shooter->SetProbe((Drone*) shot);

					else if (decoy)
					shooter->AddActiveDecoy((Drone*) shot);
				}
			}
		}
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:56,代码来源:NetGameClient.cpp

示例11: Shot

	void ManagerModel::AddShot(Vec2 startPosition) {
		Shot *shot = DBG_NEW Shot();
		shot->startPosition = startPosition;
		shot->OnInit(this);
		mEntities.push_back(shot);

		for (auto *view : mViews) {
			view->OnShotSpawned((Shot*)shot);
			view->PlayShotSoundEffect((Shot*)shot);
		}
	}
开发者ID:syvjohan,项目名称:Games,代码行数:11,代码来源:ManagerModel.cpp

示例12: Shot

void Shooter::update() {
    //rand()
    if(mFrame %(mSpeed) == 0) {
        Shot* ms = new Shot();
        ms->setShotType(Shot::ShotType_Fireball);
        ms->setInitialVelocity(float2(0.f,mInitialVelocity[Shot::ShotType_Fireball].y));
        ms->setPosition(getPosition());
        mRoom->addEntity(ms);
    }

    mFrame++;
}
开发者ID:olofn,项目名称:db_public,代码行数:12,代码来源:Shooter.cpp

示例13: if

bool
NetPlayer::DoWepRelease(NetWepRelease* release)
{
	if (ship && release) {
		int   index = release->GetIndex();
		DWORD tgtid = release->GetTgtID();
		DWORD wepid = release->GetWepID();
		int   subid = release->GetSubtarget();
		bool  decoy = release->GetDecoy();
		bool  probe = release->GetProbe();

		Weapon* w = 0;

		if (decoy)        w = ship->GetDecoy();
		else if (probe)   w = ship->GetProbeLauncher();
		else              w = ship->GetWeaponByIndex(index);

		if (w && !w->IsPrimary()) {
			SimObject*  target = 0;
			System*     subtgt = 0;

			NetGame* net_game = NetGame::GetInstance();
			if (net_game) {
				target = net_game->FindShipByObjID(tgtid);

				if (target) {
					if (subid >= 0) {
						Ship* tgt_ship = (Ship*) target;
						subtgt = tgt_ship->Systems().at(subid);
					}
				}
				else {
					target = net_game->FindShotByObjID(tgtid);
				}
			}

			Shot* shot = w->NetFireSecondary(target, subtgt, wepid);

			if (shot && shot->IsDrone()) {
				if (probe)
				ship->SetProbe((Drone*) shot);

				else if (decoy)
				ship->AddActiveDecoy((Drone*) shot);
			}

			return true;
		}
	}

	return false;
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:52,代码来源:NetPlayer.cpp

示例14: FindShipByObjID

void
NetGameClient::DoObjDamage(NetMsg* msg)
{
	if (!msg) return;

	NetObjDamage obj_damage;
	obj_damage.Unpack(msg->Data());

	Ship* ship = FindShipByObjID(obj_damage.GetObjID());
	if (ship) {
		Sim*        sim         = Sim::GetSim();
		Shot*       shot        = FindShotByObjID(obj_damage.GetShotID());
		const Ship* owner       = 0;
		const char* owner_name  = "[NET]";

		ship->InflictNetDamage(obj_damage.GetDamage(), shot);

		if (shot && sim) {
			if (shot->Owner()) {
				owner       = shot->Owner();
				owner_name  = owner->Name();
			}

			if (shot->IsMissile()) {
				SimRegion*  region = ship->GetRegion();
				float       scale  = ship->Design()->explosion_scale;

				if (scale <= 0)
				scale = ship->Design()->scale;

				if (owner) {
					const ShipDesign* owner_design = owner->Design();
					if (owner_design && owner_design->scale < scale)
					scale = (float) owner_design->scale;
				}

				sim->CreateExplosion(shot->Location(), Point(), Explosion::SHOT_BLAST, 20.0f * scale, scale, region);
			}

			if (!shot->IsBeam()) {
				if (owner) {
					ShipStats* stats = ShipStats::Find(owner_name);

					if (stats) {
						if (shot->IsPrimary())
						stats->AddGunHit();
						else if (shot->Damage() > 0)
						stats->AddMissileHit();
					}
				}

				shot->Destroy();
			}
		}
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:56,代码来源:NetGameClient.cpp

示例15: FindShotByObjID

void
NetGameClient::DoWepDestroy(NetMsg* msg)
{
	if (!msg) return;

	NetWepDestroy destroy;
	destroy.Unpack(msg->Data());

	Shot* shot = FindShotByObjID(destroy.GetObjID());
	if (shot) {
		if (shot->IsBeam())
		::Print("NetGameClient::DoWepDestroy shot '%s'\n", shot->Name());

		shot->Destroy();
	}
}
开发者ID:The-E,项目名称:Starshatter-Experimental,代码行数:16,代码来源:NetGameClient.cpp


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