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


C++ Weapon::fire方法代码示例

本文整理汇总了C++中Weapon::fire方法的典型用法代码示例。如果您正苦于以下问题:C++ Weapon::fire方法的具体用法?C++ Weapon::fire怎么用?C++ Weapon::fire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Weapon的用法示例。


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

示例1: attack

//------------------------------------------------------------------------------
void Actor::attack()
{
	Weapon w = getWeapon();
  if( w.canFire() )
  {
    Projectile* p = w.fire( getAimingDirection() ); 
    p->setPosition( getPosition() );
    mpEngine->addProjectile( p );
    
    setWeapon( w );
  }
}
开发者ID:realisim,项目名称:realisim,代码行数:13,代码来源:GameEntity.cpp

示例2: fire

void Ship::fire(int weaponIndex)
{
	if (weaponIndex >= 0 && weaponIndex < (int)weapons_.size())
	{
		transform_->getMatrix(weaponTransformation_, false);

		//keeping weapon's local direction
		Weapon* weapon = weapons_[weaponIndex].first;
		weapon->currentDirection = weapon->direction;
		weapon->currentDirection.rotateVector(weaponTransformation_);

		//keeping weapon's local position
		Vector3 weaponPos = weapons_[weaponIndex].second;
		weaponPos.rotateVector(weaponTransformation_);
		weapon->position = transform_->getPosition() + weaponPos;

		weapon->fire();
	}
	else
		Logger::PrintWarning("Ship::fire - invalid argument\n");
}
开发者ID:haksist,项目名称:Chmo-engine,代码行数:21,代码来源:Ship.cpp

示例3: fireWeaponGroup

//---------------------------------------------------------------------------
void Avatar::fireWeaponGroup(int /*groupId*/)
{
	// for now, fire everything
	ComponentList list;
	findComponents(EquipmentSlotComponent::getClassDef(), list);
	for (ComponentList::iterator it = list.begin(); it != list.end(); ++it)
	{
		EquipmentSlotComponent* pSlot = static_cast<EquipmentSlotComponent*>(*it);
		if (pSlot)
		{
			size_t numEquipment = pSlot->getNumEquipment();
			for (size_t i=0; i<numEquipment; ++i)
			{
				Mountable* pMountable = pSlot->getEquipment(i);
				if (pMountable && pMountable->isOfType(Weapon::getClassDef()))
				{
					Weapon* pWeapon = static_cast<Weapon*>(pMountable);
					pWeapon->fire();
				}
			}
		}
	}
}
开发者ID:nbtdev,项目名称:teardrop,代码行数:24,代码来源:Avatar.cpp

示例4: CheckForInput

////////////////////////////////////////////////////////////
///Entrypoint of application 
//////////////////////////////////////////////////////////// 
void CheckForInput(float &x, float &y, bool & isSpace, bool &isLeft, bool &isRight, bool &isUp, bool &isDown, bool &isSwitch, Weapon& myWeapon)
{
	//simple input used for testing
	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && !isSpace)
	{
		isSpace = true;
		myWeapon.fire(Vector2D(x, y), Vector2D(400, 300));
	}
	else
	{
		isSpace = false;
	}

	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left) && !isLeft)
	{
		isLeft = true;
		x -= 5;
	}
	else
	{
		isLeft = false;
	}

	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right) && !isRight)
	{
		isRight = true;
		x += 5;
	}
	else
	{
		isRight = false;
	}

	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) && !isUp)
	{
		isUp = true;
		y += 5;
	}
	else
	{
		isUp = false;
	}

	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) && !isDown)
	{
		isDown = true;
		y -= 5;
	}
	else
	{
		isDown = false;
	}

	if (sf::Keyboard::isKeyPressed(sf::Keyboard::S) && !isSwitch)
	{
		isSwitch = true;
		myWeapon.switchWeapon();
		cout << "Switched weapon" << endl;
	}
	else
	{
		isSwitch = false;
	}

	cout << "XDir: " << x << endl;
	cout << "YDir: " << y << endl;
}
开发者ID:gdxn96,项目名称:swarm-wars,代码行数:70,代码来源:ConsoleApplication1.cpp


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