本文整理汇总了C++中Sprite::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite::GetId方法的具体用法?C++ Sprite::GetId怎么用?C++ Sprite::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite::GetId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckCollWithSprite
//
// CheckCollWithSprite
//
bool Raycaster::CheckCollWithSprite(bool *wasPickup, int *pickupId)
{
list<Sprite *>::iterator it;
Sprite *spr;
*wasPickup = false;
for(it = sprites->begin(); it != sprites->end(); it++)
{
spr = *it;
if(spr->PointCollWith(posX, posY) && spr->GetId() != CORPSE_INDEX)
{
if(spr->GetId() >= PICKUP_INDEX && spr->GetId() < ET_SKULL)
{
*wasPickup = true;
*pickupId = spr->GetId();
delete spr;
it = sprites->erase(it);
return false;
}
return true;
}
}
return false;
}
示例2: Shoot
//
// Shoot
//
void Game::Shoot()
{
static Uint32 lShot = SDL_GetTicks() - RELOAD_TIME;
static list<SprDraw> killableSprites;
static list<SprDraw>::iterator ksIt;
static float distance, a, b, c, d;
if(SDL_GetTicks() - lShot > RELOAD_TIME)
{
list<Sprite *>::iterator it;
Sprite *spr;
if(player->GetWeapon() == 0)
{
player->DecrementAmmo(1);
if(player->GetAmmo() == 0)
{
AddMessage("Out of ammo!");
return;
}
}
else if(player->GetWeapon() == 1)
{
player->DecrementMGAmmo(1);
if(player->GetMGAmmo() == 0)
{
AddMessage("Out of ammo!");
return;
}
}
fireStart = SDL_GetTicks();
fireVisible = true;
if(player->GetWeapon()==0)
framework->PlaySound(shootSnd);
else if(player->GetWeapon()==1)
framework->PlaySound(MGshootSnd);
for(it = sprites.begin(); it != sprites.end(); it++)
{
spr = *it;
if(spr->GetLookingAt() && spr->GetId() == ET_FURBY)
{
SprDraw ks;
ks.original = spr;
ks.x = spr->GetPosX();
ks.y = spr->GetPosY();
ks.image = spr->GetImage();
a = raycaster->GetPosX() - ks.x;
b = raycaster->GetPosY() - ks.y;
distance = sqrt(a*a+b*b);
ks.distance = distance;
killableSprites.push_back(ks);
}
if(spr->GetLookingAt() && spr->GetId() == ET_SKULL)
{
SprDraw ks;
ks.original = spr;
ks.x = spr->GetPosX();
ks.y = spr->GetPosY();
ks.image = spr->GetImage();
c = raycaster->GetPosX() - ks.x;
d = raycaster->GetPosY() - ks.y;
distance = sqrt(a*a+b*b);
ks.distance = distance;
killableSprites.push_back(ks);
}
}
if(!killableSprites.empty())
{
killableSprites.sort();
killableSprites.reverse();
ksIt = killableSprites.begin();
Furby *thisFurby = (Furby *)(*ksIt).original;
Skull *thisSkull = (Skull*)(*ksIt).original;
if(!thisFurby->IsDead()&&thisFurby->GetId()==ET_FURBY)
{
thisFurby->NextImage();
framework->PlaySound(EnemyHurt);
}
else if(thisFurby->IsDead() && thisFurby->GetId()==ET_FURBY)
{
SDL_Surface *daFrames[NUM_DEATH_ANIM_FRAMES];
daFrames[0] = spriteImgs[11];
daFrames[1] = spriteImgs[12];
daFrames[2] = spriteImgs[13];
//.........这里部分代码省略.........
示例3: 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();
//.........这里部分代码省略.........