//----------------------------------------------------------------- // Main function //----------------------------------------------------------------- int main (int argc, char* argv[]) { //get the game engine GameEngine *pGameEngine = GameEngine::GetEngine(); //instantiate the game IGame *pGame = new Game; //assign the created game to the engine pGameEngine->m_game = pGame; const char* game_name = "Battle Office 2"; const char* game_icon = "res/BattleOffice.ico"; int window_width = 500; int window_height = 400; //Initialize or quit if an error occured if (!pGameEngine->Initialize(game_name, game_icon, window_width, window_height) || !pGame->Initialize()){ std::cout << "INIT ERR: " << SDL_GetError() << std::endl; return EXIT_FAILURE; } pGameEngine->Run(); return EXIT_SUCCESS; }
//----------------------------------------------------------------- // Main function //----------------------------------------------------------------- int main (int argc, char* argv[]) { //instanciante the game IGame *pGame = new Game; //get the game engine GameEngine *pGameEngine = GameEngine::GetEngine(); static int iTickTrigger = 0; int iTickCount; bool done = false; const char* game_name = "Game skeleton"; const char* game_icon = "res/Skeleton.ico"; //Initialize or quit if an error occured if (!pGameEngine->Initialize(game_name, game_icon) || !pGame->Initialize()){ std::cout << "INIT ERR" << std::endl; return EXIT_FAILURE; } //start the game now pGameEngine->SetSleep(false); pGame->Start(); // Enter the main message loop while (!done) { // Make sure the game engine isn't sleeping if (!pGameEngine->GetSleep()){ // Check the tick count to see if a game cycle has elapsed iTickCount = SDL_GetTicks(); if (iTickCount > iTickTrigger){ iTickTrigger = iTickCount + pGameEngine->GetFrameDelay(); pGame->Cycle(); } } pGameEngine->HandleEvent(); // Paint the game pGame->Paint(); } // End the game pGame->End(); return EXIT_SUCCESS; }