// Do this forever until we quit out of gameLoop->start(); static void mainLoop () { GameLoop *gameLoop = new GameLoop(); gameLoop->start(); }
static void motor_post_tick_callback (btDynamicsWorld *world, btScalar timeStep) { GameLoop *loop = static_cast<GameLoop *>(world->getWorldUserInfo()); loop->handle_collisions(); // manual callbacks of "logic_tick" function for each // object. for (IGameObject* obj: loop->event_objs) { obj->logic_tick(*loop); } }
int wmain() { Graphics::Init(); Graphics::NewWindow({ 1600, 900 }, false, { 1600, 900 }, "Graphics Engine"); GameLoop oGameLoop; oGameLoop.Loop(); Graphics::Quit(); return 0; }
int wmain() { Graphics::Init(); Graphics::NewWindow(UVector2(1600u, 900u), UVector2(1600u, 900u), false, "Graphics Engine"); Graphics::NewCamera(); GameLoop gameLoop; gameLoop.Run(); Graphics::Quit(); return 0; }
int runGame() { int res; char const* err_msg = NULL; SDL_Window *window; SDL_GLContext glcontext; GameLoop *gameloop; // Setup if (!(window = init_SDL())) { cout << "Failed to initialize SDL. Exiting." << endl; return -1; } if (!(glcontext = init_GL(window))) { cout << "Failed to initialize openGL. Exiting." << endl; destroy_SDL(); return -1; } cout << "Running with OpenGL version " << glGetString(GL_VERSION) << endl; try { gameloop = new GameLoop(window); res = gameloop->run_game_loop(); if (res < 0) cout << "Game exiting with failure." << endl; delete gameloop; } catch (char const *msg) { err_msg = msg; } // Cleanup destroy_GL(glcontext); destroy_SDL(); if (err_msg != NULL) throw err_msg; else return 0; }
int main(int argc, char** argv) { // DEBUG: allow selection of the level from cmdline long int level = -1; if(argc == 2) { if(std::string(argv[1]) == std::string("--help")) { std::cout << "Usage: "<<argv[0]<<" [level_id]"<<std::endl; std::cout <<std::endl; std::cout<<"Arguments:" <<std::endl; std::cout<<" level_id : [optional] a natural number to select the level." <<std::endl; return 0; } else { level = atol(argv[1]); } } // End of cmdline parsing video::SColor bg_color = video::SColor(255,50,50,50); GameLoop loop; loop.initialize_irrlicht(); loop.initialize_bullet(); // DEBUG: allow selection of the level from cmdline if(level != -1) { srand(level); } // End of DEBUG section loop.smgr->setAmbientLight(video::SColor(100,1,1,50)); GameScene game_scene; game_scene.create_scene(loop); // hide the cursor loop.device->getCursorControl() -> setVisible(false); loop.start_loop(); return 0; }
int wmain() { // testing math lib Vector2D<float> vector2d(6,12); // printing vector made from math library vector2d.print(); Graphics::Init(); Graphics::NewWindow({ 800, 600 }, false, { 800, 600 }, "Graphics Engine"); GameLoop oGameLoop; oGameLoop.Loop(); Graphics::Quit(); return 0; }
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){ SetMainWindowText("Give Me Wing"); SetOutApplicationLogValidFlag(FALSE); ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK ); //ウィンドウモード変更と初期化と裏画面設定 font_db.LoadFontData(); //画像ファイルのロード img_db.LoadImgData(); sound_db.LoadSoundData(); Fps fps; GameLoop loop; bool game_start = FALSE; while( ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 ){ input.Update(); //キーボード情報の更新 fps.Update(); // ↓ 処理本体をここに書く ↓ if(!game_start){ game_start = TRUE; } if(game_start){ if(loop.Loop() == 1) break; } SetDrawArea(GAME_X,GAME_Y,GAME_X+GAME_WIDTH,GAME_Y+GAME_HEIGHT);//描画エリアをゲーム範囲に設定 efect.Update(); SetDrawArea(0,0,WINDOWSIZE_X,WINDOWSIZE_Y); //描画エリアを元に戻す // ↑ 処理本体をここに書く ↑ fps.Draw(); fps.Wait(); //fps制御 } DxLib_End(); //終了処理 return 0; }
int main(void) { WorldState worldstate; RenderState renderstate; PlayerState playerstate; GameLoop gameloop; renderstate.width = 800; renderstate.height = 600; renderstate.vsync = true; renderstate.fullscreen = false; renderstate.title = "Brainz"; gameloop.setWorldState(&worldstate); gameloop.setRenderState(&renderstate); gameloop.setPlayerState(&playerstate); gameloop.onInit(); std::cout << "Starting Game!" << std::endl; return gameloop.playGame(); }
void Init() { HWND consoleWindow = GetConsoleWindow(); // Get the current console window SetWindowPos(consoleWindow, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER); // Move it to the Top Left and don't change its size or 'z' order Graphics::Init(); Text::Init("Fonts/Pokemon Red.ttf", { 255, 255, 255, 255 }, 32); Time::Init(); Graphics::NewWindow({ 1600, 900 }, false, { 1600, 900 }, "New Window", 1); /*srand(time(NULL)); float fCurrentTime = 0; float fPreviousTime = 0; float fDeltaTime = 0; float fAnimateTime = 0; System::Point2D<float> Center = { 800, 400 }; System::Point2D<float> CirclePos = { 0, 0 }; System::Point2D<float> LineBeginPos = { Center.X, Center.Y + 250 }, LineEndPos = { Center.X, Center.Y + 350 }; System::Color<float> CircleColor = { 255, 255, 255, 255 }; float fMovementRadius = 50; float fAngle = 0, fLineAngle = 0; bool bFade = true; bool bAnimateLine = false; bool bMoveLeft = true; bool bZoom = false; Graphics::GLSurface<float>* Eyes = Graphics::LoadSurface<float>("Images/Eyes.png"); Graphics::GLSurface<float>* NewEyes = Graphics::LoadSurface<float>("Images/Eyes.png"); float fZoomTime = 0, fNewZoomTime = 0; float fZoomSpeed = 0.1, fNewZoomSpeed = 0.1; NewEyes->Pos = Center; NewEyes->bIsActive = false; NewEyes->Scale = { 0.001f, 0.001f }; NewEyes->Center = { 180, 80 }; Eyes->Pos = { 314 / 2, 219 / 2 }; Eyes->Center = { 180, 80 }; bool bEyesHigh = false; while (true) { if (GetAsyncKeyState(VK_SPACE)) bAnimateLine = true; if (GetAsyncKeyState(VK_RETURN)) { Eyes->Scale = { 0.001f, 0.001f }; bZoom = true; } fPreviousTime = fCurrentTime; fCurrentTime = clock(); fDeltaTime = (fCurrentTime - fPreviousTime) / ONE_SECOND; fAngle += 5 * fDeltaTime; CirclePos = { fMovementRadius * cosf(fAngle), fMovementRadius * sinf(fAngle) }; CirclePos += Center; if (bFade) CircleColor.Alpha -= 100 * fDeltaTime; else CircleColor.Alpha += 100 * fDeltaTime; if (bFade && CircleColor.Alpha <= 0) { CircleColor.Alpha = 0; bFade = false; } else if (!bFade && CircleColor.Alpha >= 255) { CircleColor.Alpha = 255; bFade = true; } if (bAnimateLine) { fAnimateTime += fDeltaTime; if (bMoveLeft) fLineAngle += 2 * fDeltaTime; else fLineAngle -= 2 * fDeltaTime; if (bMoveLeft && fLineAngle >= PI) { fLineAngle = PI; bMoveLeft = false; } else if (!bMoveLeft && fLineAngle <= 0) { fLineAngle = 0; bMoveLeft = true; } LineBeginPos = { 100 * cosf(fLineAngle), -100 * sinf(fLineAngle) + 350 }; LineBeginPos += Center; if (fAnimateTime > 5) { fAnimateTime = 0; fLineAngle = 0; bAnimateLine = false; } } CircleColor.Blue = rand() % 255; CircleColor.Green = rand() % 255; CircleColor.Red = rand() % 255; if (bZoom) { if (Eyes->bIsActive) { Eyes->Pos = Center; Eyes->Scale.W += fZoomSpeed * fDeltaTime; Eyes->Scale.H = Eyes->Scale.W; fZoomSpeed += fZoomSpeed * 1.7 * fDeltaTime; fZoomTime += fDeltaTime; if (fZoomTime >= 3) { bEyesHigh = true; NewEyes->bIsActive = true; } if (fZoomTime >= 6) { bEyesHigh = false; fZoomTime = 0; Eyes->Scale = { 0.01f, 0.01f }; fZoomSpeed = 0.1; } } if (NewEyes->bIsActive) { NewEyes->Scale.W += fNewZoomSpeed * fDeltaTime; NewEyes->Scale.H = NewEyes->Scale.W; fNewZoomSpeed += fNewZoomSpeed * 1.7 * fDeltaTime; fNewZoomTime += fDeltaTime; if (fNewZoomTime >= 3) { bEyesHigh = false; } if (fNewZoomTime >= 6) { bEyesHigh = true; fNewZoomTime = 0; NewEyes->Scale = { 0.01f, 0.01f }; fNewZoomSpeed = 0.1; } } } Graphics::DrawCircle(CirclePos, 100.0f, 50.0f, CircleColor); Graphics::DrawLine(LineBeginPos, LineEndPos, { 255, 0, 255, 255 }); Graphics::DrawLine({ 0, 0 }, CirclePos, CircleColor); Graphics::DrawLine({ 0, 900 }, CirclePos, CircleColor); Graphics::DrawLine({ 1600, 0 }, CirclePos, CircleColor); Graphics::DrawLine({ 1600, 900 }, CirclePos, CircleColor); if (bEyesHigh) { Graphics::DrawSurface(*Eyes); Graphics::DrawSurface(*NewEyes); } else { Graphics::DrawSurface(*NewEyes); Graphics::DrawSurface(*Eyes); } Graphics::Flip(); }*/ srand((unsigned int)time(NULL)); GameLoop oGameLoop; oGameLoop.Run(); }
int main(int argc, char *argv[]) { TestAction actionBidon; int init_flags = SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK; if ( SDL_Init(init_flags) < 0 ) { fprintf(stderr, "SDL initialisation error: %s\n", SDL_GetError()); exit(1); } GameLoop *loop = GameUIDefaults::GAME_LOOP; SDL_Surface *display = SDL_SetVideoMode( 640, 480, 0, SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF); if ( display == NULL ) { fprintf(stderr, "SDL_SetVideoMode error: %s\n", SDL_GetError()); exit(1); } loop->setSurface(display); atexit(SDL_Quit); SDL_ShowCursor(SDL_DISABLE); SDL_WM_SetCaption("FloboPop by iOS-Software",NULL); // Font par défaut SoFont *darkFont = SoFont_new(); SoFont *menuFont = SoFont_new(); SoFont *textFont = SoFont_new(); SoFont_load_ttf(darkFont, "data/base.000/gfx/font.ttf", 17, SoFont_DARK); SoFont_load_ttf(menuFont, "data/base.000/gfx/font.ttf", 17, SoFont_STD); SoFont_load_ttf(textFont, "data/base.000/gfx/font.ttf", 24, SoFont_GREY); GameUIDefaults::FONT_TEXT = textFont; GameUIDefaults::FONT = menuFont; GameUIDefaults::FONT_INACTIVE = darkFont; GameCursor *cursor = new GameCursor("data/base.000/gfx/cursor.png"); loop->addDrawable(cursor); loop->addIdle(cursor); Screen scr(0, 0, 640, 480); pscr = &scr; VBox bidonBox; Text bidonText("Hello"); ShowModalDialogAction showDialogAction(scr.getRootContainer()); FramePicture fpict(IIM_Load_Absolute_DisplayFormatAlpha("data/base.000/gfx/frame.png"), 25, 28, 25, 19, 26, 23); windowFramePict = &fpict; FramePicture fpict2(IIM_Load_Absolute_DisplayFormatAlpha( "data/base.000/gfx/editfield.png"), 5, 23, 4, 6, 10, 3); FramePicture fpict3(IIM_Load_Absolute_DisplayFormatAlpha( "data/base.000/gfx/separator.png"), 63, 2, 63, 2, 4, 2); RGBA blackTranslucient = {(Uint8)0x00, (Uint8)0x00, (Uint8)0x00, (Uint8)0x80}; RGBA buttonGray = {(Uint8)0xCC, (Uint8)0x95, (Uint8)0x36, (Uint8)0xFF}; RGBA textFieldColor = {(Uint8)0xFA, (Uint8)0xEF, (Uint8)0xDB, (Uint8)0xFF}; fpict.setContentColor(blackTranslucient); fpict2.setContentColor(textFieldColor); fpict3.setContentColor(buttonGray); Frame frame(&fpict), frame2(&fpict2); frame2.setFocusedPicture(&fpict3); //frame.setPreferedSize(Vec3(100, 100)); FramedButton framedButton1("Hi1", NULL, &fpict2, &fpict3); Button bidonButton1("Hi2", &showDialogAction); TestFloboStatsAction statsAction; Button bidonButton2("Stats", &statsAction); Button bidonButton3("Hop"); FramedEditField bidonField("toto", NULL, &fpict2, &fpict2); IIM_Surface *upArrow = IIM_Load_Absolute_DisplayFormatAlpha ("data/base.000/gfx/uparrow.png"); IIM_Surface *downArrow = IIM_Load_Absolute_DisplayFormatAlpha ("data/base.000/gfx/downarrow.png"); bidonBox.setPolicy(USE_MIN_SIZE); ListView list(10, upArrow, downArrow, &fpict); IIM_Surface *onSwitchImage = IIM_Load_Absolute_DisplayFormatAlpha ("data/base.000/gfx/switch-on.png"); IIM_Surface *offSwitchImage = IIM_Load_Absolute_DisplayFormatAlpha ("data/base.000/gfx/switch-off.png"); SwitchedButton prefSwitchA(String("Mon switch tout neuf A"), true, onSwitchImage, offSwitchImage, String("test.widget.switchbuttonAB")); SwitchedButton prefSwitchB(String("Mon switch tout neuf B sur la même pref que A"), true, onSwitchImage, offSwitchImage, String("test.widget.switchbuttonAB")); SwitchedButton prefSwitchC(String("Mon switch tout neuf C sur une autre pref"), false, onSwitchImage, offSwitchImage, String("test.widget.switchbuttonC")); bidonBox.add(&prefSwitchA); bidonBox.add(&prefSwitchB); bidonBox.add(&prefSwitchC); bidonBox.add(&bidonText); //bidonBox.add(&framedButton1); //bidonBox.add(&bidonButton1); bidonBox.add(&bidonButton2); //bidonBox.add(&frame2); bidonBox.add(&bidonField); bidonBox.add(&frame); for (int i = 0 ; i < 100 ; i++) { String newEntry("Bla bla "); list.addEntry(new ListViewEntry(newEntry + i, &actionBidon)); } frame.add(&list); //bidonBox.add(&list); bidonBox.add(&bidonButton3); //list.add(&bidonButton1); //list.add(&bidonButton2); BusyWidget busy; scr.add(&busy); scr.add(&bidonBox); GameUIDefaults::SCREEN_STACK->push(&scr); GameUIDefaults::GAME_LOOP->run(); return 0; }