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


C++ Shot::Update方法代码示例

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


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

示例1: Update

//
// Update
//
void Game::Update()
{
	list<Sprite *>::iterator it;
	Sprite *curSpr;
	static bool HPwarning = false;
	static int chan = NULL;

	if(showExitConfirm)
		return;

	UpdateMessages();

	if(player->GetWeapon()==0)
		RELOAD_TIME = 650;
	if(player->GetWeapon()==1)
		RELOAD_TIME = 280;

	// Update sprites
	for(it = sprites.begin(); it != sprites.end(); it++)
	{
		curSpr = *it;

		if(curSpr->GetId() == ET_FURBY)
		{
			Furby *fb = (Furby *)curSpr;
			fb->Update(raycaster);

		}
		else if(curSpr->GetId() == SHOT_INDEX)
		{
			Shot *shot = (Shot *)curSpr;
			shot->Update(raycaster);

			if(shot->PointCollWith(raycaster->GetPosX(), raycaster->GetPosY()))
			{
				if(player->GetHealth() != 0)
				{
					framework->PlaySound(PlayerHurt);
				}
			AddMessage("You got hit by a shot from a furby!");
				player->DecrementHealth(10);

				it = sprites.erase(it);

			}
			if(shot->IsVanished())
				it = sprites.erase(it);
		}
		else if(curSpr->GetId() == DEATH_ANIMATION_INDEX)
		{
			DeathAnimation *da = (DeathAnimation *)curSpr;
			da->Update();

			if(da->HasEnded())
			{
				float itsX, itsY;
				itsX = da->GetPosX();
				itsY = da->GetPosY();

				delete da;
				it = sprites.erase(it);


				Sprite *corpse = new Sprite(spriteImgs[2], itsX, itsY, 2);
				sprites.push_back(corpse);
			}
		}

		if(curSpr->GetId() == ET_SKULL)
		{
			Skull *sk = (Skull *)curSpr;
			sk->Update(raycaster);
		}
		else if(curSpr->GetId() == SK_SHOT_INDEX)
		{
			SkullShot *skullshot = (SkullShot *)curSpr;
			skullshot->Update(raycaster);

			if(skullshot->PointCollWith(raycaster->GetPosX(), raycaster->GetPosY()))
			{
				if(player->GetHealth() !=0)
				{
					framework->PlaySound(PlayerHurt);
				}

				AddMessage("You got hit by a shot from a Skull!");
				player->DecrementHealth(20);

				it = sprites.erase(it);
			}
			if(skullshot->IsVanished())
				it = sprites.erase(it);
		}
		else if(curSpr->GetId() == SKDEATH_ANIMATION_INDEX)
		{
			SKDeathAnimation *skda = (SKDeathAnimation *)curSpr;
			skda->Update();
//.........这里部分代码省略.........
开发者ID:richi902,项目名称:FurbyKill-3D,代码行数:101,代码来源:lin32_Game.cpp


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