bool Game::SpriteCollision(Sprite* pSpriteHitter, Sprite* pSpriteHittee){ GameEngine *pGameEngine = GameEngine::GetEngine(); // See if the chicken was hit if (pSpriteHittee == _pChickenSprite) { // Move the chicken back to the start _pChickenSprite->SetPosition(4, 175); // See if the game is over if (--_iNumLives > 0) SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION , "Henway", "Ouch!", pGameEngine->GetWindow()); else { // Display game over message char szText[64]; sprintf(szText, "Game Over! You scored %d points.", _iScore); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION , "Henway", szText, pGameEngine->GetWindow()); _bGameOver = true; } return false; } return true; }
LRESULT CALLBACK LogoutButtonProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { if (msg == WM_LBUTTONDOWN) { GameEngine* gameEngine = GameEngine::getInstance(); // // TODO save user with PersistenceManager // gameEngine->setUser(NULL); // // Set game state back to initial. // gameEngine->setState(GameEngine::STATE_INITIAL); // // Reset table state // Table* table = GameEngine::getInstance()->getTable(); table->setState(TABLE_STATE_READY); delete table->getDealerHand(); delete table->getPlayerHand(); table->setDealerHand(NULL); table->setPlayerHand(NULL); RedrawWindow(GameEngine::getInstance()->getHWnd(), NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); } return CallWindowProc(oldLogoutButtonProc, hwnd, msg, wp, lp); }
/* a static function to satisfy SDL_CreateThread */ int GameEngine::EntryPoint(void *p) { GameEngine *pt = (GameEngine *)p; pt->Thread(); return 1; }
void Game::End() { GameEngine *pGameEngine = GameEngine::GetEngine(); // Cleanup the sprites pGameEngine->CleanupSprites(); //Cleanup the music Mix_FreeMusic(_mmMusic); //Cleanup the sound effects Mix_FreeChunk(_mcWhack); Mix_FreeChunk(_mcTaunt); Mix_FreeChunk(_mcBoo); // Cleanup the bitmaps delete _pOfficeBitmap; delete _pTargetBitmap; delete _pPowBitmap; for (int i = 0; i < 5; i++) delete _pGuyBitmaps[i]; delete _pSmallGuyBitmap; delete _pGameOverBitmap; // Cleanup the game engine delete pGameEngine; }
LRESULT CALLBACK HitButtonProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { if (msg == WM_LBUTTONDOWN) { PlaySound(L"sound-flipcard.wav", NULL, SND_FILENAME | SND_ASYNC); GameEngine* gameEngine = GameEngine::getInstance(); Table* table = gameEngine->getTable(); Hand* playerHand = table->getPlayerHand(); playerHand->dealCard(false); // Check for bust. if (playerHand->isBusted()) { table->setState(TABLE_STATE_FINISHED); updateTextarea(hStaticTableMiddleMessage, "Busted. Dealer Wins."); } RedrawWindow(gameEngine->getHWnd(), NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); } return CallWindowProc(oldHitButtonProc, hwnd, msg, wp, lp); }
int main(int argc, const char *argv[]) { GameEngine game; game.Run(); return 0; }
int main(int argc, char* argv[]) { GameEngine engine; engine.mainLoop(); return 0; }
// Player choses new game or to load the previous one void Choice(GameEngine &gm) { cout<<" New game -> 1\n Load game -> 2\n"; int choice; cin >> choice; switch (choice) { case 1: { Map m1(1); gm.setMap(m1); break; } case 2: { Map m2(0); // Putting '0' in the Map's constructor loades the saved map gm.setMap(m2); ifstream file("Save.dat", std::ios::binary); Hero h1(file); gm.hero = h1; break; } default: cout<<" Please restart the game and press correct number !!!\n"; fail = true; isRunning = false; break; } }
int main() { GameEngine GM; // The player chooses new game or loading saved game Choice(GM); // Setting the position of the hero GM.hero.setHeroPos(GM.getMap()); if(!fail) GM.Print(); while( isRunning ) { GM.choseAction( getch() ); GM.Print(); if(GM.hero.getLife() <= 0) isRunning = false; } if(win) cout<<"\n\n You win !!!\n\n"; else cout<< "\n\n Game Over\n\n"; if(fail) cout<<"\nSOME FILES DOES NOT EXIT,\n\tPLEASE CHECK YOUR GAME'S FOLDER\n"; return 0; }
//----------------------------------------------------------------- // 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 = "Meteor Defense"; const char* game_icon = "res/MeteorDefense.ico"; int window_width = 600; int window_height = 450; //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; }
void Game::Paint() { GameEngine *pGameEngine = GameEngine::GetEngine(); SDL_Renderer *renderer = pGameEngine->GetRenderer(); // Draw the background office _pOfficeBitmap->Draw(renderer, 0, 0); // Draw the sprites pGameEngine->DrawSprites(); // Draw the number of guys who were hit char szText[64]; SDL_Rect rect = { 237, 360, 50, 50 }; sprintf(szText, " %d ", _iHits); SDL_Color text_color = {120, 120, 120}; SDL_Texture *text_texture = pGameEngine->DrawText(renderer, szText, _ttfFont, text_color); if(text_texture)SDL_RenderCopy(renderer, text_texture, NULL, &rect); // Draw the number of guys who were missed (got away) for (int i = 0; i < _iMisses; i++) _pSmallGuyBitmap->Draw(renderer, 389 + (_pSmallGuyBitmap->GetWidth() * i), 359); // Draw the game over message, if necessary if (_bGameOver) _pGameOverBitmap->Draw(renderer, 120, 110); SDL_RenderPresent(renderer); }
int main(){ GameEngine ge; // ge.run(); ge.run(); // ge.close(); return 0; }
int main() { Graphic::WindowStyle style = Graphic::Window::Titlebar | Graphic::Window::Closeable | Graphic::Window::Resizeable; Vector2ui winSize(800, 600); // create the game engine with the config file name. Engine::Manager manager("3dNovac.conf"); // create the window. Graphic::Window window("Tuto 1", winSize, style, "Nc:Image:logo/logoNcTransparent.png", 3); // create the graphic engine, limit it's frame rate to 60 frame by second to avoid to take 100% of the CPU // and add the engine to the manager. Graphic::Engine *graphic = new Graphic::Engine(&window, &manager); graphic->LimitFrameRate(60); manager.AddEngine(graphic); // create our game engine, limit its frame rate, and add the engine to the manager. GameEngine *game = new GameEngine(&window, &manager); game->LimitFrameRate(60); manager.AddEngine(game); // start the engines and wait for them to terminate. manager.Start(); manager.Wait(); return 0; }
//int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) int main() { GameEngine ge; ge.run(); return (0); }
int main( int argc, char** argv ){ GameEngine *engine = new GameEngine(); engine->gameLoop(); return 0; }
static void setWindowCloseCallback(GLFWwindow* window) { GameEngine* engine = (GameEngine*)glfwGetWindowUserPointer(window); if (engine) { ray::AppQuitEvent quit; engine->sendMessage(&quit); } }
int main() { GameEngine engine; if(engine.initialize() == false) return(EXIT_FAILURE); while (engine.update() == true) engine.draw(); return EXIT_SUCCESS; }
void Game::Cycle() { if (!_bGameOver) { GameEngine *pGameEngine = GameEngine::GetEngine(); // Update the sprites pGameEngine->UpdateSprites(); } }
int main ( int argc, char *argv[] ) { GameEngine game; // initialisation du jeu game.Init( "Ultimate Abyss" ); // load the intro //game.ChangeState(new Start()); //game.ChangeState(new Field()); game.ChangeState(new Menu()); // main loop while ( game.Running() ) { game.HandleEvents(); game.Update(); game.Draw(); SDL_Delay(1000/game.getFramesPerSecond()); } // cleanup the engine game.Cleanup(); return 0; }
int main(int argc, char * argv[]) { GraphicEngine graphicEngine(argc,argv); GameEngine gameEngine; gameEngine.start(); Engine::sendEvent(new Event(LOADLVL)); Engine::seekEvent(); graphicEngine.start(); return 0; }
void CommandEngine::ebo(std::string &tmp, GameEngine &game) { try { std::vector<std::string> myArg = this->getArg(tmp); if (myArg.size() != 1) throw ErrorClient("Wrong Argument", "CommandEngine"); game.getMap().removeGhost(StringToNumber<int>(myArg[0])); game.getHudLeft().removeGhost(); } catch (ErrorClient const &e) { throw ErrorClient(e.what(), "CommmandEngine"); } }
void CommandEngine::tna(std::string &tmp, GameEngine &game) { try { std::vector<std::string> myArg = this->getArg(tmp); if (myArg.size() != 1) throw ErrorClient("Wrong Argument", "CommandEngine"); game.addTeam(myArg[0]); game.getHudLeft().addTeam(); } catch (ErrorClient const &e) { throw ErrorClient(e.what(), "CommmandEngine"); } }
void Game::Paint() { GameEngine* pGE = GameEngine::GetEngine(); SDL_Renderer* renderer = pGE->GetRenderer(); // Draw the background and saucer bitmaps _pBackground->Draw(renderer, 0, 0); _pSaucer[_bSaucerFlame ? 1:0]->Draw(renderer, _iSaucerX, _iSaucerY); // Force a repaint to redraw the saucer SDL_RenderPresent(renderer); }
void CommandEngine::pdi(std::string &tmp, GameEngine &game) { try { std::vector<std::string> myArg = this->getArg(tmp); if (myArg.size() < 1) throw ErrorClient("Wrong Argument", "CommandEngine"); game.getPlayer(StringToNumber<int>(myArg[0])).setDie(true); game.removePlayer(StringToNumber<int>(myArg[0])); } catch (ErrorClient const &e) { throw ErrorClient(e.what(), "CommmandEngine"); } }
int main(int argc, char *argv[]) { GameEngine *engine = new GameEngine(resx,resy,"Extreme Mission",30.0f); //engine->PushScene(new IntroScene(engine)); //engine->PushScene(new MenuScene(engine)); //engine->PushScene(new MisionScene(engine)); engine->PushScene(new MainScene(engine)); engine->Loop(); delete engine; return 0; }
void* launchGameEngine(void *param) { GameEngine* engine = reinterpret_cast<GameEngine *>(param); while (1) { engine->getThreadCond()->wait(); std::cout << "endWait" << std::endl; engine->launch(); } return (NULL); }
int main (void) { GameEngine GE; GE.initialize(std::string("script.lua")); //if(initializelua(std::string("script.lua"))) return 0; GE.gameloop(); GE.end(); //getchar(); return 0; }
void CommandEngine::enw(std::string &tmp, GameEngine &game) { try { std::vector<std::string> myArg = this->getArg(tmp); if (myArg.size() < 4) throw ErrorClient("Wrong Argument", "CommandEngine"); game.getMap().addEgg(StringToNumber<int>(myArg[2]), StringToNumber<int>(myArg[3]), StringToNumber<int>(myArg[0])); game.getHudLeft().addEgg(); game.getPlayer(StringToNumber<int>(myArg[1])).setEgg(false); } catch (ErrorClient const &e) { throw ErrorClient(e.what(), "CommmandEngine"); } }
int main( int argc, char** argv ){ cout << "Starting: " << PACKAGE_STRING << endl << "Please send all bug reports to: " << PACKAGE_BUGREPORT << endl; GameEngine *e = new GameEngine(); e->Init(); e->Execute(); delete e; return 0; }
bool Game::Initialize() { //get the game engine GameEngine *pGameEngine = GameEngine::GetEngine(); // Set the frame rate pGameEngine->SetFrameRate(30); // Initialize the joystick pGameEngine->InitJoystick(); return true; }