int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Game *game = new Game(); //devlare variables MSG msg; HWND hWnd; //regidter the class MyRegisterClass(hInstance); //create a new window hWnd = CreateWindow( APPTITLE, APPTITLE, SCREEN, CW_USEDEFAULT, CW_USEDEFAULT, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL); if (!hWnd) { DWORD ErrCode = GetLastError(); return FALSE; } //display the window ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); if (!game->Game_Init(hInstance, hWnd)) { return 0; } DWORD frame_start = GetTickCount(); DWORD count_per_frame = 1000 / FRAME_RATE; DWORD interval = 1; //main message loop int done = 0; while (!done) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { done = 1; } TranslateMessage(&msg); DispatchMessage(&msg); } DWORD now = GetTickCount(); if (now - frame_start >= count_per_frame) { interval = now - frame_start; frame_start = now; game->Game_Run(hWnd, interval); } } game->Game_End(hWnd); return msg.wParam; }