//----------------------------------------------------------------------------- // Name : InitInstance () // Desc : Initialises the entire Engine here. //----------------------------------------------------------------------------- bool CDDGameApp::InitInstance( HANDLE hInstance, LPCTSTR lpCmdLine, int iCmdShow ) { // Create the primary display device if (!CreateDisplay()) { ShutDown(); return false; } // Build Objects if (!BuildSprites()) { ShutDown(); return false; } // Set up all required game states SetupGameState(); // Setup our rendering environment //SetupRenderStates(); // Success! return true; }
//----------------------------------------------------------------------------- // Name : BeginGame () // Desc : Signals the beginning of the physical post-initialization stage. // From here on, the game engine has control over processing. //----------------------------------------------------------------------------- int CGameApp::BeginGame() { MSG msg; StartGame = false; // Start main loop while(true) { // Did we receive a message, or are we idling ? if ( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) { if (msg.message == WM_QUIT) break; TranslateMessage( &msg ); DispatchMessage ( &msg ); } else { cursor.cbSize = sizeof(CURSORINFO); GetCursorInfo(&cursor); // Advance Game Frame. if(StartGame == false) { if(cursor.ptScreenPos.x > m_nViewWidth - LOCATE_MENU_X && cursor.ptScreenPos.y < LOCATE_MENU_Y_TOP) { if (!BuildObjects()) { MessageBox( 0, _T("Failed to initialize properly. Reinstalling the application may solve this problem.\nIf the problem persists, please contact technical support."), _T("Fatal Error"), MB_OK | MB_ICONSTOP); ShutDown(); return false; } // Set up all required game states SetupGameState(); StartGame = true; } if(StartLoad == true) { if (!BuildObjects_Load()) { MessageBox( 0, _T("Failed to initialize properly. Reinstalling the application may solve this problem.\nIf the problem persists, please contact technical support."), _T("Fatal Error"), MB_OK | MB_ICONSTOP); ShutDown(); return false; } // Set up all required game states SetupGameState(); StartGame = true; } if(cursor.ptScreenPos.x > m_nViewWidth - LOCATE_MENU_X && cursor.ptScreenPos.y > m_nViewHeight + LOCATE_MENU_Y_BOTTOM) { PostQuitMessage(0); } } FrameAdvance(); } // End If messages waiting } // Until quit message is received return 0; }