Created
March 10, 2026 01:46
-
-
Save bg1bgst333/e92c83a5c72d813f6bdbcc4274c8044c to your computer and use it in GitHub Desktop.
CGameApplication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ヘッダのインクルード | |
| // 独自のヘッダ | |
| #include "GameApplication.h" // CGameApplication | |
| // コンストラクタCGameApplication | |
| CGameApplication::CGameApplication() : CGraphicalApplication() { | |
| } | |
| // メインループ処理関数MainProc. | |
| void CGameApplication::MainProc() { | |
| // "ABCDE"を描画. | |
| HDC hDC = GetDC(m_pMainWnd->m_hWnd); | |
| TextOut(hDC, 50, 50, _T("ABCDE"), lstrlen(_T("ABCDE"))); | |
| ReleaseDC(m_pMainWnd->m_hWnd, hDC); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 二重インクルード防止 | |
| #ifndef __GAME_APPLICATION_H__ | |
| #define __GAME_APPLICATION_H__ | |
| // ヘッダのインクルード | |
| // 独自のヘッダ | |
| #include "GraphicalApplication.h" // CGraphicalApplication | |
| // ゲームアプリケーションクラスCGameApplication | |
| class CGameApplication : public CGraphicalApplication { | |
| // publicメンバ | |
| public: | |
| // publicメンバ関数 | |
| // コンストラクタ | |
| CGameApplication(); // コンストラクタCGameApplication | |
| virtual void MainProc(); // メインループ処理関数MainProc. | |
| }; | |
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ヘッダのインクルード | |
| // 独自のヘッダ | |
| #include "GraphicalApplication.h" // CGraphicalApplication | |
| // コンストラクタCGraphicalApplication | |
| CGraphicalApplication::CGraphicalApplication() : CApplication() { | |
| } | |
| // メッセージループ処理関数Run. | |
| int CGraphicalApplication::Run() { | |
| // 変数の初期化. | |
| MSG msg = { 0 }; // MSG型メッセージ構造体msgを{0}で初期化. | |
| int lCount = 0; // ウィンドウメッセージが来なかった時の回数を保持するint型変数lCountの初期値を0とする. | |
| // PeekMessageによるメインループ. | |
| while (TRUE) { // 常に真(TRUE)なので無限ループ. | |
| // メッセージループが来ていれば処理する. | |
| while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { | |
| // 0にリセット. | |
| lCount = 0; // lCountを0にリセット. | |
| // WM_QUITならExitInstanceを呼んで終了. | |
| if (msg.message == WM_QUIT) { | |
| return ExitInstance(); | |
| } | |
| // ウィンドウメッセージの送出 | |
| TranslateMessage(&msg); // TranslateMessageで仮想キーメッセージを文字メッセージへ変換. | |
| DispatchMessage(&msg); // DispatchMessageで受け取ったメッセージをウィンドウプロシージャ(この場合は独自に定義したWindowProc)に送出. | |
| } | |
| // アイドル処理 | |
| OnIdle(lCount++); | |
| Sleep(1); | |
| } | |
| } | |
| // 終了処理関数ExitInstance. | |
| int CGraphicalApplication::ExitInstance() { | |
| // 親クラスのExitInstanceを呼ぶ. | |
| return CApplication::ExitInstance(); | |
| } | |
| // アイドル処理関数OnIdle. | |
| BOOL CGraphicalApplication::OnIdle(LONG lCount) { | |
| // 画面の更新. | |
| if (m_pMainWnd != NULL) { // m_pMainWndがNULLでない時. | |
| if (m_pMainWnd->m_hWnd != NULL) { // m_pMainWnd->m_hWndがNULLでない時. | |
| // メインループ処理. | |
| MainProc(); | |
| } | |
| } | |
| // とりあえずTRUE. | |
| return TRUE; | |
| } | |
| // メインループ処理関数MainProc. | |
| void CGraphicalApplication::MainProc() { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 二重インクルード防止 | |
| #ifndef __GRAPHICAL_APPLICATION_H__ | |
| #define __GRAPHICAL_APPLICATION_H__ | |
| // ヘッダのインクルード | |
| // 独自のヘッダ | |
| #include "Application.h" // CApplication | |
| // グラフィカルアプリケーションクラスCGraphicalApplication | |
| class CGraphicalApplication : public CApplication { | |
| // publicメンバ | |
| public: | |
| // publicメンバ関数 | |
| // コンストラクタ | |
| CGraphicalApplication(); // コンストラクタCGraphicalApplication | |
| virtual int Run(); // メッセージループ処理関数Run. | |
| virtual int ExitInstance(); // 終了処理関数ExitInstance. | |
| virtual BOOL OnIdle(LONG lCount); // アイドル処理関数OnIdle. | |
| virtual void MainProc(); // メインループ処理関数MainProc. | |
| }; | |
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 二重インクルード防止 | |
| #ifndef __MAIN_APPLICATION_H__ | |
| #define __MAIN_APPLICATION_H__ | |
| // ヘッダのインクルード | |
| // 独自のヘッダ | |
| #include "GameApplication.h" // CGameApplication | |
| // メインアプリケーションクラスCMainApplication | |
| class CMainApplication : public CGameApplication { | |
| // publicメンバ | |
| public: | |
| // publicメンバ関数 | |
| virtual BOOL InitInstance(HINSTANCE hInstance, LPTSTR lpCmdLine, int nShowCmd); // インスタンス初期化関数InitInstance. | |
| }; | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment