int main(int argc, char *argv[]) { struct Window window; window.width = 1024; window.height = 768; window.flags = SDL_WINDOW_OPENGL; Window_CreateOpenGLContext(&window, "OpenGL"); Window_SetOpenGLFlags(); Game_Init(); GLfloat const dt = 0.01f; GLfloat t = 0.0f; GLfloat accumulator = 0.0f; GLfloat previous_time = 0.0f; while (Game_HandleInput()) { GLfloat new_time = SDL_GetTicks() / 1000.0f; GLfloat delta_time = new_time - previous_time; if (delta_time <= 0.0f) continue; previous_time = new_time; accumulator += delta_time; while (accumulator >= dt) { Game_FixedUpdate(t, dt); accumulator -= dt; t += dt; } Game_Update(); Game_LateUpdate(); Window_ClearBuffers(); { Game_Render(); } Window_SwapBuffers(&window); } Game_Destroy(); Window_Destroy(&window); return 0; }
int main(int argc, char **argv) { unsigned int time_start, time_end; Game_Init(); FPSCount_Init(); while(game_running) { time_start = SDL_GetTicks(); Game_Update(); Game_Draw(); SDL_GL_SwapBuffers(); time_end = SDL_GetTicks(); FPSCount_Tick(); if(1000/FPS > time_end - time_start) SDL_Delay(1000/FPS - (time_end - time_start)); } Game_Quit(); return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { SetWindowIconID(IDI_ICON1); SetMainWindowText(titlebar),ChangeWindowMode(TRUE), SetGraphMode(WIDTH, HEIGHT, 32), DxLib_Init(),SetDrawScreen(DX_SCREEN_BACK); //ウィンドウモード、960*720のサイズ //画像の読み込み GraphicHandle[0] = LoadGraph("image/Title.png"); GraphicHandle[1] = LoadGraph("image/Player.png"); GraphicHandle[2] = LoadGraph("image/Comet.png"); GraphicHandle[3] = LoadGraph("image/Backscreen.png"); GraphicHandle[4] = LoadGraph("image/Clearscreen.png"); GraphicHandle[5] = LoadGraph("image/Sf_title.png"); GraphicHandle[6] = LoadGraph("image/Buttun_on.png"); GraphicHandle[7] = LoadGraph("image/Buttun_off.png"); GraphicHandle[8] = LoadGraph("image/Ready.png"); GraphicHandle[9] = LoadGraph("image/Start.png"); GraphicHandle[10] = MakeScreen(1024, 1024, false); GraphicHandle[11] = LoadGraph("image/Ranking.png"); GraphicHandle[12] = LoadGraph("image/Pause.png"); //音楽の読み込み SoundHandle[0] = LoadSoundMem("music/bgm.mp3"); SoundHandle[1] = LoadSoundMem("music/select.mp3"); SoundHandle[2] = LoadSoundMem("music/deside.mp3"); SoundHandle[3] = LoadSoundMem("music/miss.mp3"); SoundHandle[4] = LoadSoundMem("music/gameover.mp3"); GScoreFont = CreateFontToHandle("Meiryo UI Bold", 20, -1); RScoreFont = CreateFontToHandle("Meiryo UI Bold", 32, -1); CScoreFont = CreateFontToHandle("Meiryo UI Bold", 64, -1); ChangeFont("Meiryo UI Bold"); //フォントの変更 Title_Initialize(); //タイトルの初期化処理 Game_Initialize(); //ゲームの初期化処理 Clear_Initialize(); //クリア画面の初期化処理 Rank_Initialize(); //ランキング画面の初期化処理 Logo_Initialize(); while (Loop() == true) { Keyboard_Update(); GamePad_Update(); switch (NowScene()) { //現在のシーンによって動作を変える case logo: Logo_Update(); break; case title: Title_Update(); Title_Draw(); break; case gamepre: Game_Initialize(); ChangeScene(game); case game: Game_Update(); Game_Draw(); break; case clear: Clear_Update(); Clear_Draw(); break; } } Title_Finalize(); //タイトルの終了処理 Game_Finalize(); //ゲームの終了処理 Clear_Finalize(); //クリア画面の終了処理 Rank_Finalize(); //ランキング画面の終了処理 Logo_Finalize(); //ロゴ画面の終了処理 DxLib_End(); // DXライブラリ使用の終了処理 return 0; }