本文整理汇总了C++中Projectile::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ Projectile::Update方法的具体用法?C++ Projectile::Update怎么用?C++ Projectile::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projectile
的用法示例。
在下文中一共展示了Projectile::Update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void BattleStage::Update()
{
while( GameObjectsToAdd.size() > 0 )
{
Projectile* p = GameObjectsToAdd.front();
GameObjectsToAdd.pop_front();
GameObjects.push_back( p );
}
while( GameObjectsToRemove.size() > 0 )
{
Projectile* p = GameObjectsToRemove.front();
GameObjectsToRemove.pop_front();
GameObjects.remove( p );
delete p;
}
for( std::list<Projectile*>::const_iterator i = GameObjects.begin(); i != GameObjects.end(); i++ )
{
Projectile* p = (*i);
p->Update();
}
LeftPlayer->Update();
RightPlayer->Update();
if( ((BattlePlayer*)LeftPlayer)->TargetHealth == 0 || ((BattlePlayer*)RightPlayer)->TargetHealth == 0 )
{
FRAMEWORK->ProgramStages->Push( new TransitionStrips( new BattleOver( this ), FRAMES_PER_SECOND, 80 ) );
}
for( std::list<Pickup*>::const_iterator i = GamePickups.begin(); i != GamePickups.end(); i++ )
{
Pickup* p = (*i);
p->Update();
}
}
示例2: main
//.........这里部分代码省略.........
switch (event.type) { // HANDLE ALLEGRO EVENTS
case ALLEGRO_EVENT_TIMER:
render = true;
if (stage == Game) spawn_counter++;
break;
case ALLEGRO_EVENT_DISPLAY_CLOSE:
executing = false;
break;
case ALLEGRO_EVENT_KEY_DOWN:
executing = event.keyboard.keycode != ALLEGRO_KEY_ESCAPE;
switch(event.keyboard.keycode) {
case ALLEGRO_KEY_A:
case ALLEGRO_KEY_LEFT:
if (stage == Game) player->Velocity.x = -5;
break;
case ALLEGRO_KEY_D:
case ALLEGRO_KEY_RIGHT:
if (stage == Game) player->Velocity.x = 5;
break;
}
break;
case ALLEGRO_EVENT_KEY_UP:
if (stage == Game) {
player->Velocity.x = 0;
player->Velocity.y = 0;
}
break;
default: break;
}
switch (stage) { // UPDATE
case Menu:
play->Update(&event);
leaderboard->Update(&event);
options->Update(&event);
quit->Update(&event);
break;
case Game:
if (player->m_body->GetPosition().x < 1) player->m_body->SetTransform(b2Vec2(screen_w - 2, player->m_body->GetPosition().y), 0);
if (player->m_body->GetPosition().x > screen_w - 1) player->m_body->SetTransform(b2Vec2(2, player->m_body->GetPosition().y), 0);
if (spawn_counter > 75) {
spawn_counter = 0;
ALLEGRO_BITMAP *meteor_png;
switch (rand() % 4) { // Size
case 0:
switch (rand() % 4) { // Selection
case 0:
meteor_png = rand() % 2 ? assets->png_meteor_brown_big1 : assets->png_meteor_grey_big1;
break;
case 1:
meteor_png = rand() % 2 ? assets->png_meteor_brown_big2 : assets->png_meteor_grey_big2;
break;
case 2:
meteor_png = rand() % 2 ? assets->png_meteor_brown_big3 : assets->png_meteor_grey_big3;
break;
case 3:
meteor_png = rand() % 2 ? assets->png_meteor_brown_big4 : assets->png_meteor_grey_big4;
break;
default: break;
}
break;
case 1:
switch (rand() % 2) { // Selection
case 0:
meteor_png = rand() % 2 ? assets->png_meteor_brown_med1 : assets->png_meteor_grey_med1;
示例3: Update
/**
* Update cycle
*
* Checks for keypresses:
* - Esc - Quits the game
* - Left - Rotates ship left
* - Right - Rotates ship right
* - Up - Accelerates the ship
* - Down - Deccelerates the ship
*
* Also calls Update() on all the ships in the universe
*/
bool Application::Update()
{
float timedelta = hge_->Timer_GetDelta();
if (bulletShootTimer < S_BULLET_SHOOT_INTERVAL)
{
bulletShootTimer += timedelta;
}
if (missileShootTimer < S_MISSILE_SHOOT_INTERVAL)
{
missileShootTimer += timedelta;
}
ships_.at(0)->SetAngularVelocity(0.0f);
// Lab 13 Task 4 : Add a key to shoot missiles
/*if (hge_->Input_GetKeyState(HGEK_ENTER))
{
if (!keydown_enter)
{
CreateMissile(ships_.at(0)->GetX(), ships_.at(0)->GetY(), ships_.at(0)->GetW(), ships_.at(0)->GetID());
keydown_enter = true;
}
}
else
{
if (keydown_enter)
{
keydown_enter = false;
}
}*/
static const float MAX_ENTER_TIMER = 0.5f;
static float enterTimer;
if (enterTimer < MAX_ENTER_TIMER)
{
enterTimer += timedelta;
}
// Chat
if (chatMode)
{
char input = hge_->Input_GetKey();
if (input == HGEK_ESCAPE)
{
chatMode = false;
typingMsg = "";
}
else if (input == HGEK_ENTER && enterTimer >= MAX_ENTER_TIMER)
{
// Send
if (typingMsg != "")
{
RakNet::BitStream chatBS;
chatBS.Write((unsigned char)ID_CHAT_SEND);
chatBS.Write(typingMsg.c_str());
rakpeer_->Send(&chatBS, HIGH_PRIORITY, RELIABLE_ORDERED, 0, UNASSIGNED_SYSTEM_ADDRESS, true);
chatList.push_back(typingMsg);
}
// Reset
chatMode = false;
typingMsg = "";
enterTimer = 0.f;
chatShowTimer = 5.f;
}
else if (input >= 32 && input <= 126)
{
typingMsg += input;
}
}
else
{
if (chatShowTimer > 0.f)
{
chatShowTimer -= timedelta;
}
if (hge_->Input_GetKeyState(HGEK_ENTER) && enterTimer >= MAX_ENTER_TIMER)
{
chatMode = true;
enterTimer = 0.f;
}
// Ship controls
if (hge_->Input_GetKeyState(HGEK_LEFT))
{
//.........这里部分代码省略.........