int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pstrCmdLine, int iCmdShow){ HWND hWnd; MSG msg; WNDCLASSEX wc; static char strAppName[] = "First Windows App, Zen Style"; wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; wc.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hIconSm = LoadIcon(NULL, IDI_HAND); wc.hCursor = LoadCursor(NULL, IDC_CROSS); wc.lpszMenuName = NULL; wc.lpszClassName = strAppName; RegisterClassEx(&wc); hWnd = CreateWindowEx(NULL, strAppName, strAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 512,512, NULL, NULL, hInstance, NULL); g_hWndMain = hWnd;//set our global window handle ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); if(FAILED(GameInit())){;//initialize Game SetError("Initialization Failed"); GameShutdown(); return E_FAIL; } while(TRUE){ if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){ if(msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } else{ GameLoop(); } } GameShutdown();// clean up the game return msg.wParam; }
void CGameManager::Shutdown() { if( m_GameState == FrontEnd ) FrontEndShutdown(); else if( m_GameState == Game ) GameShutdown(); }
void GameInit(void) { GameShutdown(); Vector PA, PB; float oa, ob; float ra, rb; PA.Randomise(Vector(dbg_world_size * 0.5f, dbg_world_size * 0.5f), Vector(dbg_world_size * 0.5f, dbg_world_size * 0.5f)); PB.Randomise(Vector(dbg_world_size * -0.15f, dbg_world_size * -0.15f), Vector(dbg_world_size * 0.15f, dbg_world_size * 0.15f)); PB += PA; oa = frand(); ob = frand(); ra = dbg_world_size * (frand(0.1f) + 0.15f); rb = dbg_world_size * (frand(0.1f) + 0.15f); Anum = rand()%2+3; Bnum = rand()%5+3; Cnum = 32; A = PolyClip::BuildBlob(Anum, ra, ra); B = PolyClip::BuildBlob(Bnum, rb, rb); C = PolyClip::BuildBlob(Cnum, 1, 1); PolyClip::Transform(A, Anum, A, PA, oa); PolyClip::Transform(B, Bnum, B, PB, ob); }
void GameInit(void) { GameShutdown(); for(int i = 0; i < 2; i ++) { m_xPosition[i].Randomise(Vector(dbg_world_size * 0.25f, dbg_world_size * 0.25f), Vector(dbg_world_size * 0.75f, dbg_world_size * 0.75f)); m_iNumVertices[i] = rand() % 6 + 3; float fRadius = frand(dbg_world_size * 0.05f) + dbg_world_size * 0.1f; m_pxVertices[i] = PolyColl::BuildBlob(m_iNumVertices[i], fRadius); } }
int main( int argc, char* args[] ) { if(!InitializeEngine()) { printf( "Failed to initialize!\n" ); return 1; } if(!GameInitialize()) { printf( "Failed to load media!\n" ); return 2; } //Main loop flag bool quit = false; //Event handler SDL_Event e; Uint32 nStartTime = 0; Uint32 nFrameTime = 0; //While application is running while( !quit ) { //Handle events on queue while( SDL_PollEvent( &e ) != 0 ) { //User requests quit if( e.type == SDL_QUIT ) { quit = true; } else { KeyEventListenerManager::Instance().HandlerEvent(e); } } nStartTime = SDL_GetTicks(); GameLoop(nFrameTime); nFrameTime = SDL_GetTicks() - nStartTime; } // Release any and all resources. GameShutdown(); ShutdownEngine(); return 0; }
void GameInit(void) { GameShutdown(); for(int i = 0; i < 2; i ++) { m_xDisplacement[i] = Vector(0, 0); m_xPosition[i].Randomise(Vector(dbg_world_size * 0.25f, dbg_world_size * 0.25f), Vector(dbg_world_size * 0.75f, dbg_world_size * 0.75f)); m_iNumVertices[i] = rand() % 6 + 2; float fRadius = frand(dbg_world_size * 0.05f) + dbg_world_size * 0.1f; m_pxVertices[i] = PolyColl::BuildBlob(m_iNumVertices[i], fRadius); m_fAngle[i] = 0.0f; m_fAngularVelocity[i] = (float) (i) / 2.0f + 0.1f; m_xOrientation[i] = Matrix(m_fAngle[i]); } }
void GameInit(void) { GameShutdown(); Vector xBottom= Vector( dbg_world_size * 0.50f, -dbg_world_size * 0.49f); Vector xTop = Vector( dbg_world_size * 0.50f, dbg_world_size * 1.49f); Vector xLeft = Vector(-dbg_world_size * 0.49f, dbg_world_size * 0.50f); Vector xRight = Vector( dbg_world_size * 1.49f, dbg_world_size * 0.50f); Vector xCentre= Vector( dbg_world_size * 0.50f, dbg_world_size * 0.50f); m_pxBodies[0] = new CBody(xBottom, 0.0f, dbg_world_size, dbg_world_size); m_pxBodies[1] = new CBody(xTop , 0.0f, dbg_world_size, dbg_world_size); m_pxBodies[2] = new CBody(xLeft , 0.0f, dbg_world_size, dbg_world_size); m_pxBodies[3] = new CBody(xRight , 0.0f, dbg_world_size, dbg_world_size); m_pxBodies[4] = new CBody(xCentre, 0.0f, dbg_world_size * 0.01f, dbg_world_size * 0.01f); for(int i = 5; i < eNumBodies; i ++) { m_pxBodies[i] = new CBody(); } }
void GameInit(void) { GameShutdown(); Vector xBottom= Vector( dbg_world_size * 0.50f, -dbg_world_size * 0.49f); Vector xTop = Vector( dbg_world_size * 0.50f, dbg_world_size * 1.49f); Vector xLeft = Vector(-dbg_world_size * 0.49f, dbg_world_size * 0.50f); Vector xRight = Vector( dbg_world_size * 1.49f, dbg_world_size * 0.50f); m_pxBodies[0] = new CBody(xBottom, 0.0f, dbg_world_size, dbg_world_size); m_pxBodies[1] = new CBody(xTop , 0.0f, dbg_world_size, dbg_world_size); m_pxBodies[2] = new CBody(xLeft , 0.0f, dbg_world_size, dbg_world_size); m_pxBodies[3] = new CBody(xRight , 0.0f, dbg_world_size, dbg_world_size); m_pxPlayer = m_pxBodies[4] = new CBody(Vector(dbg_world_size * 0.5f, dbg_world_size * 0.5f), 100.0f, dbg_world_size * 0.1f, dbg_world_size * 0.15f); m_pxPlayer->GetAngVelocity() = 0.0f; for(int i = eMinBodies; i < eNumBodies; i ++) { m_pxBodies[i] = new CBody(); } }
void Game(void) { int x, y, z, a; char msg0[80]; char msg1[80]; char msg2[80]; char msg3[80]; qdgdfa_stop_sound(music); GameStartup(); x = 16384 + 64; z = 16384 + 64; y = 16384; a = ANGLE(0); if (_level == 0) strcpy(msg0, "LEVEL: CUSTOM"); else sprintf(msg0, "LEVEL: %d", _level); sprintf(msg1, "AREA: %s", _area_name); sprintf(msg2, "PUMPS: %d / CONSOLES: %d", _num_pumps, _num_consoles); sprintf(msg3, "TOTAL SINKING ESTIMATED: %02d:%02d", _left_minutes, _left_seconds); SetMessage(msg0, msg1, msg2, msg3, 10); GameCore(x, y, z, a); GameShutdown(); qdgdfa_reset(); music = qdgdfa_load_sound("sound/holst.wav"); qdgdfa_play_sound(music, 1); }
int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int nshowcmd ) { MSG msg; WNDCLASSEX ex; int argc; char cmdline[512]; const char* argv[32]; char* tok; // Convert command line into C-style argc & argv. strcpy( cmdline, lpcmdline ); argv[0] = "cylindrix"; argc = 1; tok = strtok( cmdline, " \t" ); while ( tok ) { argv[argc++] = tok; tok = strtok( 0, " \t" ); } ex.cbSize = sizeof(WNDCLASSEX); ex.style = CS_HREDRAW|CS_VREDRAW|CS_OWNDC; ex.lpfnWndProc = WinProc; ex.cbClsExtra = 0; ex.cbWndExtra = 0; ex.hInstance = hinstance; ex.hIcon = LoadIcon(NULL, IDI_APPLICATION); ex.hCursor = LoadCursor(NULL, IDC_ARROW); ex.hbrBackground = NULL; ex.lpszMenuName = NULL; ex.lpszClassName = WNDCLASSNAME; ex.hIconSm = NULL; if ( !RegisterClassEx( &ex ) ) { MessageBox( NULL, "Failed to register the window class", "Window Reg Error", MB_OK ); return 1; } // Create the window CreateWnd( hinstance, screenw, screenh, SCRDEPTH, WINDOWED ); GameInit( argc, argv ); // The message loop while ( !quit ) { quit = GameLoop(); // clear keys pressed. memset( keysPressed, 0, 255 ); SwapBuffers( hdc ); if ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) { if (msg.message == WM_QUIT) quit = TRUE; TranslateMessage( &msg ); DispatchMessage( &msg ); } } GameShutdown(); SysShutdown(); return msg.lParam; }
int WINAPI WinMain(HINSTANCE h, HINSTANCE p, LPSTR cmd, int show) { // Register the window class WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, WINDOW_CLASS, NULL }; RegisterClassEx(&wc); // Create the application's window if(FULLSCREEN) { g_hwnd = CreateWindowEx(NULL, WINDOW_CLASS, WINDOW_NAME, WS_POPUP | WS_SYSMENU | WS_VISIBLE, 0, 0, WIN_WIDTH, WIN_HEIGHT, NULL, NULL, h, NULL); } else { const int sys_min_height = GetSystemMetrics(SM_CYMIN); const int sys_caption_height = GetSystemMetrics(SM_CYSMCAPTION); g_hwnd = CreateWindowEx(NULL, WINDOW_CLASS, WINDOW_NAME, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, WIN_WIDTH + (sys_min_height - sys_caption_height), WIN_HEIGHT + sys_min_height, NULL, NULL, h, NULL); } if(g_hwnd) { // Show the window ShowWindow(g_hwnd, SW_SHOWDEFAULT); UpdateWindow(g_hwnd); } // Initialize the Stranded Engine. if(InitializeEngine()) { // Initialize Stranded game. if(GameInitialize()) { // Enter the message loop MSG msg; ZeroMemory(&msg, sizeof(msg)); SetCursorPos(0, 0); while(msg.message != WM_QUIT) { if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else GameLoop(); } } } // Release any and all resources. GameShutdown(); ShutdownEngine(); UnregisterClass(WINDOW_CLASS, wc.hInstance); return 0; }