// Loads the ending screen and gives to possiblity to Replay or Quit void ShipRace::EndingScreen() { if (!mIsGameOver) { DisableGame(); } ReplayGame(); QuitGame(); }
// Dtor ShipRace::~ShipRace() { // If the game is not started only delete the necessary stuffs if (mGameStarted) { // Delete everything QuitGame(); } else { // Delete titlescren delete title; } }
void GameManager::SetGameState(const StateType &newState) { // Handle the transitioning depending on new state switch (newState) { case(StateType::MainMenu) : _transitionController = new MainMenuController(); _currentState = newState; _bIsTransitioning = true; break; case(StateType::Battling) : _transitionController = new BattleController(*AvatarSerializer::GetInstance().GetPlayer(), aiDifficulty); _currentState = newState; _bIsTransitioning = true; break; case(StateType::Quitting) : QuitGame(); _currentState = newState; break; } }
void Menu::Update() { title->Update(); // タイトルロゴ if (!title->isStop) return; // 止まっていなければここはスルー const bool INPUT_VERTICAL = ( Keyboard_Get(KEY_INPUT_DOWN) == 1 || Keyboard_Get(KEY_INPUT_UP) == 1 ); const bool INPUT_OK = ( Keyboard_Get(KEY_INPUT_Z) == 1 || Keyboard_Get(KEY_INPUT_RETURN) == 1 ); const bool PUSH_KEY_UP = ( Keyboard_Get(KEY_INPUT_UP) == 1 ); const bool PUSH_KEY_DOWN = ( Keyboard_Get(KEY_INPUT_DOWN) == 1 ); const bool STATE_START = selectNum == 0; const bool STATE_QUIT = selectNum == 3; y_cur = y[selectNum] - 2; // カーソルの位置 if (INPUT_VERTICAL) PlaySoundMem(hs_move, DX_PLAYTYPE_BACK); // ♪カーソル音 if (PUSH_KEY_UP) selectNum = (selectNum + 3) % ALL_SELECT_NUM; // カーソルの移動と選択項目 if (PUSH_KEY_DOWN) selectNum = (selectNum + 1) % ALL_SELECT_NUM; if(INPUT_OK) // 決定キーを押したなら { if (STATE_START) { PlaySoundMem(hs_choice, DX_PLAYTYPE_BACK); // ♪決定音 isGame = true; } if (STATE_QUIT) QuitGame(); // ゲームをやめる } if(isGame) { c_game->Update(); if (c_game->isLast()) mSceneChanger->ChangeScene(eScene_Game); } score->Update(); // スコアデータ更新 AnotherUpdate(); // It's a secret. }
void GameManager::PlayGame() { while (!doExit) //Main Game Loop { RunGameOverCheck(); UpdateGameTimers(); UpdatePlayerInput(); UpdateEnemySpawner(); UpdateEnemies(); UpdatePlayer(); UpdateBullets(); RunCollisionCheck(); Render(); //Render everyting } QuitGame(); }
static void SDL_Fail(char *s, display *d) { fprintf(stderr, "%s %s \n", s, SDL_GetError()); fflush(stdout); QuitGame(d); exit(EXIT_FAILURE); }
void run() { display *d = newDisplay(); Button *buttons[NUM_BUTTONS]; int i, j, stop = 0, leave = 1, which_alien, money = 0, which_screen = 0; char result, **compare, *input_instruction; int user_input, wins = 0; compare = createAndFillArraywiththeInstuctions(ALIENS, INSTRUCTION); input_instruction = (char*)calloc(1, ALIENS); errorForAllocation(input_instruction); buttons[0] = createButton(940, 580, 40, 70, "WORKS");//x,y,w,h buttons[1] = createButton(280, 430, 40, 70, "WORKS"); Text grid; fillGrid(grid); Cursor *cursor = malloc(sizeof(Cursor)); cursor->r = 0; //------------------------------------ cursor->c = 0; //--------------------------- Money *moneyP = malloc(sizeof(Money)); moneyP->moneyNum = 5; while (!stop && wins < GAMES) { drawEnity(d, 0, 0, 0); result = getEvent(d, buttons); if (result == QUIT) { stop = 1;; } user_input = 0; printf("in main"); fflush(stdout); i = POSITION1, j = POSITION2; //aline location which_alien = rand() % 4 + 1; delayUntilNextAlien(1000); //Animation loop with logic while ((i > POSITION2 || j < POSITION1) && !stop) { drawFrame(d, buttons); result = getEvent(d, buttons); drawEnity(d, which_screen, 0, 0); drawGrid(d, grid, cursor->r, cursor->c); DrawMoney(moneyP, d); if (result == QUIT) { stop = 1;; } else if (result == ENTER) { // if (strcmp(&input_instruction[which_alien], compare[i]) == 0) { money += 100; leave = 1; wins++; // }; } if (i > POSITION2 && result != QUIT) { drawEnity(d, which_alien, 300, i); i--; leave = 0; } if (leave == 0 && i == POSITION2 && result != QUIT) { drawEnity(d, which_alien, 300, POSITION2); result = getEvent(d, buttons); if (result == CLICK1) { leave = 1; } else if (result == HINT) { writeTextToSurface(d, "PLEASW WORK!!!", 255, 255, 255); drawEnity(d, which_alien + ALIENS, 100, 200); } } if (isalpha(result)) { input_instruction[user_input] = result; if (user_input < ALIENS) { user_input++; } else { printf("You are trying to write something to long\n"); } } else if (result == DEL) { if (user_input >= 0) { user_input--; } } if (j < POSITION1 && leave == 1 && result != QUIT) { drawEnity(d, which_alien, 300, j); j++; result = getEvent(d, buttons); } if (result == QUIT) { stop = 1;; } else if ((result != NONE )&&( result!=CLICK1 )&&(result!=HINT)) { action(grid, cursor, result); } } } QuitGame(d); }
void C4Application::GameTick() { // Exec depending on game state switch (AppState) { case C4AS_None: assert(AppState != C4AS_None); break; case C4AS_Quit: // Do nothing, the main loop will exit soon break; case C4AS_PreInit: if (!PreInit()) Quit(); break; case C4AS_Startup: SoundSystem.Execute(); MusicSystem.Execute(); // wait for the user to start a game break; case C4AS_StartGame: // immediate progress to next state; OpenGame will enter HandleMessage-loops in startup and lobby! C4Startup::CloseStartup(); AppState = C4AS_Game; // first-time game initialization if (!Game.Init()) { // set error flag (unless this was a lobby user abort) if (!C4GameLobby::UserAbort) Game.fQuitWithError = true; // no start: Regular QuitGame; this may reset the engine to startup mode if desired QuitGame(); break; } if(Config.Graphics.Windowed == 2 && FullScreenMode()) Application.SetVideoMode(GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, true); break; case C4AS_AfterGame: // stop game Game.Clear(); if(Config.Graphics.Windowed == 2 && !NextMission && !isEditor) Application.SetVideoMode(GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, false); AppState = C4AS_PreInit; // if a next mission is desired, set to start it if (NextMission) { Game.SetScenarioFilename(NextMission.getData()); Game.fLobby = Game.NetworkActive; Game.fObserve = false; NextMission.Clear(); } break; case C4AS_Game: // Game if (Game.IsRunning) Game.Execute(); // Sound SoundSystem.Execute(); MusicSystem.Execute(); // Gamepad if (pGamePadControl) pGamePadControl->Execute(); break; } }
bool HumanClientApp::ExitGame() { QuitGame(); Exit(0); // Not reached, but required for HotkeyManager::Connect() return true; }
void C4Application::Execute() { CStdApp::Execute(); // Recursive execution check static int32_t iRecursionCount = 0; ++iRecursionCount; // Exec depending on game state assert(AppState != C4AS_None); switch (AppState) { case C4AS_Quit: // Do nothing, HandleMessage will return HR_Failure soon break; case C4AS_PreInit: if (!PreInit()) Quit(); break; case C4AS_Startup: #ifdef USE_CONSOLE // Console engines just stay in this state until aborted or new commands arrive // on stdin #else AppState = C4AS_Game; // if no scenario or direct join has been specified, get game startup // parameters by startup dialog Game.ScenarioTitle.Copy(LoadResStr("IDS_PRC_INITIALIZE")); if (!C4Startup::Execute()) { Quit(); --iRecursionCount; return; } AppState = C4AS_StartGame; #endif break; case C4AS_StartGame: // immediate progress to next state; OpenGame will enter // HandleMessage-loops // in startup and lobby! AppState = C4AS_Game; // first-time game initialization if (!OpenGame()) { // set error flag (unless this was a lobby user abort) if (!C4GameLobby::UserAbort) Game.fQuitWithError = true; // no start: Regular QuitGame; this may reset the engine to startup mode // if desired QuitGame(); } break; case C4AS_Game: { uint32_t iThisGameTick = timeGetTime(); // Game (do additional timing check) if (Game.IsRunning && iRecursionCount <= 1) if (Game.GameGo || !iExtraGameTickDelay || (iThisGameTick > iLastGameTick + iExtraGameTickDelay)) { // Execute Game.Execute(); // Save back time iLastGameTick = iThisGameTick; } // Graphics if (!Game.DoSkipFrame) { uint32_t iPreGfxTime = timeGetTime(); // Fullscreen mode if (isFullScreen) FullScreen.Execute(iRecursionCount > 1); // Console mode else Console.Execute(); // Automatic frame skip if graphics are slowing down the game (skip max. // every 2nd frame) Game.DoSkipFrame = Game.Parameters.AutoFrameSkip && ((iPreGfxTime + iGameTickDelay) < timeGetTime()); } else Game.DoSkipFrame = false; // Sound SoundSystem.Execute(); // Gamepad if (pGamePadControl) pGamePadControl->Execute(); break; } } --iRecursionCount; }