-
Notifications
You must be signed in to change notification settings - Fork 0
/
CWndMain.h
142 lines (107 loc) · 2.22 KB
/
CWndMain.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#pragma once
#include "CApp.h"
#include "Utility.h"
struct CBullet
{
float x;
float y;
float fSpeed;
};
struct CEnemy
{
float x;
float y;
float fHealth;
float fSpeed;
ULONGLONG ullLastBulletTime;
CEnemy() = default;
CEnemy(float x, float y)
{
RandInit(x, y);
}
void RandInit(float x_, float y_)
{
x = x_;
y = y_;
fHealth = 100.f;
fSpeed = (float)Utility::Rand(6, 10);
ullLastBulletTime = 0ull;
}
};
struct CExplosion
{
float x;
float y;
int idxExplosion = 0;
};
struct CSupply
{
float x;
float y;
UINT uTick;
};
class CWndMain
{
private:
enum
{
TIDX_BACKGND1,
TIDX_HERO1,
TIDX_HEROBULLET,
TIDX_ENEMY1,
TIDX_ENEMYBULLET,
TIDX_EXPLOSION,
TIDX_SUPPLY,
TIDX_MAX,
};
HWND m_hWnd = NULL;
IDXGISwapChain1* m_pSwapChain = NULL;
ID2D1DeviceContext* m_pDC = NULL;
ID2D1Bitmap1* m_pBmpBK = NULL;
ID2D1Bitmap1* m_pBmpPauseBK = NULL;
ID2D1SolidColorBrush* m_pBrHealth = NULL;
ID2D1SolidColorBrush* m_pBrHealthBK = NULL;
ID2D1SolidColorBrush* m_pBrText = NULL;
IDWriteTextFormat* m_pTfScore = NULL;
IDWriteTextFormat* m_pTfTitle = NULL;
Utility::Texture m_Texture[TIDX_MAX]{};
int m_cxClient = 0;
int m_cyClient = 0;
int m_yBkImg = 0;
D2D1_POINT_2F m_ptCursor{};
float m_fScaleFactor = 1.f;
std::vector<CBullet> m_HeroBullet{};
std::vector<CBullet> m_EnemyBullet{};
std::vector<CEnemy> m_Enemy{ 6 };
std::vector<CExplosion> m_Explosion{};
std::vector<CSupply> m_Supply{};
BOOL m_bLBtnDown = FALSE;
ULONGLONG m_ullLastBulletTime = 0ull;
ULONGLONG m_ullLastCollisionTime = 0ull;
UINT m_uScore = 0u;
UINT m_uMiss = 0u;
float m_fHealth = 100.f;
BOOL m_bGameOver = FALSE;
BOOL m_bGamePause = FALSE;
BOOL m_bPauseBKPrepared = FALSE;
private:
static LRESULT CALLBACK WndProc_Main(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void OnSize(int cx, int cy);
void OnCreate(HWND hWnd);
void OnDestroy();
void LoadTexture();
void PreparePauseBK(int iType);
void Reset();
void EnemyOnDel(CEnemy& x);
public:
CWndMain()
{
m_HeroBullet.reserve(32u);
}
void Tick();
static ATOM RegisterWndClass();
HWND GetHwnd() const { return m_hWnd; }
HWND Create(PCWSTR pszText, int x, int y, int cx, int cy, DWORD dwStyle, DWORD dwExStyle);
void GameOver();
void Pause();
};