-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.h
121 lines (83 loc) · 1.97 KB
/
game.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
/*
Àâòîð(ñ): Ñàííèêîâ, Êóëåáÿêèí, Ñòóïàê è Ïàðõîìåíêî
Íàçâàíèå êîìàíäû: AGRAGE
e-mail: [email protected]
*/
#if! defined(_GAME_VILLAGE_)
#define _GAME_VILLAGE_
#if _MSC_VER > 1000
#pragma once
#endif
#define MAX_BUTTONS 2
// ìåíþøíàÿ êíîïêà
struct sButton {
TCHAR caption[32];
GLint x;
GLint y;
GLint width;
GLint height;
COLORREF color;
COLORREF color_state;
COLORREF color_active;
int id;
sButton(void){}
sButton(int pid, const TCHAR* pcaption, GLint px, GLint py, GLint pwidth, GLint pheight, COLORREF pcolor_state, COLORREF pcolor_active) {
_tcscpy(caption, pcaption);
x = px;
y = py;
width = pwidth;
height = pheight;
color_state = pcolor_state;
color_active = pcolor_active;
color = color_state;
id = pid;
}
bool MouseMove(LPPOINT pt) {
RECT rect = { x, y, x + width, y + height };
if(PtInRect(&rect, *pt)) {
color = color_active;
return true;
} else
color = color_state;
return false;
}
int MouseDown(const LPPOINT pt) {
if(this->MouseMove(pt))
return id;
return 0;
}
};
// êëàññ-èãðû
class xGame : public xDlgScene {
private:
GLuint tex_cursor;
GLuint tex_digits;
GLuint tex_alpha;
xTerrain* terrain;
xUser* user;
xSkyBox skybox;
xCamera camera;
GLuint tex_life;
GLVECTOR4 light_pos;
enum {
GAME_MENU = 1,
GAME_START = 2,
GAME_OVER = 8,
GAME_QUIT = 16
};
int state_game;
sButton buttons[MAX_BUTTONS];
public:
xGame(HINSTANCE hInstance);
~xGame();
private:
virtual void OnRender(void);
virtual void OnCreate(HDC hDC, HWND hwnd);
virtual void OnDestroy(void);
virtual void OnMouseDown(WPARAM wParam, int x, int y);
private:
void Initialize(void);
void DrawMenu(void);
void DrawGameOver(void);
};
#endif