Created
March 14, 2026 02:00
-
-
Save bg1bgst333/abbaf206599b52cdce78883a10c8abd9 to your computer and use it in GitHub Desktop.
CGameApplication::Render
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() { | |
| // 初期化. | |
| m_x = 0; | |
| m_y = 0; | |
| } | |
| // メインループ処理関数MainProc. | |
| void CGameApplication::MainProc() { | |
| // 入力処理 | |
| Input(); | |
| // 描画処理 | |
| Render(); | |
| } | |
| // 入力処理関数Input. | |
| void CGameApplication::Input() { | |
| // キー入力で描画位置を動かす. | |
| if (GetAsyncKeyState(VK_LEFT) & 0x8000) { | |
| m_x -= 2; | |
| } | |
| if (GetAsyncKeyState(VK_RIGHT) & 0x8000) { | |
| m_x += 2; | |
| } | |
| if (GetAsyncKeyState(VK_UP) & 0x8000) { | |
| m_y -= 2; | |
| } | |
| if (GetAsyncKeyState(VK_DOWN) & 0x8000) { | |
| m_y += 2; | |
| } | |
| } | |
| // 描画処理関数Render. | |
| void CGameApplication::Render() { | |
| // "ABCDE"を描画. | |
| HDC hDC = GetDC(m_pMainWnd->m_hWnd); | |
| TextOut(hDC, m_x, m_y, _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メンバ変数 | |
| int m_x; // テキストの位置X座標m_x | |
| int m_y; // テキストの位置Y座標m_y | |
| // publicメンバ関数 | |
| // コンストラクタ | |
| CGameApplication(); // コンストラクタCGameApplication | |
| virtual void MainProc(); // メインループ処理関数MainProc. | |
| virtual void Input(); // 入力処理関数Input. | |
| virtual void Render(); // 描画処理関数Render. | |
| }; | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment