本文整理汇总了C++中Projectile::GetActive方法的典型用法代码示例。如果您正苦于以下问题:C++ Projectile::GetActive方法的具体用法?C++ Projectile::GetActive怎么用?C++ Projectile::GetActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projectile
的用法示例。
在下文中一共展示了Projectile::GetActive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Projectile
Projectile * Application::FetchProjectile()
{
for (vector<Projectile*>::iterator it = projectileList.begin(); it != projectileList.end(); ++it)
{
Projectile* p = *it;
if (!p->GetActive())
{
return p;
}
}
return nullptr;
/*const int BATCH_PRODUCE = 20;
for (int i = 0; i < BATCH_PRODUCE; ++i)
{
Projectile* p = new Projectile();
projectileList.push_back(p);
}
return projectileList.back();*/
}
示例2: Update
//.........这里部分代码省略.........
//collisions
/*if ((*ship) == ships_.at(0))
checkCollisions((*ship));*/
}
// Lab 13 Task 5 : Updating the missile
/*if (mymissile)
{
if (mymissile->Update(ships_, timedelta))
{
//havecollision
delete mymissile;
mymissile = 0;
}
}*/
// Lab 13 Task 13 : Update network missiles
/*for (MissileList::iterator missile = missiles_.begin(); missile != missiles_.end(); missile++)
{
if ((*missile)->Update(ships_, timedelta))
{
//havecollision
delete*missile;
missiles_.erase(missile);
break;
}
}*/
// Update enemies
/*for (vector<Enemy*>::iterator it = enemyList.begin(); it != enemyList.end(); ++it)
{
Enemy* e = *it;
if (e->GetActive())
{
bool reset = e->Update(timedelta);
if (reset)
{
RakNet::BitStream bs;
bs.Write((unsigned char)ID_DESTROY_ENEMY);
bs.Write(e->GetID());
rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_SYSTEM_ADDRESS, true);
}
}
}*/
// Update projectile
for (vector<Projectile*>::iterator it = projectileList.begin(); it != projectileList.end(); ++it)
{
Projectile* p = *it;
if (/*p->GetOwner() == ships_.at(0) && */p->GetActive()) // Only update your own projectile
{
bool reset = p->Update(timedelta);
RakNet::BitStream bs;
if (reset)
{
DestroyProjectile(p);
bs.Write((unsigned char)ID_DESTROY_PROJECTILE);
bs.Write(p->GetID());
rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_SYSTEM_ADDRESS, true);
}
else
{
for (vector<Enemy*>::iterator it2 = enemyList.begin(); it2 != enemyList.end(); ++it2)
{
Enemy* e = *it2;
示例3: Render
/**
* Render Cycle
*
* Clear the screen and render all the ships
*/
void Application::Render()
{
hge_->Gfx_BeginScene();
hge_->Gfx_Clear(0);
// Background
if (background)
{
background->Render(0, 0);
}
// Base
if (base)
{
base->Render(S_SCREEN_WIDTH * 0.5f, S_SCREEN_HEIGHT * 0.5f);
}
ShipList::iterator itr;
for (itr = ships_.begin(); itr != ships_.end(); itr++)
{
(*itr)->Render();
}
// Lab 13 Task 6 : Render the missile
if (mymissile)
{
mymissile->Render();
}
// Lab 13 Task 12 : Render network missiles
MissileList::iterator itr2;
for (itr2 = missiles_.begin(); itr2 != missiles_.end(); itr2++)
{
(*itr2)->Render();
}
// Render enemies
for (vector<Enemy*>::iterator it = enemyList.begin(); it != enemyList.end(); ++it)
{
Enemy* e = *it;
if (e->GetActive())
{
e->Render();
}
}
// Render projectile
for (vector<Projectile*>::iterator it = projectileList.begin(); it != projectileList.end(); ++it)
{
Projectile* p = *it;
if (p->GetActive())
{
p->Render();
}
}
// Render boom
for (vector<Boom*>::iterator it = boomList.begin(); it != boomList.end(); ++it)
{
Boom* b = *it;
if (b->isActive())
{
b->Render();
}
}
// Render explosion
for (vector<Explosion*>::iterator it = explosionList.begin(); it != explosionList.end(); ++it)
{
Explosion* e = *it;
if (e->isActive())
{
e->Render();
}
}
// Base hp
if (f_base_hp)
{
f_base_hp->Render(S_SCREEN_WIDTH * 0.5f, S_SCREEN_HEIGHT * 0.1f, HGETEXT_CENTER, std::to_string(base_hp).c_str());
}
// Score
if (p1_score)
{
string score = "Your score: " + std::to_string(ships_.at(0)->GetScore());
p1_score->Render(S_SCREEN_WIDTH * 0.25f, S_SCREEN_HEIGHT * 0.1f, HGETEXT_CENTER, score.c_str());
}
if (p2_score && ships_.size() > 1)
{
string score = "Other score: " + std::to_string(ships_.at(1)->GetScore());
p1_score->Render(S_SCREEN_WIDTH * 0.75f, S_SCREEN_HEIGHT * 0.1f, HGETEXT_CENTER, score.c_str());
}
// Chat
//.........这里部分代码省略.........