void GameState::KeyJustPressed(int key) { if (key==DIK_ESCAPE) manager->SetState(mainMenuState); else if (userChatMessageInput.GetUserInput()==false && key==DIK_SPACE && (currentState==GAME_LOST || currentState==GAME_WON || currentState==RESTART_WAITING_ON_LOCAL_SYSTEM)) { if (rakClient->IsConnected()==false && rakServer->IsActive()==false) RestartGame(); // Single player else { char c=ID_RESTART_GAME; if (rakClient->IsConnected()) rakClient->Send(&c, 1, HIGH_PRIORITY, RELIABLE, 0); else if (rakServer->IsActive()) rakServer->Send(&c, 1, HIGH_PRIORITY, RELIABLE, 0, 255, true, false); if (currentState==RESTART_WAITING_ON_LOCAL_SYSTEM) // They already indicated they wanted to start RestartGame(); else { currentState=RESTART_WAITING_ON_REMOTE_SYSTEM; // We are now waiting for them (game restarts from network code) strcpy(gameMessage, "Waiting for opponent to restart game."); } } } else if (CanChoosePerk()) { for (int i=0; i < numberOfPerksToChooseFrom; i++) if (key==DIK_1 + i) { GivePerkToPlayer(perks[i], user->GetTeam(), false); break; } } else if (rakServer->IsActive() || rakClient->IsConnected()) { userChatMessageInput.KeyJustPressed(key); if (key==DIK_RETURN) { TransmitChatMessage((char*)userChatMessageInput.GetUserInput()); AddChatMessage((char*)user->userName.GetUserInput(), (char*)userChatMessageInput.GetUserInput()); userChatMessageInput.SetText(0); userChatMessageInput.StartTextInput(); } } /* #ifdef _DEBUG if (key==DIK_L) { players[0].IncreaseExperience(10); players[1].IncreaseExperience(10); } #endif */ }
// Handle the gameflow, start, restartm die...etc. void ShipRace::Update() { // Get the button to start the game if the game is not already started...Meh ! if (gDInput->keyPressed(DIK_SPACE) && !mGameStarted) { // Init the game InitGame(); } // If gameOver... if (!mGameOver) { // and the game is started... if (mGameStarted) { // and the ship is dead if (ship->GetIsDead()) { // Gameover ! GameOver(); } } } // Else if space is pressed and it is gameover else if (gDInput->keyPressed(DIK_SPACE) && mGameOver) { // Restart the game RestartGame(); } }
int main(void){ TExaS_Init(SSI0_Real_Nokia5110_Scope); // set system clock to 80 MHz DisableInterrupts(); Random_Init(1); Nokia5110_Init(); Nokia5110_ClearBuffer(); Nokia5110_DisplayBuffer(); SysTick_Init(); // initialize Timer2 after Nokia5110_Init because of // error-prone registers operations (old and new registers // are not working good together) // 80MHz/11,025 cycles, which is about 7256 Timer2_Init(7256); Ports_Init(); InitSprites(NumberOfEnemies); RestartGame(); // Countdown, after which all interrupts are enabled! // print 3 Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_03, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); // print 2 Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_02, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); // print 1 Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_01, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); // print GO Nokia5110_ClearBuffer(); Nokia5110_PrintBMP(28, 41, _my_Countdown_GO, 0); Nokia5110_DisplayBuffer(); Delay100ms(3); EnableInterrupts(); while(1){ if (Flag == 1) { Nokia5110_DisplayBuffer(); Flag = 0; } } }
void MyWorld::Update() { // Adjust perspective based on dimensions of screen to keep board in view int max = IwGxGetScreenHeight() > IwGxGetScreenWidth() ? IwGxGetScreenHeight() : IwGxGetScreenWidth(); setPerspective(480.0f - (1024 - max) / 2); // Update camera swing if (CamSwing) { float d = CamSwingTime / CAM_SWING_TIME; LookFrom.x = StartCamSwingPos.x + (FinalCamSwingPos.x - StartCamSwingPos.x) * d; LookFrom.y = StartCamSwingPos.y + (FinalCamSwingPos.y - StartCamSwingPos.y) * d; LookFrom.z = StartCamSwingPos.z + (FinalCamSwingPos.z - StartCamSwingPos.z) * d; TransformDirty = true; CamSwingTime++; if (CamSwingTime > CAM_SWING_TIME) { CamSwing = false; CamSwingTime = 0; } } // TODO: Add world logic here World::Update(); switch (GameState) { case eGameState_GameOver: if (GameOverTimer.HasTimedOut()) { RestartGame(); } break; case eGameState_Running: if (TurnsLeftChanged) { char str[64]; snprintf(str, 64, "%u", TurnsLeft); TurnsLeftLabel->setText(str); TurnsLeftChanged = false; } if (RoundChanged) { char str[64]; snprintf(str, 64, "%u", Round); RoundLabel->setText(str); RoundChanged = false; } break; } }
void ALabyrinthGameMode::DefaultTimer() { Super::DefaultTimer(); // don't update timers for play in editor mode, it's not a real match if (GetWorld()->IsPlayInEditor()) { // start the match if necessary if (GetMatchState() == MatchState::WaitingToStart) { StartMatch(); } return; } ALGameState* const MyGameState = Cast<ALGameState>(GameState); if (MyGameState && MyGameState->RemainingTime > 0 && !MyGameState->bIsTimerPaused) { MyGameState->RemainingTime--; if (MyGameState->RemainingTime <= 0) { if (GetMatchState() == MatchState::WaitingPostMatch) { RestartGame(); } else if (GetMatchState() == MatchState::InProgress) { FinishMatch(); // Send end round events ALGameState* const MyGameState = Cast<ALGameState>(GameState); for (FConstControllerIterator It = GetWorld()->GetControllerIterator(); It; It++) { ALPlayerController* PlayerController = Cast<ALPlayerController>(*It); if (PlayerController && MyGameState) { ALPlayerState* PlayerState = Cast<ALPlayerState>((*It)->PlayerState); const bool bIsWinner = IsWinner(PlayerState); // TO-DO: Add this to the Player controller //PlayerController->ClientSendRoundEndEvent(bIsWinner, MyGameState->ElapsedTime); } } } else if (GetMatchState() == MatchState::WaitingToStart) { StartMatch(); } } } }
void AShooterGameMode::DefaultTimer() { // don't update timers for Play In Editor mode, it's not real match if (GetWorld()->IsPlayInEditor()) { // start match if necessary. if (GetMatchState() == MatchState::WaitingToStart) { StartMatch(); } return; } AShooterGameState* const MyGameState = Cast<AShooterGameState>(GameState); if (MyGameState && MyGameState->RemainingTime > 0 && !MyGameState->bTimerPaused) { MyGameState->RemainingTime--; if (MyGameState->RemainingTime <= 0) { if (GetMatchState() == MatchState::WaitingPostMatch) { RestartGame(); } else if (GetMatchState() == MatchState::InProgress) { FinishMatch(); // Send end round events for (FConstControllerIterator It = GetWorld()->GetControllerIterator(); It; ++It) { AShooterPlayerController* PlayerController = Cast<AShooterPlayerController>(*It); if (PlayerController && MyGameState) { AShooterPlayerState* PlayerState = Cast<AShooterPlayerState>((*It)->PlayerState); const bool bIsWinner = IsWinner(PlayerState); PlayerController->ClientSendRoundEndEvent(bIsWinner, MyGameState->ElapsedTime); } } } else if (GetMatchState() == MatchState::WaitingToStart) { StartMatch(); } } } }
void AFSMGameMode::OnGameEnd() { switch (EndMapBehavior) { case EMapEndBehavior::Quit: { UKismetSystemLibrary::QuitGame(GetWorld(), UGameplayStatics::GetPlayerController(GetWorld(),0), EQuitPreference::Quit); break; } case EMapEndBehavior::Restart: { RestartGame(); break; } } }
void AOnlineArenaGameMode::DefaultTimer() { const auto World = GetWorld(); if (nullptr != World && World->IsPlayInEditor()) { //!< PIE ‚Ì�ê�‡ if (MatchState::WaitingToStart == GetMatchState()) { StartMatch(); } } else { const auto MatchSteate = GetMatchState(); const auto GS = Cast<AOnlineGameState>(GameState); if (nullptr != GS) { --GS->RemainingTime; if (GS->RemainingTime <= 0) { GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Red, TEXT("TIME UP")); if (MatchState::WaitingPostMatch == MatchState) { RestartGame(); } else if (MatchState::InProgress == MatchState) { EndMatch(); } } else { GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Red, FString::FromInt(GS->RemainingTime)); if (MatchState::WaitingToStart == MatchState) { StartMatch(); } } } } }
void Game::Update(float deltaTime, float alphaMul) { if (!m_IsActive) return; if (m_Manager->GetCurrent() == this) { // Update base scene Scene::Update(deltaTime, alphaMul); if (!gameOver) { if (m_IsInputActive) { if (!DBZBlast) { NormalGameLoop(); } else { DBZLoop(); } } } else { if ((g_pInput->m_Touched && !g_pInput->m_PrevTouched) || (g_pInput->m_Touched && g_pInput->m_PrevTouched)) { restartButtonHit = gameOverSprite->HitTest(g_pInput->m_X, g_pInput->m_Y); } else if (!g_pInput->m_Touched && g_pInput->m_PrevTouched) { if (restartButtonHit && gameOverSprite->HitTest(g_pInput->m_X, g_pInput->m_Y)) { RestartGame(); } g_pInput->Reset(); } } } }
void CHL2MPRules::Think( void ) { #ifndef CLIENT_DLL CGameRules::Think(); if ( g_fGameOver ) // someone else quit the game already { // check to see if we should change levels now if ( m_flIntermissionEndTime < gpGlobals->curtime ) { if ( !m_bChangelevelDone ) { ChangeLevel(); // intermission is over m_bChangelevelDone = true; } } return; } // float flTimeLimit = mp_timelimit.GetFloat() * 60; float flFragLimit = fraglimit.GetFloat(); if ( GetMapRemainingTime() < 0 ) { GoToIntermission(); return; } if ( flFragLimit ) { if( IsTeamplay() == true ) { CTeam *pCombine = g_Teams[TEAM_COMBINE]; CTeam *pRebels = g_Teams[TEAM_REBELS]; if ( pCombine->GetScore() >= flFragLimit || pRebels->GetScore() >= flFragLimit ) { GoToIntermission(); return; } } else { // check if any player is over the frag limit for ( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer *pPlayer = UTIL_PlayerByIndex( i ); if ( pPlayer && pPlayer->FragCount() >= flFragLimit ) { GoToIntermission(); return; } } } } if ( gpGlobals->curtime > m_tmNextPeriodicThink ) { CheckAllPlayersReady(); CheckRestartGame(); m_tmNextPeriodicThink = gpGlobals->curtime + 1.0; } if ( m_flRestartGameTime > 0.0f && m_flRestartGameTime <= gpGlobals->curtime ) { RestartGame(); } if( m_bAwaitingReadyRestart && m_bHeardAllPlayersReady ) { UTIL_ClientPrintAll( HUD_PRINTCENTER, "All players ready. Game will restart in 5 seconds" ); UTIL_ClientPrintAll( HUD_PRINTCONSOLE, "All players ready. Game will restart in 5 seconds" ); m_flRestartGameTime = gpGlobals->curtime + 5; m_bAwaitingReadyRestart = false; } ManageObjectRelocation(); #endif }
void DogfightClass::UpdateDogfight (void) { if (vuxRealTime > lastUpdateTime + VU_TICS_PER_SECOND) { // Check for new players TheCampaign.MissionEvaluator->RebuildEvaluationData(); // Update the game status UpdateGameStatus(); // Update local game status if (localGameStatus == dog_EndRound) { // Only Matchplay gets here :-) if ((restart_matchplay_round) && (vuxRealTime > static_cast<VU_TIME>(restart_matchplay_round))) { MonoPrint ("Ending Round Now\n"); RoundOver (); if (GameOver()) { EndGame(); OTWDriver.EndFlight(); } else { EndRound(); } restart_matchplay_round = 0; } else { MonoPrint ("Still waiting to end round %d\n", restart_matchplay_round - vuxRealTime); if ((gameType == dog_TeamMatchplay) && (CheckRoundOver() == 0)) { RoundOver (); if (GameOver()) { EndGame(); OTWDriver.EndFlight(); } else { EndRound(); } restart_matchplay_round = 0; } } } else if (localGameStatus == dog_Flying) { if ((gameType == dog_TeamMatchplay) && (CheckRoundOver() <= 1)) { MonoPrint ("GameStatus: dog EndRound\n"); restart_matchplay_round = vuxRealTime + 10 * VU_TICS_PER_SECOND; localGameStatus = dog_EndRound; } else if (GameOver()) { EndGame(); OTWDriver.EndFlight(); } else if (GameManager.NoMorePlayers(FalconLocalGame)) { EndGame(); } else if (gameType != dog_TeamMatchplay) { RegenerateAvailableAircraft(); } } else if (localGameStatus == dog_Starting) { if (gameType == dog_TeamMatchplay) { // Wait until all players are no longer flying before resetting if (gameStatus != dog_Flying) { ResetRound(); } // Wait until all players are ready before restarting if (GameManager.AllPlayersReady(FalconLocalGame)) { GameManager.ReleasePlayer(FalconLocalSession); action_cam_started = FALSE; action_cam_time = 0; OTWDriver.SetExitMenu(FALSE); MonoPrint ("GameStatus: dog Flying\n"); localGameStatus = dog_Flying; } } else { RegenerateAvailableAircraft(); MonoPrint ("GameStatus: dog Flying\n"); localGameStatus = dog_Flying; } } else { // Check for game restart if ((localFlags & DF_VIEWED_SCORES) && (gameStatus == dog_Waiting)) { RestartGame(); } if ((FalconLocalSession->GetFlyState() >= FLYSTATE_LOADING) && (FalconLocalSession->GetFlyState() <= FLYSTATE_FLYING)) { MonoPrint ("GameStatus: dog Starting\n"); localGameStatus = dog_Starting; } } lastUpdateTime = vuxRealTime; if ((!SimDriver.GetPlayerEntity()) && (!action_cam_started) && (!action_cam_time)) { action_cam_time = vuxRealTime + 10 * VU_TICS_PER_SECOND; action_cam_started = TRUE; } if ((action_cam_started) && (static_cast<VU_TIME>(action_cam_time) > vuxRealTime)) { OTWDriver.ToggleActionCamera(); action_cam_started = FALSE; } } }
bool GameState::ProcessPacket(Packet* p, unsigned char packetIdentifier) { switch (packetIdentifier) { case ID_DISCONNECTION_NOTIFICATION: strcpy(gameMessage, "Opponent has quit."); currentState=CONNECTION_LOST; break; case ID_KICKED_BY_SERVER: strcpy(gameMessage, "You have been kicked out of the server."); currentState=CONNECTION_LOST; break; case ID_MODIFIED_PACKET: strcpy(gameMessage, "Opponent is cheating. Disconnecting"); currentState=CONNECTION_LOST; break; case ID_CONNECTION_LOST: strcpy(gameMessage, "Connection lost to opponent."); currentState=CONNECTION_LOST; break; case ID_SUMMON_CREATURE: #ifdef _DEBUG manager->LogWrite("ID_SUMMON_CREATURE."); #endif ReceiveSummonCreature(p); break; case ID_KILL_CREATURE: #ifdef _DEBUG manager->LogWrite("ID_KILL_CREATURE."); #endif ReceiveKillCreature(p); break; case ID_SET_CREATURE_TEAM: #ifdef _DEBUG manager->LogWrite("ID_SET_CREATURE_TEAM."); #endif ReceiveSetCreatureTeam(p); break; case ID_CHOOSE_PERK: #ifdef _DEBUG manager->LogWrite("ID_CHOOSE_PERK."); #endif ReceiveChoosePerk(p); break; case ID_CREATE_FIREBALL: #ifdef _DEBUG manager->LogWrite("ID_CREATE_FIREBALL."); #endif ReceiveCreateFireball(p); break; case ID_SET_CASTLE_HEALTH: #ifdef _DEBUG manager->LogWrite("ID_SET_CASTLE_HEALTH."); #endif ReceiveSetCastleHealth(p); break; case ID_CHAT_MESSAGE: #ifdef _DEBUG manager->LogWrite("ID_CHAT_MESSAGE."); #endif ReceiveChatMessage(p); break; case ID_RESTART_GAME: #ifdef _DEBUG manager->LogWrite("ID_RESTART_GAME."); #endif if (currentState==RESTART_WAITING_ON_REMOTE_SYSTEM) RestartGame(); else { currentState=RESTART_WAITING_ON_LOCAL_SYSTEM; strcpy(gameMessage, "Opponent is waiting for new game. Hit space to restart."); } break; default: manager->LogWrite("Unknown packet type in GameState::ProcessPacket. Type %i with length %i", packetIdentifier, p->length); assert(1); break; } return true; }
void nGame::Process() { static float absoluteTime = 0.0f; static float absoluteTime2 = 0.0f; // Check for pause key if(nGetInstance()->GetInput()->GetKeyboard()->GetNewKey(DIK_PAUSE) || nGetInstance()->GetInput()->GetKeyboard()->GetNewKey(DIK_P)) SetPause(!GetPause()); // Don't process further if paused if(m_Pause) return; absoluteTime += nGetInstance()->GetElapsedTime(); absoluteTime2 += nGetInstance()->GetElapsedTime(); // Create enemy missle if enough time passed if(absoluteTime > m_MissleTime) { // Reset the timer absoluteTime = 0.0f; if(m_MissleTime > 1.0f) m_MissleTime -= (double)nGetInstance()->GetElapsedTime() / 4.0f; // Create a missle at a random top position going to a random bottom position AddMissle(nVector2(randf(0.0f,nGetInstance()->GetGraphics()->GetDisplaySize().cx),0.0f),nVector2(randf(0.0f,nGetInstance()->GetGraphics()->GetDisplaySize().cx),nGetInstance()->GetGraphics()->GetDisplaySize().cy),1.0f,80.0f,GAME_ENEMY_COLOR,false,true); } // Create child enemy missle if enough time passed if(absoluteTime2 > 100.0f) { // Reset the timer absoluteTime2 = 0.0f; if(m_Missles.size()) { // Create a missle at a random trail of a nother missle unsigned long count = 1 + rand() % 3; Missle* missle = &m_Missles[rand() % m_Missles.size()]; // Find a live enemy missle while(missle->frendly || missle->dead > 0.0f) missle = &m_Missles[rand() % m_Missles.size()]; nVector2 dir = missle->position - missle->source; float length = dir.Length(); dir.Normalize(); nVector2 source = missle->source + dir * randf(0.0f,length); for(unsigned long i = 0; i < count; i++) AddMissle(source,nVector2(randf(0.0f,nGetInstance()->GetGraphics()->GetDisplaySize().cx),nGetInstance()->GetGraphics()->GetDisplaySize().cy),1.0f,80.0f,GAME_ENEMY_COLOR,false,true); } } // Check left missle silo launch if(nGetInstance()->GetInput()->GetMouse()->GetNewButton(nMouse::ButtonLeft)) FireSilo(m_Silos[0],nGetInstance()->GetInput()->GetMouse()->GetPosition(),20.0f,80.0f,true); // Check right missle silo launch if(nGetInstance()->GetInput()->GetMouse()->GetButton(nMouse::ButtonRight)) { // Get a random vector in a sphere domain nVector2 miss(randf(-1.0f,1.0f),randf(-1.0f,1.0f)); miss.Normalize(); miss *= randf(0.0f,50.0f); FireSilo(m_Silos[1],nGetInstance()->GetInput()->GetMouse()->GetPosition() + miss,30.0f,20.0f,false); } // Remove silo fire time for(unsigned long i = 0; i < m_Silos.size(); i++) { Silo* silo = &m_Silos[i]; // Remove some fire time silo->time -= nGetInstance()->GetElapsedTime(); // Check if all/too much fire time was removed if(silo->time < 0.0f) silo->time = 0.0f; } // Move missles and remove dead ones for(unsigned long i = 0; i < m_Missles.size(); i++) { Missle* missle = &m_Missles[i]; if(missle->position == missle->destination || missle->dead > 0.0f) { if(missle->position == missle->destination && !missle->frendly && missle->dead == 0.0f) { // Players base got hit SetHealth(GetHealth() - 10); // Check if player dead if(!GetHealth()) { // Game over AddHiScore(m_Score); RestartGame(); return; } } if(missle->dead > 10.0f) { // Remove missle RemoveMissle(i--); continue; } if(missle->dead == 0.0f) { // Explode AddExplosion(missle->position,missle->blast,4.0f,nColor(1.0f,0.1f,1.0f)); } missle->dead += nGetInstance()->GetElapsedTime(); continue; } if(missle->target > 0.0f) missle->target -= nGetInstance()->GetElapsedTime() / 10.0f; else if(missle->target < 0.0f) missle->target = 0.0f; nVector2 velocity = missle->destination - missle->source; velocity.Normalize(); velocity *= missle->speed * nGetInstance()->GetElapsedTime(); if(velocity.x > 0.0f && missle->position.x + velocity.x > missle->destination.x) missle->position.x = missle->destination.x; else if(velocity.x < 0.0f && missle->position.x + velocity.x < missle->destination.x) missle->position.x = missle->destination.x; else missle->position.x += velocity.x; if(velocity.y > 0.0f && missle->position.y + velocity.y > missle->destination.y) missle->position.y = missle->destination.y; else if(velocity.y < 0.0f && missle->position.y + velocity.y < missle->destination.y) missle->position.y = missle->destination.y; else missle->position.y += velocity.y; } // Expand explosions and remove dead ones for(unsigned long i = 0; i < m_Explosions.size(); i++) { Explosion* explosion = &m_Explosions[i]; if(explosion->size == explosion->power) { // Remove it RemoveExplosion(i--); continue; } float expansion = explosion->speed * nGetInstance()->GetElapsedTime(); if(explosion->size + expansion > explosion->power) explosion->size = explosion->power; else explosion->size += expansion; // Check if the explosion destroyed any missles for(unsigned long j = 0; j < m_Missles.size(); j++) { Missle* missle = &m_Missles[j]; // Skip frendly or already dead missles if(missle->frendly || missle->dead > 0.0f) continue; nVector2 dir = missle->position - explosion->position; unsigned long points = 0; if(dir.Length() < explosion->size) { // Set death time missle->dead += nGetInstance()->GetElapsedTime(); // Create some particles for(unsigned long k = 0; k < 50; k++) { // Get a random vector in a sphere domain nVector2 velocity(randf(-1.0f,1.0f),randf(-1.0f,1.0f)); velocity.Normalize(); velocity *= randf(0.0f,5.0f); AddParticle(missle->position,velocity,nVector2(0.0f,0.1f),10.0f,GAME_COLOR_PARTICLES); } // Add player points points++; } // Add score if(points > 1) SetScore(GetScore() + points + points / 2); else SetScore(GetScore() + points); } } // Move and remove particles for(unsigned long i = 0; i < m_Particles.size(); i++) { Particle* particle = &m_Particles[i]; // Remove the particle if it's dead if(particle->lived >= particle->life) { // Remove it RemoveParticle(i--); continue; } particle->lived += nGetInstance()->GetElapsedTime(); particle->velocity += particle->force * nGetInstance()->GetElapsedTime(); particle->position += particle->velocity * nGetInstance()->GetElapsedTime(); } }
Common::Error TinselEngine::run() { // Initialize backend if (getGameID() == GID_DW2) { #ifndef DW2_EXACT_SIZE initGraphics(640, 480, true); #else initGraphics(640, 432, true); #endif _screenSurface.create(640, 432, 1); } else { initGraphics(320, 200, false); _screenSurface.create(320, 200, 1); } g_system->getEventManager()->registerRandomSource(_random, "tinsel"); _console = new Console(); _scheduler = new Scheduler(); InitSysVars(); // init memory manager MemoryInit(); // load user configuration ReadConfig(); #if 1 // FIXME: The following is taken from RestartGame(). // It may have to be adjusted a bit CountOut = 1; RebootCursor(); RebootDeadTags(); RebootMovers(); resetUserEventTime(); RebootTimers(); RebootScalingReels(); DelayedScene.scene = HookScene.scene = 0; #endif // Load in text strings ChangeLanguage(g_language); // Init palette and object managers, scheduler, keyboard and mouse RestartDrivers(); // load in graphics info SetupHandleTable(); // Actors, globals and inventory icons LoadBasicChunks(); // Continuous game processes CreateConstProcesses(); // allow game to run in the background //RestartBackgroundProcess(); // FIXME: is this still needed? //dumpMusic(); // dumps all of the game's music in external XMIDI files // Load game from specified slot, if any // // TODO: We might want to think about properly taking care of possible // errors when loading the save state. if (ConfMan.hasKey("save_slot")) { if (loadGameState(ConfMan.getInt("save_slot")) == Common::kNoError) loadingFromGMM = true; } // Foreground loop uint32 timerVal = 0; while (!shouldQuit()) { assert(_console); if (_console->isAttached()) _console->onFrame(); // Check for time to do next game cycle if ((g_system->getMillis() > timerVal + GAME_FRAME_DELAY)) { timerVal = g_system->getMillis(); AudioCD.updateCD(); NextGameCycle(); } if (bRestart) { RestartGame(); bRestart = false; bHasRestarted = true; // Set restarted flag } // Save/Restore scene file transfers ProcessSRQueue(); // Handle any playing movie FettleBMV(); #ifdef DEBUG if (bFast) continue; // run flat-out #endif // Loop processing events while there are any pending while (pollEvent()) ; DoCdChange(); if (MoviePlaying() && NextMovieTime()) g_system->delayMillis(MAX<int>(NextMovieTime() - g_system->getMillis() + MovieAudioLag(), 0)); else g_system->delayMillis(10); } // Write configuration WriteConfig(); return Common::kNoError; }