int main() { if(!Window::Initialise("Game Technologies", 1280,800,false)) { return Quit(true, "Window failed to initialise!"); } if(!Renderer::Initialise()) { return Quit(true, "Renderer failed to initialise!"); } PhysicsSystem::Initialise(); MyGame* game = new MyGame(); Window::GetWindow().LockMouseToWindow(true); Window::GetWindow().ShowOSPointer(false); bool running = true; std::thread physics(physicsLoop, game, std::ref(running)); while(Window::GetWindow().UpdateWindow() && !Window::GetKeyboard()->KeyDown(KEYBOARD_ESCAPE)){ float msec = Window::GetWindow().GetTimer()->GetTimedMS(); //How many milliseconds since last update? game->UpdateRendering(msec); //Update our 'sybsystem' logic (renderer and physics!) game->UpdateGame(msec); //Update our game logic } running = false; physics.join(); delete game; //Done with our game now...bye bye! return Quit(); }
int main (int argc, char * const argv[]) { MyGame game; game.Init(); game.Start(); return 0; }
int main() { MyGame game; game.setXS(15); game.setYS(15); game.run(); return (0); }
int main() { Menu menu; MyGame game; menu.run(); game.run(); return (EXIT_SUCCESS); }
MyGame * MyGame::create(int mission_id) { MyGame *pRet = new(std::nothrow) MyGame(); if (pRet && pRet->init(mission_id)) { pRet->autorelease(); return pRet; } else { delete pRet; pRet = nullptr; return nullptr; } return nullptr; }
int main(int argc, char *argv[], char *envp[]) { (void)argc; (void)argv; if (envp == NULL || getenv("PATH") == NULL) { std::cerr << "[ERROR] : Environment variable `PATH` missing." << std::endl; } else { MyGame game; srand(time(NULL)); game.run(); } return (EXIT_SUCCESS); }
int main(int argc, char *argv[]) #endif { // Create application object MyGame app; try { app.go(); } catch( Ogre::Exception& e ) { #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL); #else std::cerr << "An exception has occured: " << e.getFullDescription().c_str() << std::endl; #endif } return 0; }
int main(int argc, char* argv[]) { MyGame myGame; myGame.SetTitle("Loading..."); myGame.Init(); myGame.SetTitle("SDL_Testing!"); myGame.Start(); myGame.SetTitle("Quiting..."); return EXIT_SUCCESS; }
int main(int argc, char** argv) { cpp3ds::Console::enable(cpp3ds::BottomScreen); // Console for reading stdout MyGame game; game.run(); return 0; }
int main() { Disp::Menu *main_menu = new Disp::Menu; Disp::MenuLabel *menu_label = new Disp::MenuLabel(-25, -15, 50, 20); MyGame *game = new MyGame; map::map *map = new map::map(20, 20, 2); Bloc::Wall *wall = new Bloc::Wall(*map); Bloc::Box *box = new Bloc::Box(*map); Bloc::Blank *blank = new Bloc::Blank(*map); Bloc::Morebomb *Morebomb = new Bloc::Morebomb(*map); Bloc::Lessbomb *Lessbomb = new Bloc::Lessbomb(*map); Bloc::Morepower *Morepower = new Bloc::Morepower(*map); Bloc::Lesspower *Lesspower = new Bloc::Lesspower(*map); Fire *fire = new Fire(map, 0,0,1); Bombe *bomb = new Bombe(0,0,1,fire); Setting1 config1; Setting2 config2; Character *Character1 = new Character(map, &config1, 2, bomb); Character *Character2 = new Character(map, &config2, 5, bomb); while(2) { game->setMap(map); game->add_object(wall); game->add_object(box); game->add_object(blank); game->add_object(Morebomb); game->add_object(Lessbomb); game->add_object(fire); game->add_object(bomb); game->add_object(Morepower); game->add_object(Lesspower); game->setCharacter1(Character1); game->setCharacter2(Character2); game->add_object(Character1); game->add_object(Character2); main_menu->add_object(menu_label); main_menu->lbl_ = menu_label; main_menu->run(); if (menu_label->MenuDecide == true) { switch (menu_label->MenuCurr) { case 1: menu_label->MenuDecide = false; game->run(); break; case 2: //load return 0; break; case 3: //save return 0; break; case 4: return 0; break; } } } }
int main(int argc, char* argv[]) { MyGame* game = nullptr; // pointer to allow game termination when exceptions are caught try { load(WINDOW_WIDTH, WINDOW_HEIGHT); SDL_Window* window = SDL_GL_GetCurrentWindow(); SDL_GLContext glContext = SDL_GL_GetCurrentContext(); MyGame myGame(window, glContext, WINDOW_WIDTH, WINDOW_HEIGHT); // should MyGame become owner of window and glcontext when passed them? would change ~MyGame() // also, should MyGame::Terminate and Initialize even exist? Initialize could be constructor, terminate destructor game = &myGame; myGame.Initialize(); myGame.Draw(); unsigned int lastUpdate = SDL_GetTicks(); while (myGame.isRunning()) { if (lastUpdate + 66 < SDL_GetTicks()) { myGame.Update(); myGame.Draw(); lastUpdate = SDL_GetTicks(); } } myGame.Terminate(); unload(); } catch (SDLInitError err) { printf("%s, err: %s", err.getMessage().c_str(), SDL_GetError()); std::cin.get(); } catch (InitError err) { printf("Initialization failed, err: %s", err.getMessage().c_str()); std::cin.get(); } catch (GLError err) { char* type = ""; GLchar log[512]; switch (err.getType()) { case GLErrorType::PROGRAM: type = "Program"; glGetProgramInfoLog(err.getHandle(), 512, NULL, log); break; case GLErrorType::PROGRAM_PIPELINE: type = "Program Pipeline"; glGetProgramPipelineInfoLog(err.getHandle(), 512, NULL, log); break; case GLErrorType::SHADER: type = "Shaders"; glGetShaderInfoLog(err.getHandle(), 512, NULL, log); break; } printf("Error with GL %s. \nError Message: %s.\n", type, err.getMessage().c_str()); std::cout << "GL Log: " << log << std::endl; std::cin.get(); } if (game) { game->Terminate(); } unload(); return 0; }
Entity MyEntity::create(MyGame& game) { Entity ent = game.createEntity(GET_ETYPE_ID(MyEntity)); ent.getComponent<CMovable>().getSpeed().setAngularSpeed(Angle::Pi/4); CRenderables& rs = ent.getComponent<CRenderables>(); RectRenderable& rr = rs.addRenderable<RectRenderable>().init(game); rr.setSize(Vec2{1000, 200}); rr.setGeomNormOffset(-Vec2{0.5, 0.5}); rr.setLayerId(0); rr.setColor(Colorf::Red()); RectBorderRenderable& rbr = rs.addRenderable<RectBorderRenderable>().init(game); rbr.setSize(Vec2{120, 200}); rbr.setGeomNormOffset(-Vec2{0.5, 0.5}); rbr.setLayerId(0); rbr.setColor(Colorf::Red()); rbr.setBorders({50, 20}); rbr.accLocalTransform().setPosition({(float)250, (float)250}); for (uint32_t i=0; i<3; ++i) { int r_to = rand()%100 + 20; int r_from = rand()%(r_to-10); int x = rand()%1024 - 512; int y = rand()%768 - 384; CircleRenderable& cc = rs.addRenderable<CircleRenderable>().init(game, r_to, r_from); cc.setLayerId(1); float r = (float)rand()/RAND_MAX; float g = (float)rand()/RAND_MAX; float b = (float)rand()/RAND_MAX; cc.setColor(Colorf(r, g, b, 1)); cc.accLocalTransform().setPosition({(float)x, (float)y}); } SpriteRenderable& s1 = rs.addRenderable<SpriteRenderable>().init(game); s1.setImageRegion(sprite_region); s1.accLocalTransform().setScale(Vec2{0.5, 0.5}); s1.setTextureUnit(0); s1.setLayerId(2); SpriteRenderable& s2 = rs.addRenderable<SpriteRenderable>().init(game); s2.setTextureUnit(0); s2.setAnimation(animation_id); s2.setLayerId(2); s2.setEndAction(SpriteRenderable::eaChangeDir); s2.accLocalTransform().setPosition({-100, 0}); TextRenderable& tr = rs.addRenderable<TextRenderable>().init(game); tr.setTextureUnit(1); tr.getTextSetter().setFont(game.assets.fonts_pack_id).setFontSize(45).setText("This is SPARTA!"); tr.accLocalTransform().setPosition({100, 0}); PgonRenderable& pr = rs.addRenderable<PgonRenderable>().init(game); Vec2 vertices[6] = { {268, 162}, {309, 107}, {471, 130}, {517, 257}, {445, 324}, {263, 315} }; ARect bound(vertices, 6); for (uint32_t i=0; i<6; ++i) { vertices[i] -= bound.getCenter(); pr.getGeom().addVertex(vertices[i]); } pr.setLayerId(3); pr.accLocalTransform().setPosition({-200, 200}); pr.accLocalTransform().setScale({0.8f, 0.8f}); return ent; }
void Monster::gameOver(MyGame& game) { state = sDead; getSprite(sprEye).setTextureCoords(resources_.eye_dead_reg_.getTextureRect()); getSprite(sprEye).getLocalTransform().setRotation(-Angle::Pi/2); game.getHUD().gameOver(game); }
int main(int argc, char** argv) { MyGame* mygame = new MyGame(); return mygame->run(); }