-
Notifications
You must be signed in to change notification settings - Fork 0
/
zff_old.cpp
254 lines (251 loc) · 4.88 KB
/
zff_old.cpp
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#include<iostream>
#include<conio.h>
#include<windows.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include"get.cpp"
#include"rand.cpp"
using namespace std;
typedef const int ci;
typedef const char cc;
typedef const double cd;
cc fu='F',you='H';
int keyboard()
{
int ch;
while (1)
{
if (_kbhit())
{//如果有按键按下,则_kbhit()函数返回真
ch = _getch();//使用_getch()函数获取按下的键值
Sleep(10);
return ch;
}
}
}
int check(int num){
if(num==72)return 1;
if(num==80)return 2;
if(num==75)return 3;
if(num==77)return 4;
if(num==13)return 13;
if(num==114)return 7;
if(num==112)return 8;
if(num==113)return 9;
// else return 0;
}
ci nx[5]={0,-1,1,0,0};//sxzy
ci ny[5]={0,0,0,-1,1};
int n,field[10005][10005];
int level;
string name;
bool getpalse(){
int typeU;
fstream file;
file.open("palseZ.dll", ios::in);
streambuf* stream_buffer_cout = cout.rdbuf();
streambuf* stream_buffer_cin = cin.rdbuf();
streambuf* stream_buffer_file = file.rdbuf();
cin.rdbuf(stream_buffer_file);
cin>>typeU;
cin.rdbuf(stream_buffer_cin);
file.close();
if(typeU==1){
fstream file;
file.open("palseF.dll", ios::in);
streambuf* stream_buffer_cout = cout.rdbuf();
streambuf* stream_buffer_cin = cin.rdbuf();
streambuf* stream_buffer_file = file.rdbuf();
cin.rdbuf(stream_buffer_file);
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>field[i][j];
}
}
cin.rdbuf(stream_buffer_cin);
file.close();
return true;
}
return false;
}
void putpalse(){
fstream file;
file.open("palseZ.dll", ios::out);
streambuf* stream_buffer_cout = cout.rdbuf();
streambuf* stream_buffer_cin = cin.rdbuf();
streambuf* stream_buffer_file = file.rdbuf();
cout.rdbuf(stream_buffer_file);
system("cls");
cout<<1;
cout.rdbuf(stream_buffer_cout);
file.close();
if(1==1){
fstream file;
file.open("palseF.dll", ios::out);
streambuf* stream_buffer_cout = cout.rdbuf();
streambuf* stream_buffer_cin = cin.rdbuf();
streambuf* stream_buffer_file = file.rdbuf();
cout.rdbuf(stream_buffer_file);
system("cls");
cout<<n<<endl;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cout<<field[i][j]<<" ";
}
cout<<endl;
}
cout.rdbuf(stream_buffer_cout);
file.close();
}
}
void maken(){
putlevel(0);
level=getlevel();
printf("正在初始化……\n");
Sleep(1000);
printf("设定您的用户名\n");
string UserNameSET;
getline(cin,UserNameSET);
putuser(UserNameSET);
printf("即将完成……");
Sleep(100);
system("cls");
Sleep(100);
}
void start(){
system("color F0");
printf("请稍后……\n");
level=getlevel();
system("cls");
printf(" 撞Fufu \n\n\n\n\n\n\n\n\n\n 欢迎\n");
if(level==-1){
maken();
}
printf(" 欢迎");
level=getlevel();
name=getuser();
cout<<name<<endl;
Sleep(2000);
"MB_OK";
}
int tr,kd;
int game(){
//move
int fx=n-1,fy=n-1,hx=2,hy=2;
while(true){
if(fx==hx&&fy==hy){
putlevel(level+1);
system("cls");
printf("游戏结束,恭喜!胜利!成功晋级!\n继续游戏?[继续:q / 离开:Enter]\n");
int r=check(keyboard());
if(r==9)return 1;
else return 0;
}
system("cls");
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(field[i][j]==0)cout<<" ";
if(field[i][j]==1)cout<<"-";
if(field[i][j]==2)cout<<"|";
if(field[i][j]==5)cout<<"H";
if(field[i][j]==6)cout<<"F";
}
cout<<endl;
}
printf("\n使用“上下左右”按键以控制小人,按下R键重新开始,按下P键保存缓存\n");
int r=check(keyboard());
if(r==224)continue;
cout<<r;
Sleep(1000);
if(r==7){
system("cls");
return 1;
}
if(r==8){
system("cls");
putpalse();
printf("缓存加载完毕,再见\n");
Sleep(2000);
exit(1);
}
if(r>0&&r<5){
//move
system("cls");
if(hx+nx[r]<=1||hx+nx[r]>=n||hy+ny[r]<=1||hy+ny[r]>=n){
printf("ERR-ID:出界\n");
continue;
}
cout<<hx<<hy<<endl;
hx=hx+nx[r];
hy=hy+ny[r];
if(field[hx][hy]==0){
field[hx][hy]=5;
field[hx-nx[r]][hy-ny[r]]=0;
}
printf("成功\n");
Sleep(1);
cout<<hx<<hy<<endl;
Sleep(5000);
}
}
}
void start_game(){
system("cls");
cout<<"@"<<endl;
if(level<=10){
n=10,tr=24,kd=40;
}
else if(level<=20){
n=12,tr=34,kd=66;
}
else if(level>20){
n=15,tr=50,kd=119;
}
/*
0:_
1:-
2:|
5:H
6:F
*/
field[1][1]=field[n][n]=1;
field[1][n]=field[n][1]=1;
for(int i=2;i<=n-1;i++){
field[1][i]=field[n][i]=1;
field[i][1]=field[i][n]=2;
}
for(int i=2;i<=n-1;i++){
for(int j=2;j<=n-1;j++){
while(true){
int k=r(2);
// if(k==1&&tr>0){
// int l=r(2)+1;
// field[i][j]=l;
// tr--;
// break;
// }
if(k==0&&kd>0){
// kd--;
break;
}
}
}
}cout<<"@"<<endl;
field[2][2]=5,field[n-1][n-1]=6;
if(game()==1)start_game();
}
void findpalse(){
if(getpalse()){
game();
}
else{
start_game();
}
}
int main(){
start();
Sleep(1);
findpalse();
}