// Reduce energy of each character if we are in death mode void GameClassic::ApplyDeathMode () const { if (IsGameFinished()) return; if (GameTime::GetInstance()->Read() > GameMode::GetInstance()->duration_before_death_mode * 1000) { GameMessages::GetInstance()->Add(_("Hurry up, you are too slow !!"), white_color); FOR_ALL_LIVING_CHARACTERS(team, character) { // If the character energy is lower than damage // per turn we reduce the character's health to 1 if (static_cast<uint>(character->GetEnergy()) > GameMode::GetInstance()->damage_per_turn_during_death_mode) // No damage dealer, thus pass NULL character->SetEnergyDelta(-(int)GameMode::GetInstance()->damage_per_turn_during_death_mode, NULL); else character->SetEnergy(1, NULL); } }
int _tmain(int argc, _TCHAR* argv[]) { Game game; InitGame(game); while (!IsGameFinished(game)) { // Get game time game.t = timeGetTime(); GetUserInput(game); PerformAI(game); DrawGame(game); } DisplayResults(game); TerminateGame(game); return 0; }
// Beginning of a new turn void GameClassic::__SetState_PLAYING() { MSG_DEBUG("game.statechange", "Playing"); // initialize counter duration = GameMode::GetInstance()->duration_turn; Interface::GetInstance()->UpdateTimer(duration, false, true); Interface::GetInstance()->EnableDisplayTimer(true); last_clock_update = GameTime::GetInstance()->Read(); Wind::GetRef().UpdateStrength(); SetCharacterChosen(false); // Prepare each character for a new turn FOR_ALL_LIVING_CHARACTERS(team,character) character->PrepareTurn(); // Select the next team ASSERT (!IsGameFinished()); GetTeamsList().NextTeam(); give_objbox = true; //hack: make it so that there is no more than one objbox per turn }
void GameClassic::RefreshClock() { GameTime * global_time = GameTime::GetInstance(); if (1000 < global_time->Read() - last_clock_update) { last_clock_update = global_time->Read(); switch (state) { case PLAYING: if (duration <= 1) { /* let the user release the key to shoot */ if (ActiveTeam().GetWeapon().IsLoading()) break; JukeBox::GetInstance()->Play("default", "end_turn"); SetState(END_TURN); } else { duration--; if (duration == 12) { countdown_sample.Play("default", "countdown-end_turn"); } if (duration > 10) { Interface::GetInstance()->UpdateTimer(duration, false, false); } else { Interface::GetInstance()->UpdateTimer(duration, true, false); } } break; case HAS_PLAYED: if (duration <= 1) { SetState(END_TURN); } else { duration--; Interface::GetInstance()->UpdateTimer(duration, false, false); } break; case END_TURN: if (duration <= 1) { if (IsAnythingMoving()) { duration = 1; // Hack to be sure that nothing is moving since long enough // it avoids giving hand to another team during the end of an explosion for example break; } if (IsGameFinished()) { duration--; break; } if (give_objbox && GetWorld().IsOpen()) { NewBox(); give_objbox = false; break; } else { SetState(PLAYING); break; } } else { duration--; } break; } // switch }// if }