Created
March 13, 2026 01:10
-
-
Save bg1bgst333/75daa70a8f0e758f69bfc4e5b489bbb6 to your computer and use it in GitHub Desktop.
CGameApplication::Input
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(); | |
| // "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); | |
| } | |
| // 入力処理関数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; | |
| } | |
| } |
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. | |
| }; | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment