//다음 함수는 응용 프로그램이 실행되면 호출된다는 것에 유의하라. bool CGameFramework::OnCreate(HINSTANCE hInstance, HWND hMainWnd) { m_hInstance = hInstance; m_hWnd = hMainWnd; //Direct3D 디바이스, 디바이스 컨텍스트, 스왑 체인 등을 생성하는 함수를 호출한다. if (!CreateDirect3DDisplay()) return(false); //렌더링할 객체(게임 월드 객체)를 생성한다. BuildObjects(); return(true); }
// 다음 함수는 응용 프로그램이 실행되면 호출된다는 것에 유의 bool CGameFrameWork::OnCreate(HINSTANCE hInstance, HWND hMainWnd) { m_hdc = GetDC(g_hWnd); m_hInstance = hInstance; m_nGoal = 10000; m_nScore = 0; m_bMove = false; BuildObjects(); //////////////////////////////////// m_bRecord = false; m_bReplay = false; m_bStepByStep = false; m_bSpaceDown = false; m_nReplayCnt = 0; //////////////////////////////////// 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; }