int main(int argc,char *argv[]) { /* ウインドウの初期化 */ if(InitWindow() == -1) { fprintf(stderr,"setup failed : InitWindows\n"); return -1; } InitSystem(); while(gState != GAME_END) { switch(gState) { case GAME_TITLE: GameTitle(); break; case GAME_EDIT: GameEdit(); break; case GAME_MAIN: GameMain(); break; default: break; } } DestroyWindow(); return 0; }
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { return GameMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow); }
// -------------------------------------------------------------------- // メイン関数定義 // -------------------------------------------------------------------- int WINAPI WinMain( HINSTANCE hInstance, // 現在のインスタンスのハンドル HINSTANCE hPrevInstance, // 以前のインスタンスのハンドル LPSTR lpCmdLine, // コマンドライン int nCmdShow // 表示状態 ) { // DXLIBの初期化処理 DxLib_Init(); // ゲーム初期化 InitGame(); // ゲームループ // 以下の処理をエスケープキーが押されるまでかプレイヤーが生きている間繰り返す while( ProcessMessage() == 0 && CheckHitKey( KEY_INPUT_ESCAPE ) == 0 && Player.state == STATE_LIVE) { GameMain(); } // DXLIBの終了処理 DxLib_End(); // アプリケーションの終了 return 0; }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ){ ChangeWindowMode(TRUE); gFPS.SetDefaultFPS(60); if( DxLib_Init() == -1 ){ return -1; // エラーが起きたら直ちに終了 } ChangeFontType(DX_FONTTYPE_ANTIALIASING_EDGE); SetMouseDispFlag(TRUE); gameManager.SetStage(gameManager.Load); for(;;){ //メインループ ClearDrawScreen(); if(ProcessMessage()==-1 || GameMain()==1){break;} //ゲーム本体を実行 //FPS描画 int NowFPS = gFPS.Get(); int Col = (int)(255 * NowFPS / gFPS.GetDefaultFPS()); //DrawFormatString(500,450,GetColor(255,Col,Col),"FPS: %d",NowFPS); ScreenFlip(); if((GetJoypadInputState( DX_INPUT_KEY_PAD1 ) & PAD_INPUT_10) !=0){ GetDateTime( &Date ); std::stringstream fname; fname <<"img" << Date.Year << Date.Mon << Date.Day <<Date.Hour <<Date.Min <<GetNowCount() << ".png"; SaveDrawScreenToPNG( 0 , 0 , 480 , 480 ,fname.str().c_str()) ; } gFPS.Fix(); } DxLib_End() ; // DXライブラリ使用の終了処理 return 0 ; // ソフトの終了 }
int main(int argc, char *argv[]) { // initialize SDL if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO) < 0) { fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError()); return 255; } atexit(SDL_Quit); SDL_SetHint(SDL_HINT_ORIENTATIONS, "Portrait"); // initialize video if (!VideoInit()) { fprintf(stderr, "VideoInit() failed: %s\n", SDL_GetError()); return 255; } atexit(VideoDestroy); // initialize audio if (SOUND_OpenAudio(44100, 2, 1024) < 0) { fprintf(stderr, "InitSound() failed: %s\n", SDL_GetError()); return 255; } return GameMain(); }
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow) { MFInitParams initParams; initParams.hInstance = hInstance; initParams.pCommandLine = lpCmdLine; return GameMain(&initParams); }
int main(int argc, const char *argv[]) { MFInitParams initParams; initParams.argc = argc; initParams.argv = argv; return GameMain(&initParams); }
int main(int argc, const char *argv[]) { MFInitParams initParams; MFZeroMemory(&initParams, sizeof(MFInitParams)); initParams.argc = argc; initParams.argv = argv; return GameMain(&initParams); }
int main() { //s3eInetAddress addr; //memset(&addr, 0, sizeof(addr)); //s3eInetLookup("localhost", &addr, NULL, NULL); //addr.m_Port = s3eInetHtons(81); //s3eSocket* pSock = s3eSocketCreate(S3E_SOCKET_UDP, 0); //char szData[20000]; //for (int i=0; i <20000;++i) //{ // szData[i] = i; //} //while (true) //{ // int sent = s3eSocketSendTo(pSock, szData, 20000, 0, &addr); // s3eDeviceYield(0); //} s3eLocationStart(); //IwGx can be initialised in a number of different configurations to help the linker eliminate unused code. //For the examples we link in all of IwGx's possible functionality. //You can see the code size reduce if you remove any of the IwGxInit calls following IwGxInit_Base. //Note that, for demonstration purposes, some examples call IwGxInit() themselves - this will link in the //standard renderer and the GL renderer, so on those examples these features cannot be excluded from the build. //IwGxInit_Base(); //IwGxInit_GLRender(); IwGxInit(); Iw2DInit(); IwUIInit(); //Instantiate the view and controller singletons. //IwUI will not instantiate these itself, since they can be subclassed to add functionality. new CIwUIView; CIwUIController2* pController = new CIwUIController2; IwDebugTraceLinePrintf("Creating Game Object"); FireflyGameEngine* pGameEngine = new FireflyGameEngine; IwDebugTraceLinePrintf("Entering Main"); int result = GameMain(pGameEngine); delete pGameEngine; Iw2DTerminate(); delete IwGetUIView(); delete pController; IwUITerminate(); IwGxTerminate(); s3eLocationStop(); return result; }
//********************************************************* // ゲームの更新を行う //********************************************************* int GameUpdate(void) { // [ESC]キーで終了 if (CheckHitKey(KEY_INPUT_ESCAPE) == 1) return 0; //ゲームメインの読み込み GameMain(); // 正常に処理を行っている return 1; }
int main(void) { _BeginWindow(); GameMain(); _EndWindow(); return 0; }
int main(int argc, const char *argv[]) { MFInitParams initParams; initParams.argc = argc; initParams.argv = argv; int r = GameMain(&initParams); sceKernelExitGame(); return r; }
int main(int argc, const char *argv[]) { MFInitParams initParams; MFZeroMemory(&initParams, sizeof(MFInitParams)); initParams.argc = argc; initParams.argv = argv; int r = GameMain(&initParams); sceKernelExitGame(); return r; }
INT WINAPI wWinMain( HINSTANCE hInst, HINSTANCE, LPWSTR, INT ) { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); //_crtBreakAlloc = 446; WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"VG Test", NULL }; RegisterClassEx( &wc ); HWND hWnd = CreateWindow( L"VG Test", L"VG Test", WS_OVERLAPPEDWINDOW, 100, 100, 256, 256, NULL, NULL, wc.hInstance, NULL ); ////////////////////////////////////////////////////////////////////////// RECT wndRect; RECT clientRect; GetWindowRect((HWND)hWnd, &wndRect); GetClientRect((HWND)hWnd, &clientRect); int iWinWidth = iWidth + (wndRect.right - wndRect.left) - (clientRect.right - clientRect.left); int iWinHeight = iHeight + (wndRect.bottom - wndRect.top) - (clientRect.bottom - clientRect.top); MoveWindow((HWND)hWnd, wndRect.left, wndRect.top, iWinWidth, iWinHeight, TRUE); ////////////////////////////////////////////////////////////////////////// if(FAILED(Init(hWnd))) return 1; ShowWindow( hWnd, SW_SHOWDEFAULT ); UpdateWindow( hWnd ); MSG msg; ZeroMemory( &msg, sizeof(msg) ); while( msg.message != WM_QUIT ) { if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else GameMain(); } UnregisterClass( L"VG Test", wc.hInstance ); return 0; }
/************************************************************************* WinMain() Windows entry point *************************************************************************/ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { SetupWindow(); MSG msg; int exitCode; CTimer timer; timer.Init(); while (true) { if(PeekMessage(&msg, g_hwnd, NULL, NULL, PM_REMOVE)) { if (msg.message == WM_QUIT) // do we receive a WM_QUIT message? { exitCode = msg.wParam; break; // if so, time to quit the application } else { TranslateMessage(&msg); // translate and dispatch to event queue DispatchMessage(&msg); } } // don't update the scene if the app is minimized if (g_isActive) { // update the scene every time through the loop GameMain(timer.GetElapsedSeconds()); DisplayFPS(&timer); // switch the front and back buffers to display the updated scene SwapBuffers(g_hdc); } else { timer.GetElapsedSeconds(); } } KillWindow(); return exitCode; }
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int nCmdShow) { const wchar_t CLASS_NAME[] = L"breakout"; WNDCLASSEX wc = {}; wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1)); wc.hIconSm = (HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 16, 16, 0); wc.hInstance = hInstance; wc.lpfnWndProc = WndProc; wc.lpszClassName = CLASS_NAME; wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbSize = sizeof(wc); RegisterClassEx(&wc); HWND hwnd = CreateWindow(CLASS_NAME, L"My Breakout", WS_OVERLAPPEDWINDOW &~WS_THICKFRAME &~WS_MAXIMIZEBOX, 50, 10, 800, 600, NULL, NULL, hInstance, NULL); if (!hwnd) return 0; ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); MSG msg; bool running = true; while (running) { DWORD start_tick = GetTickCount(); if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) running = false; else { TranslateMessage(&msg); DispatchMessage(&msg); } } GameMain(hwnd, hInstance); BitBlt(mainDC, 0, 0, 800, 600, backDC, 0, 0, SRCCOPY); while (GetTickCount() - start_tick < GAME_SPEED); } return msg.wParam; }
//============================================================================================== // Windows メイン処理 //============================================================================================== INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // ウィンドウクラスの登録 WNDCLASS wc; ZeroMemory(&wc, sizeof(WNDCLASS)); wc.style = CS_HREDRAW | CS_VREDRAW; // ウィンドウスタイル wc.lpfnWndProc = (WNDPROC)WndProc; // ウィンドウプロシージャ wc.cbClsExtra = 0; // 補助領域サイズ wc.cbWndExtra = 0; // 補助領域サイズ wc.hInstance = hInstance; // インスタンスハンドル wc.hIcon = LoadIcon(hInstance, TEXT("IDI_ICON")); // アイコン wc.hCursor = LoadCursor(NULL, IDC_ARROW); // マウスカーソル wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // クライアント領域背景色 wc.lpszMenuName = NULL; // ウィンドウメニュー wc.lpszClassName = TEXT("Windows"); // ウィンドウクラス名 if (!RegisterClass(&wc)) return 0; // ウィンドウの作成 hWnd = CreateWindow( wc.lpszClassName, // ウィンドウクラス名 TEXT("タイトル"), // ウィンドウタイトル WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX, // ウィンドウスタイル CW_USEDEFAULT, // 表示X座標 CW_USEDEFAULT, // 表示Y座標 pWid + GetSystemMetrics(SM_CXDLGFRAME) * 2, // 幅 pHei + GetSystemMetrics(SM_CYDLGFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION), // 高さ NULL, // 親ウィンドウ NULL, // ウィンドウメニュー hInstance, // インスタンスハンドル NULL); // WM_CREATE情報 // ウィンドウの表示 ShowWindow(hWnd, nCmdShow); // 表示状態の設定 UpdateWindow(hWnd); // クライアント領域の更新 hInst = hInstance; hDC_Wnd = GetDC(hWnd); // ゲームメイン処理へ~ GameMain(); ReleaseDC(hWnd, hDC_Wnd); return 0; // とりあえず0を返す }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ){ read_xml(CONFIG_FILE_NAME, gConfig); ChangeWindowMode(gConfig.get("WindowMode",true)); SetMainWindowText( PJTITLE ); if( DxLib_Init() == -1 ){ return -1; // エラーが起きたら直ちに終了 } LPCSTR font_path = "img\\font.ttf"; // 読み込むフォントファイルのパス AddFontResourceEx(font_path, FR_PRIVATE, NULL); ChangeFont("Neuropol",DX_CHARSET_DEFAULT); ChangeFontType( DX_FONTTYPE_ANTIALIASING_EDGE ); shotButton = gConfig.get("Pad.Shot",PAD_INPUT_1); subButton = gConfig.get("Pad.Sub",PAD_INPUT_2); SetJoypadInputToKeyInput(DX_INPUT_PAD1, shotButton, gConfig.get("Key.Shot", KEY_INPUT_Z), -1, -1, -1 ) ; SetJoypadInputToKeyInput(DX_INPUT_PAD1, subButton, gConfig.get("Key.Sub", KEY_INPUT_X), -1, -1, -1 ) ; gGameManager.Set(&GameManager::Init); for(;;){ //メインループ //SetDrawScreen(DX_SCREEN_BACK); SetDrawScreen(gDrawScr); ClearDrawScreen(); if(ProcessMessage()==-1 || GameMain()==1){break;} //ゲーム本体を実行 SetDrawScreen( DX_SCREEN_BACK ) ; //裏スクリーンに描画対象を移す SetDrawBlendMode(DX_BLENDMODE_ALPHA,255); DrawGraph(0,0,gDrawScr,FALSE); //実際に描画 SetDrawBlendMode(DX_BLENDMODE_NOBLEND,0); //FPS描画 { int NowFPS = gFPS.Get(); int Col = (int)(255 * NowFPS / gFPS.GetDefaultFPS()); DrawFormatString(SCR_WIDTH-80,SCR_HEIGHT-20,GetColor(255,Col,Col),"%02dFPS",NowFPS); } ScreenFlip(); CaptureScreen(); gFPS.Fix(); } DxLib_End() ; // DXライブラリ使用の終了処理 write_xml(CONFIG_FILE_NAME,gConfig); return 0 ; // ソフトの終了 }
//--------------------------------------------------------------------------- //########################################################################### int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow) { WNDCLASSEX winclass ; HWND hwnd ; MSG msg ; winclass.cbSize=sizeof(WNDCLASSEX); winclass.style =CS_DBLCLKS|CS_OWNDC|CS_HREDRAW|CS_VREDRAW; winclass.lpfnWndProc = WindowProc; winclass.cbClsExtra=0; winclass.cbWndExtra=0; winclass.hIcon=LoadIcon(NULL,IDI_APPLICATION); winclass.hCursor=LoadCursor(NULL,IDC_ARROW); winclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH); winclass.lpszMenuName=NULL; winclass.lpszClassName=WINDOW_CLASS_NAME; winclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION); if(!RegisterClassEx(&winclass)) return(0); hwnd=CreateWindowEx(NULL,WINDOW_CLASS_NAME, "THE HIVE", WS_POPUP|WS_VISIBLE, 0,0, //- position screen_HEIGHT,screen_WIDTH, //- size NULL,NULL,hinstance,NULL); if(!hwnd)return(0); main_handle = hwnd ; main_hinstance = hinstance ; GameInit(); // INITIALIZING while(true) { if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if(msg.message==WM_QUIT)break; TranslateMessage(&msg); DispatchMessage(&msg); } ; GameMain(); // MAIN GAME FUNCTION } ; GameExit(); // RELEASE return(msg.wParam); };
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX window_class = {}; window_class.cbSize = sizeof(WNDCLASSEX); window_class.style = CS_OWNDC; window_class.lpszClassName = "EnGenWindowClass"; window_class.lpfnWndProc = (WNDPROC) MessageLoop; window_class.hCursor = LoadCursor(0, IDC_ARROW); window_class.hbrBackground = (HBRUSH)(COLOR_BACKGROUND); if (!RegisterClassEx(&window_class)) { return 1; } DWORD screen_res_x = GetSystemMetrics(SM_CXSCREEN); DWORD screen_res_y = GetSystemMetrics(SM_CYSCREEN); DWORD window_res_x = (DWORD) (screen_res_x * 0.9f); DWORD window_res_y = (DWORD) (screen_res_y * 0.9f); DWORD window_x = (screen_res_x - window_res_x) / 2; DWORD window_y = (screen_res_y - window_res_y) / 2; s_hWnd = CreateWindowEx( NULL, // dwExStyle, window_class.lpszClassName, // lpClassName, "Hello Windows!", // lpWindowName, WS_OVERLAPPEDWINDOW | WS_VISIBLE, // dwStyle, window_x, // x, window_y, // y, window_res_x, // nWidth, window_res_y, // nHeight, NULL, // hWndParent, NULL, // hMenu, hInstance, // hInstance, NULL); // lpParam); int game_result = GameMain(); return game_result; }
INT WINAPI wWinMain( HINSTANCE hInst, HINSTANCE, LPWSTR, INT ) { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"VG Test", NULL }; RegisterClassEx( &wc ); HWND hWnd = CreateWindow( L"VG Test", L"VG Test", WS_OVERLAPPEDWINDOW, 100, 100, 256, 256, NULL, NULL, wc.hInstance, NULL ); if(FAILED(InitD3D(hWnd))) return 1; SetCamera(); ShowWindow( hWnd, SW_SHOWDEFAULT ); UpdateWindow( hWnd ); if(FAILED(InitGeometry())) return 1; MSG msg; ZeroMemory( &msg, sizeof(msg) ); while( msg.message != WM_QUIT ) { if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else GameMain(); } UnregisterClass( L"VG Test", wc.hInstance ); return 0; }
/* * WinMain: * Contains the message loop. */ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { MSG msg; srand(time(NULL)); // initialize the app if (!InitApp(hInst, nCmdShow)) { return FALSE; } strcpy(level_file, lpCmdLine); // infinite loop while (1) { // peekmessage so as not to interrupt processes if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // if the message said to quit, get the hell outta here if (msg.message == WM_QUIT) { break; } // translate and dispatch the message TranslateMessage(&msg); DispatchMessage(&msg); } // if there are no messages, update the game if (g_Active) { GameMain(); } } // shutdown game and release all resources FiniApp(); // return to Windows like this return(msg.wParam); }
void Display(void) { //各バッファーをクリア glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); //行列の初期化 glMatrixMode(GL_MODELVIEW); glLoadIdentity(); GameMain(); glutSwapBuffers(); switch (g_Change) { case ESceneChange::None: break; case ESceneChange::Main: delete g_Scene; g_Scene = new CMainGame(); break; case ESceneChange::Title: delete g_Scene; g_Scene = new CTitle(); break; case ESceneChange::Tutorial: delete g_Scene; g_Scene = new (CTutorial); break; case ESceneChange::Result: delete g_Scene; g_Scene = new (CResult); break; } }
int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode) { HWND hwnd; MSG msg; WNDCLASS wcl; HDC hdc; char buffer[] = "hello"; wcl.hInstance = hThisInst; wcl.lpszClassName = WINDOW_CLASS_NAME; wcl.lpfnWndProc = WindowFunc; wcl.style = CS_HREDRAW | CS_VREDRAW; wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); //wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO); wcl.hCursor = LoadCursor(NULL, IDC_ARROW); wcl.lpszMenuName = WINDOW_CLASS_NAME; wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; wcl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); if(!RegisterClass(&wcl)) return 0; if(!(hwnd = CreateWindowEx ( WS_EX_TOPMOST, WINDOW_CLASS_NAME, "My First Proper Thing 2", WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hThisInst, NULL ))) return 0; ShowWindow(hwnd, nWinMode); UpdateWindow(hwnd); SetFocus(hwnd); ShowCursor(0); main_window_handle = hwnd; LoadBitmap(&colour_bmp_file,"texture2.bmp"); LoadBitmap(&height_bmp_file,"heightd2.bmp"); if (!DD_Init(hwnd)) { DestroyWindow(hwnd); return 0; } ofstream fout("myfile.dem"); int i,j,n,index = 0; for ( i = 0; i < 512; i++) { for ( j = 0; j < 512; j++) { // heights[i][j] = height_bmp_file.buffer[index++] * 8; // fout << heights[i][j] << " "; heights[i][j] = 0; } fout << "\n"; } index = 0; for ( i = 0; i < 1024; i++) { for ( j = 0; j < 1024; j++) { if ((colours[i][j] = colour_bmp_file.buffer[index++])>250) colours[i][j] = 250; } fout << "\n"; } LoadDEM(); fout.close(); LoadDEM(); while (1) { if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { if(msg.message == WM_QUIT) { DD_Shutdown(); break; } TranslateMessage(&msg); DispatchMessage(&msg); } else { memset(&ddsd,0,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); while ( lpddsback->Lock(NULL,&ddsd,DDLOCK_SURFACEMEMORYPTR,NULL) != DD_OK); video_buffer = (UCHAR *) ddsd.lpSurface; memset(video_buffer,0,SCREEN_WIDTH*SCREEN_HEIGHT); GameMain(); lpddsback->Unlock(NULL); sprintf(buffer,"%d",poo); if (lpddsback->GetDC(&hdc) == DD_OK) { SetBkColor(hdc, RGB(0, 0, 255)); SetTextColor(hdc, RGB(255, 255, 0)); TextOut(hdc, 0, 0, buffer, lstrlen(buffer)); lpddsback->ReleaseDC(hdc); } //Z+=10; if (Z>3840.0) Z -=3840.0; while (TRUE) { ddrval = lpddsprimary->Flip(NULL, 0); if (ddrval == DD_OK) break; if (ddrval == DDERR_SURFACELOST) { ddrval = lpddsprimary->Restore(); if (ddrval != DD_OK) break; } if (ddrval != DDERR_WASSTILLDRAWING) break; } if (KEY_DOWN(VK_ESCAPE)) { DD_Shutdown(); PostMessage(main_window_handle,WM_CLOSE,0,0); } } } DD_Shutdown(); return(msg.wParam); }
//=============================================== //シーンの描画 //=============================================== void CSceneManager::DrawScene(eSceneType type) { m_CurrentScene = type; switch(m_CurrentScene) { /*初期化画面*/ case SCENE_INIT: { Initialize(); break; } /*AI待ち画面*/ case SCENE_WAIT: { obj[SCENE_WAIT].DoAllTasks(); WaitAI(); break; } case SCENE_CHOOSESPECIAL: { obj[SCENE_CHOOSESPECIAL].DoAllTasks(); ChooseSpecial(); break; } case SCENE_CHOOSECHARA: { obj[SCENE_CHOOSECHARA].DoAllTasks(); ChooseChara(); break; } /*メイン画面*/ case SCENE_MAIN: { obj[SCENE_MAIN].DoAllTasks(); GameMain(); break; } /*戦闘画面*/ case SCENE_BATTLE: { obj[SCENE_BATTLE].DoAllTasks(); Battle(); break; } /*戦闘終了画面*/ case SCENE_BATTLEEND: { BattleEnd(); break; } /*終了処理画面*/ case SCENE_FINAL: { Finalize(); break; } } }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); MSG msg; HACCEL hAccelTable; // グローバル文字列を初期化しています。 LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_TETRIS, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // アプリケーションの初期化を実行します: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_TETRIS)); // メイン メッセージ ループ: ::timeBeginPeriod(1); double host_timescale = 1; double view_max_fps = VIEW_SPEED_FPS; // 描画のFPS制限 // 上のがいわゆるnet_graphのFPSだと思う double game_max_fps = GAME_SPEED_FPS * host_timescale; // ゲームスピードのFPS制限 // こっちが一般的にはtick?? DWORD dwTime = ::timeGetTime(); DWORD fps_after = dwTime; DWORD fps_before = fps_after; DWORD frame = 0; DWORD currentTime = dwTime; double gameSpeedWaitTime = (1.0 / game_max_fps * 1000.0); double gameSpeedNextTime = dwTime + gameSpeedWaitTime; double viewSpeedWaitTime = (1.0 / view_max_fps * 1000.0); double viewSpeedNextTime = dwTime + gameSpeedWaitTime; Game_init(); while(true){ if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)){ if(!GetMessage(&msg, NULL, 0, 0)) return msg.wParam; TranslateMessage(&msg); DispatchMessage(&msg); }else{ // FPS測定(1000ms秒あたりのframe数を計測) currentTime = ::timeGetTime(); if(currentTime - fps_before >= 1000){ // 前回から1秒間(1000ms)経過していた場合 fps_before = currentTime; g_frameRate = g_frame; g_frame = 0; // フレーム数を次秒の計測のためにリセット } // FPS制限(1/60おきにコードが実行されるようにする) if(currentTime >= gameSpeedNextTime ){ // 次回の予定実行時を過ぎていた場合 gameSpeedNextTime += gameSpeedWaitTime; // メイン処理 if( GameMain(msg.hwnd) == false ){ break; // 終了処理へ } }else{ // 表示上のFPS描画しなければならないかチェックする if(currentTime >= viewSpeedNextTime ){ viewSpeedNextTime += viewSpeedWaitTime; onPaint(g_hWnd, g_mDC); ::InvalidateRect(g_hWnd, NULL, FALSE); g_frame++; }else{ Sleep(1); } } } } // いろいろ後片付けを書く trace(L"終了処理\n"); GameMain_quit(); ::timeEndPeriod(1); return (int) msg.wParam; }
int main() { env; //フォント Font font("res/font/keifont.ttf"); font.size(80); //起動時に一回だけ表示 bool start_flag = false; //シーン切り替え int scene = TITLE; /////////////////////////////////////////////////////////////// //マルチ /////////////////////////////////////////////////////////////// //ランキング int ranking[6] = { 2000, 1800, 1500, 1000, 500, 0}; char name[3] = { 'U', 'M', 'R' }; //スコア int score = 0; int hiscore = 2000; //所持金額 int bone = 100; ////////////////////////////////////////////////////////////// //ソロ ////////////////////////////////////////////////////////////// //スコア int s_score = 0; int s_hiscore = 0; //所持金額 int s_bone = 100; //アイテム int nbone = 0; ///////////////////////////////////////////////////////////// //メイン ///////////////////////////////////////////////////////////// while (env.isOpen()) { env.begin(); switch (scene) { case TITLE: Title(scene, font, start_flag); break; case TUTORIAL: Tutorial(scene, font); break; case OPERATION: Operation(scene, font); break; case OPTION: Option(scene, font); break; case SOLO_MENU: SoloMenu(scene, s_bone, font, nbone); case MULTI_MENU: Menu(scene, font, ranking, name); break; case SOLO_GAMEMAIN: S_GameMain(scene, s_bone, font, s_score, s_hiscore, nbone); break; case MULTI_GAMEMAIN: GameMain(font, scene, score, hiscore, bone, ranking, name); break; case S_RESTART: S_Restart(scene); break; case RESTART: Restart(scene); break; } env.end(); } }
Sint32 CGameGunHound::AdvertiseDemo() { //--------------------------------------------- //デモ //--------------------------------------------- if( m_pOpeningDemo == NULL ) { m_pOpeningDemo = new COpeningDemo(); } m_pOpeningDemo->Action(); Sint32 opCode = m_pOpeningDemo->GetOperation(); if( m_pOpeningDemo->IsEnd() ) { delete m_pOpeningDemo; m_pOpeningDemo = NULL; opCode = COpeningDemo::enOperationEnd; } else { m_pOpeningDemo->Draw(); } switch( opCode ){ case COpeningDemo::enOperationInit: //ゲームを初期化 g_StGameInfo.PlayStage = GetDemoStage(); pGame = new CGameManager(); GameInit(); g_StGameInfo.m_bMusic = gxFalse; g_StGameInfo.m_bMessage = gxFalse; g_StGameInfo.m_bReplay = gxTrue; pGame->init(); m_sDemoCount ++; break; case COpeningDemo::enOperationMain: //ゲームを更新 GameMain(); if( CCockpit::GetInstance()->IsGameOver() ) { m_pOpeningDemo->SetStatusGameOver(); } break; case COpeningDemo::enOperationEnd: GameEnd(); if( pGame ) { delete pGame; pGame = NULL; } CCockpit::GetInstance()->ReNew(); return -1; default: break; } return 0; }
void CGameGunHound::Loop() { //----------------------------------------- //ハウンドメイン //----------------------------------------- if( m_bResetOK ) { if( m_bResetPlease ) { m_bResetPlease = gxFalse; m_sEndSeq = -1; ChangeGameSeq( enMainSeqGameEnd ); } else if( CDashBoard::GetInstance()->IsMenuBar() ) { m_bPauseFlag = gxTrue; } else { m_bPauseFlag = gxFalse; } } switch( m_GameSeq ){ case enMainSeqInit: //----------------------------------------- //ゲーム初期化 //----------------------------------------- m_bBriefingRoot = gxTrue; m_bResetOK = gxFalse; viiDbg::log("ハウンドシーケンス:enMainSeqInit"); //SaveDataInit(); //GameConfigLoad(); m_bPauseFlag = gxFalse; ChangeGameSeq( enMainSeqStart ); break; case enMainSeqStart: //----------------------------------------- //スコア初期化 //----------------------------------------- m_bResetOK = gxFalse; viiDbg::log("ハウンドシーケンス:enMainSeqStart"); #ifdef _VII_DEBUG_ CDashBoard::GetInstance()->SetMenuDisable(gxFalse); CDashBoard::GetInstance()->SetLogo(gxFalse); CDashBoard::GetInstance()->SetWallPaper(gxFalse); ChangeGameSeq( enMainSeqRestart ); #else // ChangeGameSeq( enMainSeqGameOpeningDemo ); CDashBoard::GetInstance()->SetMenuDisable(gxFalse); CDashBoard::GetInstance()->SetLogo(gxFalse); CDashBoard::GetInstance()->SetWallPaper(gxFalse); ChangeGameSeq( enMainSeqGameTitle ); #endif break; case enMainSeqGameTitle: //----------------------------------------- //タイトルのシーケンス //----------------------------------------- UploadTexture(); m_bResetOK = gxFalse; ChangeGameSeq( enMainSeqRestart ); break; case enMainSeqRestart: //----------------------------------------- //リスタートのポイント //----------------------------------------- m_bResetOK = gxFalse; ResetClass(); #ifdef GX_DEBUG ChangeGameSeq( enMainSeqDebugMenu ); #else ChangeGameSeq( enMainSeqGameMainMenu ); #endif break; case enMainSeqGameMainMenu: //----------------------------------------- //メインメニューのシーケンス //----------------------------------------- m_bResetOK = gxTrue; CDashBoard::GetInstance()->SetMenuDisable(gxTrue); switch( MainMenu() ){ case enMenuSeqBack: case enMenuSeqNext: g_StGameInfo.Reset(); if( m_sMainMenuSelected == CMainMenu::enMainMenuOpening ) { //オープニングへ ChangeGameSeq( enMainSeqGameOpeningDemo ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuDebug ) { //デバッグモードへ g_StGameInfo.m_sGameMode = StGameInfo::enGameModeNormal; ChangeGameSeq( enMainSeqDebugMenu ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuEnding ) { //エンディング CDashBoard::GetInstance()->SetIcon( enIconNone ); ChangeGameSeq( enMainSeqGameEndingDemo ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuStart ) { //ゲームスタートへ CDashBoard::GetInstance()->SetIcon( enIconNone ); g_StGameInfo.m_sGameMode = StGameInfo::enGameModeNormal; g_StGameInfo.m_bMessage = gxTrue; ChangeGameSeq( enMainSeqGameBriefing ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuTutorial ) { //チュートリアルスタートへ g_StGameInfo.m_bMusic = gxTrue; g_StGameInfo.m_bMessage = gxTrue; g_StGameInfo.m_bReplay = gxFalse; CDashBoard::GetInstance()->SetIcon( enIconNone ); g_StGameInfo.m_sGameMode = StGameInfo::enGameModeNormal; g_StGameInfo.PlayStage = enScenarioTutorial; StageSet(); g_StGameInfo.PlayArea = m_sSelectedStage; ChangeGameSeq( enMainSeqGameInit ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuMission ) { //ゲームスタートへ CDashBoard::GetInstance()->SetIcon( enIconNone ); g_StGameInfo.m_sGameMode = StGameInfo::enGameModeMission; g_StGameInfo.PlayStage = m_sSelectedStage;//enScenarioTutorial; g_StGameInfo.PlayArea = 0; StageSet(); ChangeGameSeq( enMainSeqGameInit ); } else if( m_sMainMenuSelected == CMainMenu::enMainMenuExit ) { //ゲーム終了 ExitGame(); } break; default: break; } break; case enMainSeqGameOpeningDemo: //----------------------------------------- //オープニングのシーケンス //----------------------------------------- m_bResetOK = gxFalse; if( AdvertiseDemo() ) { ChangeGameSeq( enMainSeqGameTitle ); } break; case enMainSeqDebugMenu: //----------------------------------------- //デバッグメニュー //----------------------------------------- m_bResetOK = gxTrue; switch( DebugMenu() ) { case enMenuSeqBack: ChangeGameSeq( enMainSeqGameMainMenu ); break; case enMenuSeqNext: // g_StGameInfo.Reset(); g_StGameInfo.m_bMessage = gxTrue; g_StGameInfo.m_bMusic = gxTrue; g_StGameInfo.m_bReplay = gxFalse; ChangeGameSeq( enMainSeqGameInit ); break; } break; case enMainSeqGameBriefing: g_StGameInfo.ContinueArea = 0; CCockpit::GetInstance()->SetHidden(); CDashBoard::GetInstance()->SetMenuDisable(gxFalse); m_bResetOK = gxTrue; if( m_pSetUp == NULL ) { //セットアップ画面を作る m_pSetUp = new CSetUp( -1 );//g_StGameInfo.PlayStage ); } if( BriefingMain() ) { //ステージ決定 StageSet(); m_bBriefingRoot = gxTrue; ChangeGameSeq( enMainSeqGameSetUp ); } CockpitControl(); break; case enMainSeqGameSetUp: CCockpit::GetInstance()->SetHidden(); m_bResetOK = gxTrue; if( m_pSetUp->IsEnd() ) { ChangeGameSeq( enMainSeqGameBefore ); } CockpitControl(); break; case enMainSeqGameBefore: //----------------------------------------- //ゲーム初期化 //----------------------------------------- CCockpit::GetInstance()->ReNew(); CCockpit::GetInstance()->SetHidden(); CockpitControl(); m_bResetOK = gxTrue; if( !m_pSetUp->IsWait() ) { //CCockpit::GetInstance()->Reset(); viiMus::StopBGM( enSoundBgm1 ); ChangeGameSeq( enMainSeqGameInit ); } break; case enMainSeqGameInit: //----------------------------------------- //ゲーム初期化 //----------------------------------------- CCockpit::GetInstance()->Destroy(); CCockpit::GetInstance()->SetHidden(); m_bResetOK = gxFalse; if( pGame ) delete pGame; pGame = new CGameManager(); GameInit(); pGame->init(); CockpitControl(); viiMus::Destroy(); ChangeGameSeq( enMainSeqGameMain ); break; case enMainSeqGameMain: //----------------------------------------- //ゲームメイン //----------------------------------------- CDashBoard::GetInstance()->SetMenuDisable(gxFalse); m_bResetOK = gxTrue; if( m_pSetUp ) { m_bResetOK = gxFalse; m_pSetUp->Draw(); if( m_pSetUp->GoDestroy() ) { //---------------------------------------------- //セットアップ終了 //---------------------------------------------- CCockpit::GetInstance()->Reset(); delete m_pSetUp; m_pSetUp = NULL; } } if( !m_bGameStart && pGame->IsGameStart() ) { m_bGameStart = gxTrue; } GameMain(); if( pGame->IsStageClear() ) { m_sEndSeq = pGame->GetNextSeq(); //m_sEndSeq = 1; //次へ ChangeGameSeq( enMainSeqGameEnd ); } else if( CCockpit::GetInstance()->IsGameOver() ) { m_sEndSeq = enClearSeqContinue; ChangeGameSeq( enMainSeqGameEnd ); } break; case enMainSeqGameEnd: //----------------------------------------- //ゲーム終了 //----------------------------------------- m_bResetOK = gxFalse; GameEnd(); if( pGame ) { delete pGame; pGame = NULL; } if( !m_bBriefingRoot ) { m_sEndSeq = 0; } CCockpit::GetInstance()->ReNew(); if( m_sMainMenuSelected == CMainMenu::enMainMenuMission || m_sMainMenuSelected == CMainMenu::enMainMenuTutorial) { //--------------------------------------- //ストーリーモード以外の時 //--------------------------------------- //スコアを加算する g_CHoundSaveData.UpdateHighScore( g_StGameInfo.m_uAllScore ); //ミッションモードだった ChangeGameSeq( enMainSeqGameMainMenu ); //チュートリアルモードだった ChangeGameSeq( enMainSeqGameMainMenu ); } else if( m_sEndSeq == enClearSeqStageClear ) { #ifdef _TRIAL_VERSION_ //タイトルに戻る g_CHoundSaveData.UpdateHighScore( g_StGameInfo.m_uAllScore ); ChangeGameSeq( enMainSeqRestart ); #else //ステージクリアだった g_StGameInfo.SetStageClear( g_StGameInfo.PlayStage ); switch( g_StGameInfo.PlayStage ){ case enScenarioJungle: g_CHoundSaveData.SetHiddenOpen( enHiddenItemMission2 ); break; case enScenarioRiver: g_CHoundSaveData.SetHiddenOpen( enHiddenItemMission3 ); break; case enScenarioMountain: g_CHoundSaveData.SetHiddenOpen( enHiddenItemMission4 ); break; case enScenarioBase: g_CHoundSaveData.SetHiddenOpen( enHiddenItemMission5 ); break; } ChangeGameSeq( enMainSeqGameBriefing ); #endif } else if( m_sEndSeq == enClearSeqContinue ) { //ステージ失敗だった(コンティニュールート) ChangeGameSeq( enMainSeqGameContinue ); } else if( m_sEndSeq == enClearSeqGameOver ) { //ゲームオーバーだった ChangeGameSeq( enMainSeqGameContinue ); } else if( m_sEndSeq == enClearSeqEnding ) { //エンディングだった g_StGameInfo.SetStageClear( g_StGameInfo.PlayStage ); g_CHoundSaveData.UpdateHighScore( MISSION_ALLOVER_BONUS ); Uint32 uScore = 0; //ゲームスコアを加算 m_stEndingBonus.uAllScore = g_StGameInfo.m_uAllScore; //オールオーバーボーナスをコンティニュー回数で割る m_stEndingBonus.uContinueBonus = MISSION_ALLOVER_BONUS/(g_StGameInfo.m_sContinueCnt+1); m_stEndingBonus.uContinueBonus = m_stEndingBonus.uContinueBonus/10; m_stEndingBonus.uContinueBonus = m_stEndingBonus.uContinueBonus*10; //Trueエンディングの場合場合ボーナス m_stEndingBonus.uTrueEndBonus = 0; if( g_StGameInfo.m_bTrueEnd ) { m_stEndingBonus.uTrueEndBonus = ENDING_TRUEVERSION_BONUS; g_CHoundSaveData.SetHiddenOpen( enHiddenItemViewEnding ); } //ノーコンティニューだった場合2倍ボーナス if( g_StGameInfo.m_sContinueCnt == 0 ) { m_stEndingBonus.uNoContinueBonus = m_stEndingBonus.uAllScore + m_stEndingBonus.uContinueBonus + m_stEndingBonus.uTrueEndBonus; } uScore = m_stEndingBonus.uAllScore; uScore += m_stEndingBonus.uContinueBonus; uScore += m_stEndingBonus.uTrueEndBonus; uScore += m_stEndingBonus.uNoContinueBonus; m_stEndingBonus.uTotalScore = uScore; //スコアを加算する g_CHoundSaveData.UpdateHighScore( uScore ); ChangeGameSeq( enMainSeqGameEndingDemo ); } else { //リセットだった /* if( m_bGameStart && m_sMainMenuSelected == CMainMenu::enMainMenuStart ) { m_sResetCount = 120; ChangeGameSeq( enMainSeqResetInGame ); } else { ChangeGameSeq( enMainSeqRestart ); } */ ChangeGameSeq( enMainSeqRestart ); } break; case enMainSeqGameContinue: //----------------------------------------- //コンティニュー //----------------------------------------- m_bResetOK = gxTrue; m_bGameStart = gxFalse; switch( ContinueScreen() ){ case enMenuSeqNext: { //タイトルに戻る g_CHoundSaveData.UpdateHighScore( g_StGameInfo.m_uAllScore ); ChangeGameSeq( enMainSeqRestart ); } break; case enMenuSeqBack: { //コンティニューする // Sint32 sMem = g_StGameInfo.PlayArea; // StageSet(); //スコアをリセットする /* g_StGameInfo.m_uAllScore = (g_StGameInfo.m_uAllScore/2); g_StGameInfo.m_uAllScore -= g_StGameInfo.m_uAllScore%10;; */ //スコア更新 g_CHoundSaveData.UpdateHighScore( g_StGameInfo.m_uAllScore ); g_StGameInfo.m_uAllScore = 0;//(g_StGameInfo.m_uAllScore/2); g_StGameInfo.m_uStageScore = g_StGameInfo.m_uAllScore; if( g_StGameInfo.m_sContinueCnt < 99 ) g_StGameInfo.m_sContinueCnt ++; g_StGameInfo.ContinueArea = g_StGameInfo.PlayArea; ChangeGameSeq( enMainSeqGameInit ); } break; default: break; } break; case enMainSeqGameEndingDemo: //----------------------------------------- //ゲーム終了 //----------------------------------------- m_bResetOK = gxTrue; m_bGameStart = gxFalse; CCockpit::GetInstance()->SetHidden(); CDashBoard::GetInstance()->SetMenuDisable(gxFalse); if( EndingDemo() ) { ChangeGameSeq( enMainSeqRestart ); } break; case enMainSeqResetInGame: if( m_sResetCount > 0 ) { m_sResetCount --; } else { g_StGameInfo.m_uAllScore = 0; g_StGameInfo.m_uStageScore = 0; g_StGameInfo.ContinueArea = g_StGameInfo.PlayArea; CCockpit::GetInstance()->ReNew(); ChangeGameSeq( enMainSeqGameInit ); } break; default: break; } viiMus::GetInstance()->Action(); CFadeManager::GetInstance()->action(); }
//+++++++++++++++++++++++++++++++++++++++++++++++++ //メイン関数 //------------------------------------------------- //初期化及びメインループ //--in--------------------------------------------- // //--out--------------------------------------------- // //+++++++++++++++++++++++++++++++++++++++++++++++++ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, int iCmdShow) { HWND hWnd; MSG msg; DWORD dwFPSLastTime, dwCurrentTime, dwFrameCount; //ウィンドウ クラスを登録 WNDCLASS wndClass = { CS_HREDRAW | CS_VREDRAW, WndProc, 0, 0, hInst, LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1)), LoadCursor(NULL, IDC_ARROW), (HBRUSH)GetStockObject(WHITE_BRUSH), MAKEINTRESOURCE(IDR_MENU1), CLASS_NAME }; if (RegisterClass(&wndClass) == 0) return false; //ウィンドウ サイズを取得 RECT rc = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT}; DWORD dwStyle = WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE; DWORD dwExStyle = 0; AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle); //ウィンドウを作成 hWnd = CreateWindowEx( dwExStyle, CLASS_NAME, CAPTION_NAME, dwStyle, WINDOW_X, WINDOW_Y, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInst, NULL); if (hWnd == NULL) return false; g_bWindow = true; if(FAILED(InitializeGraphics(hWnd, g_bWindow))) return 0; //OpenGL の初期化 //変数初期化 timeBeginPeriod(1); //タイマの分解能を最小にセット dwFPSLastTime = dwExecLastTime = timeGetTime(); //現在のシステム タイマを取得 dwExecLastTime -= FRAME_RATE; dwFrameCount = 0; g_fFPS = 0.0f; //マウスカーソル位置を固定する //SetCursorPos( WINDOW_X + SCREEN_WIDTH / 2, WINDOW_Y + SCREEN_HEIGHT / 2 ); //ウィンドウの中心位置に固定 ShowCursor(false); //メイン ウインドウ ループ msg.message = WM_NULL; //乱数設定 InitRandom(); while (WM_QUIT != msg.message && !g_bEnd) //WM_QUIT がくるか、終了フラグがたつまでループ { if (PeekMessage(&msg,NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { dwCurrentTime = timeGetTime(); //現在のタイマ値を取得 if (dwCurrentTime - dwFPSLastTime >= 500) //0.5 秒ごとに計測 { //フレーム数を計算 g_fFPS = dwFrameCount * 1000.0f / (dwCurrentTime - dwFPSLastTime); dwFPSLastTime = dwCurrentTime; //タイマ値を更新 dwFrameCount = 0; //フレーム カウンタをリセット } //この辺で時間管理 while (dwCurrentTime - dwExecLastTime >= FRAME_RATE) //一定時間が経過したら・・・ { dwExecLastTime += FRAME_RATE; //タイマ値を更新 GameMain(hWnd); //ゲーム メイン処理 } RenderGraphics(); //レンダリング処理を実行 dwFrameCount++; //フレーム カウントを+1 Sleep(1); //いったん Windows に制御を戻す } //終了確認 if(g_bEnd) { //if (IDNO == MessageBox(hWnd, _T("ゲームを終了しますか?"), _T("終了確認"), MB_YESNO)) // g_bEnd = false; } } timeEndPeriod(1); //システム タイマの分解能を元に戻す return (int)msg.wParam; }