Repository navigation
Expand file tree
/
Copy pathgame.cpp
More file actions
173 lines (171 loc) · 3.19 KB
/
Copy pathgame.cpp
File metadata and controls
173 lines (171 loc) · 3.19 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include "common.h"
#include "graphic.h"
#include "function.h"
#pragma comment(linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"")
int main()
{
image IMG;
int floor = 1;
bool clear = false;
srand(unsigned int(time(NULL)));
button B[BUTTONCOUNT];
iniAllButton(B);
initgraph(1080, 720);
loadImg(&IMG);
HWND h = GetHWnd();
SetWindowText(h, "黄金矿工");
Bgm();
while (1)
{
player p;
iniPlayer((getwidth() - 140) / 2, 70, 140, 120, 0, H_swing, 1, false, &p);//初始化玩家
tool t;
iniTool(&t);
floor = 1;
while (1)
{
BeginBatchDraw();
menu(B);
int tmp = menuButton();
if (tmp == 3)
return 0;
else if (tmp == BUTTONCOUNT)
{
showHelp();
}
else if (tmp == 2)
{
showChart();
}
else if (tmp == 1)
{
break;
}
FlushBatchDraw();
}
InputBox(p.name, 45, "请输入您的名字", "输入名字", NULL, 400, 0);
//bool exi = true;
//while (exi)
//{
// showShop(&IMG, &t, &p);
// switch (shop(&t, &p))
// {
// case 0://退出
// exi = false;
// break;
// case 2://购买失败
// shopFail();
// break;
// case 1:
// shopSuccess();
// break;
// }
//}
while (1)
{
hook h;
iniHook(60, p.x + 45, p.y + 90, p.x + 45, p.y + 150, 0.0, 0.0009, true, 0.0, 0.0, 0.0, H_swing, true, &h);
iniPptState(&p);
while (t.lottery > 0)
{
int price = scratchTickets(&p, &t);
showLottery(&IMG, price);
}
int countdown = 60;
nfm* curMove = NULL;
nfm* head = ininFm();
randomMine(head, floor);
int clearcondition = clearanceCondition(head) + p.coin;
time_t start_time = time(NULL);
while (countdown > 0 && !is_Clear(head))
{
BeginBatchDraw();
drawPlayer(&IMG, &p, h);
countDown(start_time, &countdown);
currentFloor(floor);
current(p.coin);
target(clearcondition);
showTool(&t, &IMG);
keyOp(&h, curMove, &p, &t);
HookMove(&h);
//ppt(&p, &t);
drawMine(head, &IMG);
if (catchMine(&h, head, &p) != NULL)
{
curMove = catchMine(&h, head, &p);
}
if (GetAsyncKeyState(VK_ESCAPE))
{
time_t tmp1 = time(NULL);
FlushBatchDraw();
while (1)
{
BeginBatchDraw();
menu(B);
int tmp = menuButton();
if (tmp == 3)
{
sortChart(p.coin, p.name);
return 0;
}
else if (tmp == BUTTONCOUNT)
{
showHelp();
}
else if (tmp == 2)
{
showChart();
}
else if (tmp == 1)
{
break;
}
FlushBatchDraw();
}
time_t tmp2 = time(NULL);
start_time -= tmp1 - tmp2;
}
sleep_us(150);//用暂停控制帧率
FlushBatchDraw();
}
if (p.coin < clearcondition)
{
if (totem(t.totem))//有图腾不死
{
showTotemBreak(&IMG);
t.totem--;
}
else//没图腾死亡
{
fail();
sortChart(p.coin, p.name);
break;
}
}
floor++;
if (floor - 1 != 0 && (floor - 1) % 5 == 0)
{
bool exi = true;
while (exi)
{
showShop(&IMG, &t, &p);
switch (shop(&t, &p))
{
case 0://退出
exi = false;
break;
case 2://购买失败
shopFail();
break;
case 1:
shopSuccess();
break;
}
}
}
nextfloor();
}
}
closegraph();
return 0;
}