1.仿generals
复制代码
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597/* 源自generals.io 大洋彼岸的服务器体验极差! 使用说明 整合了零人、单人、双人版 单人版&&通用规则 图片:https://www.picb.cc/image/tAJbks和https://www.picb.cc/image/tAJ7Nj 先输入0/1/2,代表游戏人数 然后要输入一个随机数种子(更新:长度可以任意),相同种子(相同编译器?)生成相同地图 地图:X为障碍,黑色背景的数为原有城市,红色为玩家的,蓝色为电脑的,城市和普通地面颜色不同 数字表示:数大于99时只显示最高位和一个字母 (e代表100,k代表1000,w代表10000),数大于99999就显示"ju" (巨) 在屏幕左下角可以看到光标所指的数的精确值(hp) 光标是一个小于号"<",用方向键控制光标 按下w/s/a/d时,光标的左边那个数(前提是自己的)会随光标移动 按下z,再按w/s/a/d,光标的左边那个数(前提是自己的)的一半会随光标移动 无法移动的情况:遇到障碍/下一个位置上的数不是自己的,且>=自己的数-1 时间以回合(count)为单位,在屏幕左下角 移动光标不算回合,移动数字算,按到空格键视作放弃一回合 城市每回合+2,其余被占领的地面每10回合+1 屏幕左下角的"army"指一方数字和,"land"指一方占领的格子数 零人版 两个一样的bfs算法对打 只要观战就可以啦 可以按方向键移动光标,但不能移动任何数 按下空格键进入下一回合 如果想快点看到结果,按f键,之后无法移动光标 双人版 红方键盘:(z/x+) w/s/a/d,默认只移动光标,按z移一半数,按x移全部 蓝方键盘:(n/m+) 方向键,默认只移动光标,按n移一半数,按m移全部 任何一方按空格可以放弃一回合 游戏时间会很漫长 地图有概率出现“封城”,城市也可能分布不公平,换一个种子重启(继续碰运气)即可 当一方操作结束,光标会移到地图的左上角或右下角,(希望)能方便操作 结束条件:占领所有主塔(最开始的塔再【1】【1】或【n】【n]) */ #include<iostream> #include<cstdio> #include<fstream> #include<algorithm> #include<cmath> #include<deque> #include<vector> #include<queue> #include<string> #include<cstring> #include<map> #include<stack> #include<set> #include<windows.h> #include<conio.h> #include<ctime> using namespace std; const int cA=5;//red城市 const int cB=3;//blue城市 const int ca=4;//red地面 const int cb=1;//blue地面 const int cC=0;//black原有城市 const int msize=16;//地图大小 const int mount=16;//障碍数量 const int grey=16;//城市数量 const int pmain=2;//城市hp每回合增加量 const int lcnt=10;//地面hp增加1所需回合 char cMap[msize][msize];//大写字母表示城市,小写表示地面,Aa是红,Bb是蓝,C是白,X是障碍 int hp[msize][msize]; int nCount,sx,sy;//回合累加,和光标的坐标 bool bVis[msize][msize];//bfs int dir[4][2]={1,0,-1,0,0,1,0,-1};//bfs struct dRet//决策信息:位置为(x,y)的数移到(x+dx,y+dy) { int x; int y; int dx; int dy; }; struct node//bfs { int x; int y; int step; }; void vInit();//生成地图 void vMove(int dx,int dy);//移动光标 //以下5个函数,保证A=='A'||A=='B' void vMoveNum(int dx,int dy,char A); void vMoveNum(int x,int y,int dx,int dy,char A); void vDiv(int dx,int dy,char A); void vDecide(char A); dRet bfs(int x,int y,char A); void vPlus();//每回合数值增加,计算army和land void vChange(int x,int y);//刷新屏幕上指定坐标的数 void gotoxy(int x,int y);//移动输出的位置 void color(int t,int b);//设置输出颜色,t为文字色,b为背景色 void vMain0(); void vMain1(); void vMain2(); void vEnd();//判断游戏结束 int main() { int p; cout<<"player:"<<endl; cin>>p; system("cls"); if(p==0) vMain0(); if(p==1) vMain1(); if(p==2) vMain2(); return 0; } void vMain0() { int in; bool cur=true; vInit(); for(nCount=0;;nCount++) { gotoxy(msize,0); color(15,0); cout<<"count="<<nCount<<endl; if(cur) { do { in=getch(); if(in==224) { in=getch(); if(in==72) vMove(-1,0); if(in==80) vMove(1,0); if(in==75) vMove(0,-1); if(in==77) vMove(0,1); } }while(in!=' '&&in!='f'); if(in=='f') cur=false; } vDecide('A'); vDecide('B'); vPlus(); } } void vMain1() { int in; vInit(); for(nCount=0;;nCount++) { gotoxy(msize,0); color(15,0); cout<<"count="<<nCount<<endl; do { in=getch(); if(in==224) { in=getch(); if(in==72) vMove(-1,0); if(in==80) vMove(1,0); if(in==75) vMove(0,-1); if(in==77) vMove(0,1); } }while(in!='w'&&in!='s'&&in!='a'&&in!='d'&&in!='z'&&in!=' '); if(in=='w') vMoveNum(-1,0,'A'); if(in=='s') vMoveNum(1,0,'A'); if(in=='a') vMoveNum(0,-1,'A'); if(in=='d') vMoveNum(0,1,'A'); if(in=='z') { in=getch(); if(in=='w') vDiv(-1,0,'A'); if(in=='s') vDiv(1,0,'A'); if(in=='a') vDiv(0,-1,'A'); if(in=='d') vDiv(0,1,'A'); } vDecide('B'); vPlus(); } } void vMain2() { int in; vInit(); for(nCount=0;;nCount++) { gotoxy(msize,0); color(15,0); cout<<"count="<<nCount; vMove(-sx,-sy); gotoxy(msize+1,0); cout<<"red "; do { in=getch(); if(in=='w') vMove(-1,0); if(in=='s') vMove(1,0); if(in=='a') vMove(0,-1); if(in=='d') vMove(0,1); }while(in!='x'&&in!='z'&&in!=' '); if(in=='x') { in=getch(); if(in=='w') vMoveNum(-1,0,'A'); if(in=='s') vMoveNum(1,0,'A'); if(in=='a') vMoveNum(0,-1,'A'); if(in=='d') vMoveNum(0,1,'A'); } else if(in=='z') { in=getch(); if(in=='w') vDiv(-1,0,'A'); if(in=='s') vDiv(1,0,'A'); if(in=='a') vDiv(0,-1,'A'); if(in=='d') vDiv(0,1,'A'); } vEnd(); vMove(msize-1-sx,msize-1-sy); gotoxy(msize+1,0); color(15,0); cout<<"blue"; do { in=getch(); if(in==224) { in=getch(); if(in==72) vMove(-1,0); if(in==80) vMove(1,0); if(in==75) vMove(0,-1); if(in==77) vMove(0,1); } }while(in!='n'&&in!='m'&&in!=' '); if(in=='m') { in=getch(); if(in==224) { in=getch(); if(in==72) vMoveNum(-1,0,'B'); if(in==80) vMoveNum(1,0,'B'); if(in==75) vMoveNum(0,-1,'B'); if(in==77) vMoveNum(0,1,'B'); } } else if(in=='n') { in=getch(); if(in==224) { in=getch(); if(in==72) vDiv(-1,0,'B'); if(in==80) vDiv(1,0,'B'); if(in==75) vDiv(0,-1,'B'); if(in==77) vDiv(0,1,'B'); } } vPlus(); } } void vInit() { int i,j,x,y; string sSeed; unsigned int sd=20190622; cout<<"seed:"<<endl; cin>>sSeed; system("cls"); for(i=0;i<sSeed.size();i++) sd=sd*233+sSeed[i]; srand(sd); cMap[0][0]='A'; hp[0][0]=pmain; vChange(0,0); cMap[msize-1][msize-1]='B'; hp[msize-1][msize-1]=pmain; vChange(msize-1,msize-1); for(i=1;i<=mount;i++) { x=rand()%msize; y=rand()%msize; if(cMap[x][y]!=0) i--; else { cMap[x][y]='X'; gotoxy(x,y*3); color(15,0); cout<<" X"; } } for(i=1;i<=grey;i++) { x=rand()%msize; y=rand()%msize; if(cMap[x][y]!=0) i--; else { cMap[x][y]='C'; hp[x][y]=40+rand()%10; vChange(x,y); } } sx=sy=0; gotoxy(0,2); color(15,0); cout<<"<"; } void vMove(int dx,int dy) { color(15,0); dx+=sx;dy+=sy; if(!(dx>=0&&dx<msize&&dy>=0&&dy<msize)) return; gotoxy(sx,sy*3+2); cout<<" "; sx=dx;sy=dy; gotoxy(sx,sy*3+2); cout<<"<"; gotoxy(msize+1,0); cout<<"cMap="<<cMap[dx][dy]<<",hp="<<hp[dx][dy]<<" "; } void vMoveNum(int x,int y,int dx,int dy,char A) { char a,B,b; a=A-'A'+'a'; B=(A=='A')?'B':'A'; b=B-'A'+'a'; if(cMap[x][y]!=a&&cMap[x][y]!=A) return; dx+=x;dy+=y; if(!(dx>=0&&dx<msize&&dy>=0&&dy<msize&&cMap[dx][dy]!='X')) return; char &cd=cMap[dx][dy]; int &hd=hp[dx][dy],&hs=hp[x][y]; if(cd!=a&&cd!=A&&hd>=hs-1) return; if(cd==0) { cd=a; hd=hs-1; } else if(cd==A||cd==a) { hd+=hs-1; } else if(cd==B||cd==b) { if(B=='B') cd--; else cd++; hd=hs-1-hd; } else//'C' { cd=A; hd=hs-1-hd; } hs=1; vChange(dx,dy); vChange(x,y); } void vMoveNum(int dx,int dy,char A) { vMoveNum(sx,sy,dx,dy,A); vMove(dx,dy); } void vDiv(int dx,int dy,char A) { char a,B,b; a=A-'A'+'a'; B=(A=='A')?'B':'A'; b=B-'A'+'a'; if(cMap[sx][sy]!=a&&cMap[sx][sy]!=A) return; dx+=sx;dy+=sy; if(!(dx>=0&&dx<msize&&dy>=0&&dy<msize&&cMap[dx][dy]!='X')) return; char &cd=cMap[dx][dy]; int &hd=hp[dx][dy],&hs=hp[sx][sy],tmp=hs/2; if(tmp==0) return; if(cd!=a&&cd!=A&&hd>=tmp-1) return; if(cd==0) { cd=a; hd=tmp; } else if(cd==A||cd==a) { hd+=tmp; } else if(cd==B||cd==b) { if(B=='B') cd--; else cd++; hd=tmp-hd; } else//'C' { cd=A; hd=tmp-hd; } hs-=tmp; vChange(dx,dy); vChange(sx,sy); vMove(dx-sx,dy-sy); } void vDecide(char A) { char a,B,b; a=A-'A'+'a'; B=(A=='A')?'B':'A'; b=B-'A'+'a'; int i,j,k,x,y,dx,dy; dRet tmp,res; bool bd=false,bm=false; for(i=(A=='A')?0:(msize-1);(A=='A')?(i<=msize-1):(i>=0);(A=='A')?(i++):(i--)) { for(j=(A=='A')?0:(msize-1);(A=='A')?(j<=msize-1):(j>=0);(A=='A')?(j++):(j--)) { if(!bd&&(cMap[i][j]==B||cMap[i][j]=='C')) { tmp=bfs(i,j,A); if(tmp.dx+tmp.dy==0) continue; bd=true; res=tmp; } if(!bd&&!bm&&(cMap[i][j]==A||cMap[i][j]==a)&&hp[i][j]>1) { for(k=0;k<4;k++) { dx=dir[k][0]+i; dy=dir[k][1]+j; if(!(dx>=0&&dx<msize&&dy>=0&&dy<msize)) continue; if((cMap[dx][dy]==0||cMap[dx][dy]==b)&&hp[dx][dy]<hp[i][j]-1) { bm=true; res.dx=dir[k][0]; res.dy=dir[k][1]; res.x=i; res.y=j; break; } } } if(bd) break; } if(bd) break; } if(!bd&&!bm) return; vMoveNum(res.x,res.y,res.dx,res.dy,A); } dRet bfs(int x,int y,char A) { char a,B,b; a=A-'A'+'a'; B=(A=='A')?'B':'A'; b=B-'A'+'a'; int i,dx,dy; dRet ret; node now,nxt; queue<node>q; now.step=hp[x][y]+2; now.x=x; now.y=y; q.push(now); memset(bVis,false,sizeof bVis); bVis[x][y]=true; while(!q.empty()) { now=q.front(); q.pop(); for(i=0;i<4;i++) { dx=dir[i][0]+now.x; dy=dir[i][1]+now.y; if(dx>=0&&dx<msize&&dy>=0&&dy<msize&&!bVis[dx][dy]&&cMap[dx][dy]!='X') { bVis[dx][dy]=true; if(cMap[dx][dy]==0) nxt.step=now.step+1; if(cMap[dx][dy]==b||cMap[dx][dy]==B||cMap[dx][dy]=='C') nxt.step=now.step+hp[dx][dy]+2; else { nxt.step=now.step-hp[dx][dy]+1; if(nxt.step<-5&&(cMap[dx][dy]==A||cMap[dx][dy]==a)) { ret.dx=-dir[i][0]; ret.dy=-dir[i][1]; ret.x=dx; ret.y=dy; return ret; } } nxt.x=dx; nxt.y=dy; q.push(nxt); } } } ret.dx=ret.dy=0; return ret; } void vPlus() { int i,j,aa=0,ba=0,al=0,bl=0; if(nCount%lcnt==0) { for(i=0;i<msize;i++) { for(j=0;j<msize;j++) { if(cMap[i][j]=='a'||cMap[i][j]=='b') { hp[i][j]++; vChange(i,j); } } } } for(i=0;i<msize;i++) { for(j=0;j<msize;j++) { if(cMap[i][j]=='A'||cMap[i][j]=='B') { hp[i][j]+=pmain; vChange(i,j); } if(cMap[i][j]=='A'||cMap[i][j]=='a') al++,aa+=hp[i][j]; if(cMap[i][j]=='B'||cMap[i][j]=='b') bl++,ba+=hp[i][j]; } } color(15,0); gotoxy(msize+2,0); cout<<"red army:"<<aa<<" "<<endl; cout<<"red land:"<<al<<" "<<endl; cout<<"blue army:"<<ba<<" "<<endl; cout<<"blue land:"<<bl<<" "<<endl; vEnd(); } void vEnd() { if(cMap[0][0]=='B') { cout<<"blue win"<<endl; while(1); } if(cMap[msize-1][msize-1]=='A') { cout<<"red win"<<endl; while(1); } } void vChange(int x,int y) { int c; char cm=cMap[x][y]; if(cm=='A') c=cA; if(cm=='a') c=ca; if(cm=='B') c=cB; if(cm=='b') c=cb; if(cm=='C') c=cC; gotoxy(x,y*3); color(15,c); int val=hp[x][y]; if(val<10) cout<<" "<<val; else if(val<100) cout<<val; else if(val<1000) cout<<val/100<<"e"; else if(val<10000) cout<<val/1000<<"k"; else if(val<100000) cout<<val/10000<<"w"; else cout<<"ju"; } void gotoxy(int x,int y) { COORD c; c.X=y; c.Y=x; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c); } void color(int t,int b) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),t+b*16); }
2.连连看(有点难操作)
复制代码
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595#include <iostream> #include <windows.h> #include <cstdio> #include <conio.h> #include <cstring> using namespace std; void block(int x,int y){ HANDLE hCon; hCon = GetStdHandle(STD_OUTPUT_HANDLE); COORD setps; setps.X = x; setps.Y = y; SetConsoleCursorPosition(hCon,setps); } void color(int a){ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a); } void HideCursor(){ CONSOLE_CURSOR_INFO cursor_info = {1, 0}; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info); } int mo = 0, n = 0, zx = 1, zy = 1, zz = 0, z1 = 1, m = 0; int dis[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}}; int co[10] = {0, 12, 14, 11, 10, 13}; int ca[10][10]; int a[10][10]; bool yin[10]; int guan[20][15] = {{0}, {4, 1, 5, 2, 5, 2, 3, 2, 4}, {5, 1, 5, 2, 4, 3, 2, 4, 2}, {3, 1, 4, 4, 2, 3, 3}, {5, 1, 3, 2, 5, 3, 5}, {3, 1, 1, 1, 1, 1, 3}, {5, 1, 5, 2, 4, 3, 3}, {4, 1, 2, 4, 3, 1, 4, 1, 1}, {5, 2, 3, 2, 5, 1, 3, 3, 5}, {4, 1, 4, 5, 3, 5, 3, 1, 3}, {5, 1, 3, 1, 4, 5, 3, 5, 2} }; void mem(){ n = 0; zx = 1; zy = 1; zz = 0; z1 = 1; m = 0; memset(a, 0, sizeof(a)); memset(a, 0, sizeof(ca)); } bool in(int x, int y){ return 0 < x && x <= n && 0 < y && y <= n; } bool zou(int zi, int zj, int zti, int ztj){ for(int i = 0; i < 4; i++){ int zzx = zi + dis[i][0]; int zzy = zj + dis[i][1]; if(in(zzx, zzy)){ if(a[zzx][zzy] == a[zti][ztj] && !(zzx == zti && zzy == ztj)){ return true; }else{ if(a[zi][zj] < 99){ if(a[zzx][zzy] == a[zi][zj] * 100 + 1){ if(zou(zzx, zzy, zti, ztj)){ return true; } } }else{ if(a[zzx][zzy] == a[zi][zj] + 1){ if(zou(zzx, zzy, zti, ztj)){ return true; } } } } } } return false; } bool ying(){ for(int i = 1; i <= m; i++){ yin[i] = false; } for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(a[i][j] == 0){ return false; }else if(a[i][j] < 99){ if(zou(i, j, i, j)){ yin[a[i][j]] = true; } } } } for(int i = 1; i <= m; i++){ if(yin[i] == false){ return false; } } return true; } void nuo(){ if(zz > 0){ if(z1 == 1){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(a[i][j] / 100 == zz){ a[i][j] = 0; } } } } if(a[zx][zy] > 99){ if(a[zx][zy] / 100 == zz){ int z2 = a[zx][zy] % 100; for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(a[i][j] / 100 == a[zx][zy] / 100 && a[i][j] % 100 > z2){ a[i][j] = 0; } } } z1 = z2 + 1; }else{ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(a[i][j] / 100 == a[zx][zy] / 100 && !(i == zx && j == zy)){ a[i][j] = 0; } } } a[zx][zy] = zz * 100 + z1; z1++; } }else if(a[zx][zy] > 0){ z1 = 1; zz = 0; }else{ a[zx][zy] = zz * 100 + z1; z1++; } } } void output(){ block(0, 0); color(15); cout << "当前状态:"; if(zz == 0){ cout << "松开"; }else{ cout << "按下"; } if(mo == 1){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(a[i][j] != ca[i][j] || zx == i && zy == j){ block(j * 2, i + 1); if(a[i][j] > 99){ if(zx == i && zy == j){ color(co[a[i][j] / 100] * 16 + 15); if(zz > 0){ cout << "┼"; }else{ int z1z = 0, z2z = 0; for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] + 1){ z1z = k + 1; break; } } } p1:if(z1z == 0){ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] / 100){ z1z = k + 1; break; } } } if(z1z == 0){ cout << "┼"; }else{ goto p1; } }else{ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] - 1){ z2z = k + 1; break; } } } if(z2z == 0){ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] / 100){ z2z = k + 1; break; } } } } if(z1z == 1){ if(z2z == 2){cout << "┌";}else if(z2z == 3){cout << "└";}else if(z2z == 4){cout << "─";} }else if(z1z == 2){ if(z2z == 1){cout << "┌";}else if(z2z == 3){cout << "│";}else if(z2z == 4){cout << "┐";} }else if(z1z == 3){ if(z2z == 1){cout << "└";}else if(z2z == 2){cout << "│";}else if(z2z == 4){cout << "┘";} }else if(z1z == 4){ if(z2z == 1){cout << "─";}else if(z2z == 2){cout << "┐";}else if(z2z == 3){cout << "┘";} } } } }else{ color(co[a[i][j] / 100]); int z1z = 0, z2z = 0; for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] + 1){ z1z = k + 1; break; } } } p2:if(z1z == 0){ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] / 100){ z1z = k + 1; break; } } } if(z1z == 0){ cout << "┼"; }else{ goto p2; } }else{ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] - 1){ z2z = k + 1; break; } } } if(z2z == 0){ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] / 100){ z2z = k + 1; break; } } } } if(z1z == 1){ if(z2z == 2){cout << "┌";}else if(z2z == 3){cout << "└";}else if(z2z == 4){cout << "─";} }else if(z1z == 2){ if(z2z == 1){cout << "┌";}else if(z2z == 3){cout << "│";}else if(z2z == 4){cout << "┐";} }else if(z1z == 3){ if(z2z == 1){cout << "└";}else if(z2z == 2){cout << "│";}else if(z2z == 4){cout << "┘";} }else if(z1z == 4){ if(z2z == 1){cout << "─";}else if(z2z == 2){cout << "┐";}else if(z2z == 3){cout << "┘";} } } } }else if(a[i][j] > 0){ if(zx == i && zy == j){ color(co[a[i][j]] * 16 + 15); }else{ color(co[a[i][j]]); } cout << "■"; }else{ color(15); if(zx == i && zy == j){ cout << "┼"; }else{ cout << " "; } } } if(zx == i && zy == j){ ca[i][j] = -1; }else{ ca[i][j] = a[i][j]; } } } }else{ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(a[i][j] != ca[i][j]){ block(j, i + 1); if(a[i][j] > 99){ if(zx == i && zy == j){ color(co[a[i][j] / 100] * 16 + 15); if(zz > 0){ cout << "┼"; }else{ int z1z = 0, z2z = 0; for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] + 1){ z1z = k + 1; break; } } } p3:if(z1z == 0){ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] / 100){ z1z = k + 1; break; } } } if(z1z == 0){ cout << "┼"; }else{ goto p3; } }else{ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] - 1){ z2z = k + 1; break; } } } if(z2z == 0){ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] / 100){ z2z = k + 1; break; } } } } if(z1z == 1){ if(z2z == 2){cout << "┌";}else if(z2z == 3){cout << "└";}else if(z2z == 4){cout << "─";} }else if(z1z == 2){ if(z2z == 1){cout << "┌";}else if(z2z == 3){cout << "│";}else if(z2z == 4){cout << "┐";} }else if(z1z == 3){ if(z2z == 1){cout << "└";}else if(z2z == 2){cout << "│";}else if(z2z == 4){cout << "┘";} }else if(z1z == 4){ if(z2z == 1){cout << "─";}else if(z2z == 2){cout << "┐";}else if(z2z == 3){cout << "┘";} } } } }else{ color(co[a[i][j] / 100]); int z1z = 0, z2z = 0; for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] + 1){ z1z = k + 1; break; } } } p4:if(z1z == 0){ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] / 100){ z1z = k + 1; break; } } } if(z1z == 0){ cout << "┼"; }else{ goto p4; } }else{ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] - 1){ z2z = k + 1; break; } } } if(z2z == 0){ for(int k = 0; k < 4; k++){ int zzi = i + dis[k][0]; int zzj = j + dis[k][1]; if(in(zzi, zzj)){ if(a[zzi][zzj] == a[i][j] / 100){ z2z = k + 1; break; } } } } if(z1z == 1){ if(z2z == 2){cout << "┌";}else if(z2z == 3){cout << "└";}else if(z2z == 4){cout << "─";} }else if(z1z == 2){ if(z2z == 1){cout << "┌";}else if(z2z == 3){cout << "│";}else if(z2z == 4){cout << "┐";} }else if(z1z == 3){ if(z2z == 1){cout << "└";}else if(z2z == 2){cout << "│";}else if(z2z == 4){cout << "┘";} }else if(z1z == 4){ if(z2z == 1){cout << "─";}else if(z2z == 2){cout << "┐";}else if(z2z == 3){cout << "┘";} } } } }else if(a[i][j] > 0){ if(zx == i && zy == j){ color(co[a[i][j]] * 16 + 15); }else{ color(co[a[i][j]]); } cout << "■"; }else{ color(15); if(zx == i && zy == j){ cout << "┼"; }else{ cout << " "; } } } if(zx == i && zy == j){ ca[i][j] = -1; }else{ ca[i][j] = a[i][j]; } } } } } /*void output1(){ block(0, 7); for(int i = 1; i <= n; i++){ cout << " "; cout << endl; } block(0, 7); for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ cout << a[i][j] << " "; } cout << endl; } }*/ int main( ){ HideCursor(); color(15 * 16); system("mode con lines=5 cols=42"); cout << " 欢迎来到*杨柳白皮*的连连看!" << endl; Sleep(500); cout << " F键打开个人主页" << endl << " "; char zzz1 = getch(); if(zzz1 == 'F' || zzz1 == 'f'){ system("start https://www.luogu.com.cn/user/359425"); } Sleep(500); system("pause"); system("cls"); Sleep(200); cout << " 请选择合适的输出格式——" << endl; Sleep(750); cout << " 1.高配版-1" << endl; Sleep(200); cout << " 2.高配版-2" << endl; Sleep(200); p_1:char zzz2 = getch(); if(zzz2 >= '1' && zzz2 <= '2'){ mo = zzz2 - '0'; }else{ goto p_1; } cout << zzz2; p_3:Sleep(500); mem(); color(15); system("mode con cols=25 lines=10"); Sleep(500); cout << "游戏开始!" << endl; Sleep(750); cout << "请选择关卡(1~5):"; p_2:char zzz3 = getch(); if(zzz3 >= '1' && zzz3 <= '5'){ cout << zzz3 << endl; Sleep(500); }else{ goto p_2; } int zzz4 = zzz3 - '0'; cout << "加载中";Sleep(200);cout << "▁";Sleep(200);cout << "▂";Sleep(200);cout << "▃";Sleep(200);cout << "▅";Sleep(200);cout << "▆";Sleep(200);cout << "▇"; Sleep(750); m = guan[zzz4 * 2 - 1][0]; for(int i = 1; i <= guan[zzz4 * 2 - 1][0]; i++){ a[guan[zzz4 * 2 - 1][i * 2 - 1]][guan[zzz4 * 2][i * 2 - 1]] = i; a[guan[zzz4 * 2 - 1][i * 2]][guan[zzz4 * 2][i * 2]] = i; } n = guan[zzz4 * 2][0]; cout << endl << "加载成功!"; Sleep(250); system("cls"); while(true){ output(); //output1(); if(ying()){ break; } char zz1 = getch(); if(zz1 == 'w'){ if(in(zx - 1, zy)){ zx--; } nuo(); }else if(zz1 == 's'){ if(in(zx + 1, zy)){ zx++; } nuo(); }else if(zz1 == 'a'){ if(in(zx, zy - 1)){ zy--; } nuo(); }else if(zz1 == 'd'){ if(in(zx, zy + 1)){ zy++; } nuo(); }else if(zz1 == ' '){ if(a[zx][zy] > 0 && a[zx][zy] <= 9){ if(zz == 0){ z1 = 1; zz = a[zx][zy]; }else{ zz = 0; } }else if(a[zx][zy] > 99){ if(zz == 0){ z1 = a[zx][zy] % 100 + 1; zz = a[zx][zy] / 100; }else{ zz = 0; } } } Sleep(20); } color(15); Sleep(750); system("cls"); block(0, 0); cout << "第" << zzz3 << "关挑战成功!" << endl; Sleep(1500); system("pause"); goto p_3; return 0; }
3.秘境
复制代码
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809//秘境测试版 1.4.1 鼠标系统加入+Bug更新! #include<bits/stdc++.h> #include<windows.h> #define HD 30 using namespace std; typedef BOOL (WINAPI *PROCSETCONSOLEFONT)(HANDLE, DWORD); PROCSETCONSOLEFONT SetConsoleFont; POINT Windowpos(){ POINT pt; GetCursorPos(&pt); HWND h=GetForegroundWindow(); ScreenToClient(h,&pt); pt.x/=8; pt.y/=16; return pt; } void SetPos(int y,int x){ COORD pos; pos.X=x,pos.Y=y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos); } HANDLE hann=GetStdHandle(-11); void hide(){ CONSOLE_CURSOR_INFO cursor; cursor.bVisible=0; cursor.dwSize=1; SetConsoleCursorInfo(hann,&cursor); } int hp=100,bsd=100,water=100,nl=100; bool han=0;// 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 string name[100]={"0","木条","木板","石头","碎石","平滑石","捕鱼笼","捕兽夹","苹果","浆果","毛皮","生肉","熟肉","木桶","装有水的木桶","船","火把","藤蔓","弓","石剑","地图碎片","地图","磁石","指南针","石斧","生鱼","熟鱼","金币","铁锭","金锭","茅草"}; int hand[100]; int num[100]; / int pasture;//是否探索到打草场 1探索到了 0没有探索到 int pasture_time=10; int YNpasture;//pasture_time:草的状态pasture_time>=10时草成熟 YNpasture:草是否种植1种植了0没种植 / int animal;//是否探索到野兽小径 1探索到了 0没有探索到 / int berry;//是否探索到浆果地 1探索到了 0没有探索到 int berry_time=10; int YNberry;//berry_time:浆果的状态berry_time>=10时浆果成熟 YNberry:浆果是否种植1种植了0没种植 / int brook;//是否探索到小溪 1探索到了 0没探索到 int fcageplace;//捕鱼笼数量(已放置) int acageplace;//捕兽夹数量(已放置) int YNcatchfish;//是否捕到鱼(大于等于10时,每个捕鱼笼有几率获得3~6条鱼) int YNcatchanimal;//是否捕到野兽(大于等于20时,每个捕鱼笼有几率获得3~5块肉) / int fire=0;//火焰旺度,0为没有火焰 int YNrainy;//是否下雨 int YNenergy=1;//这一步是否消耗能量 int YNfloorwet=0;//地面是否为湿(可用茅草吸干) / void print(char a[]); void juqing(); void login(); void home(); void bag(); void table(); void gotable(); void goberry(); void gopasture(); void gobrook(); void goanimal(); void main_menu(); void aboutus(); void create(); bool ctrlmouse(int,int,int,int); void fileout(); void init(); // int main(){ init(); home(); return 0; } void print(char a[]){ for(int i=0;i<strlen(a);i++){ Sleep(10); cout<<a[i]; } cout<<endl; } void home(){ int time=0;//当前时间 while(1){ YNenergy=0; if(time%24==0){ int YNrainyrand=rand()%4+1; if(YNrainyrand==1) YNfloorwet=YNrainy=1; else YNfloorwet=YNrainy=0; } time++; Refreshmain: system("cls"); cout<<"现在是"; if((time/12)%2==0)cout<<"白天"; else cout<<"黑夜"; if(YNrainy==1) cout<<"/雨天"; else cout<<"/晴天"; cout<<"/"<<time%24<<"时"; if((time%24)/4==0) cout<<"/清晨"<<endl; if((time%24)/4==1) cout<<"/中午"<<endl; if((time%24)/4==2) cout<<"/黄昏"<<endl; if((time%24)/4==3) cout<<"/傍晚"<<endl; if((time%24)/4==4) cout<<"/午夜"<<endl; if((time%24)/4==5 || (time%24)/4==6) cout<<"/凌晨"<<endl; cout<<"这是你被困在这里的第"<<time/24+1<<"天......"<<endl; cout<<"-------------------------------------------"<<endl; cout<<"血量:"<<hp<<" "<<"饱食度:"<<bsd<<" "<<"口渴度:"<<water<<" "<<"耐力:"<<nl<<endl; if(berry_time>=10 && berry==1) cout<<"浆果已成熟!"<<endl; if(YNcatchfish>=10 && brook==1) cout<<"捕鱼笼已捕到鱼!"<<endl; if(YNcatchanimal>=20 && animal==1) cout<<"捕兽夹已捕到猎物!"<<endl; if(pasture_time>=10 && pasture==1) cout<<"可以打草!"<<endl; if(YNfloorwet==1){ fire=0; cout<<"在陆地上生不了火(收集20个茅草以吸干雨水)"<<endl; } if(fire>1) cout<<"火堆熊熊燃烧"<<endl; if(fire==1) cout<<"火堆燃烧着"<<endl; if(bsd<=50) cout<<"你感到很饿"<<endl; if(water<=50)cout<<"你感到很渴"<<endl; if(nl<=50) cout<<"你感到你需要休息一下"<<endl; cout<<"-------------------------------------------"<<endl; if(rand()%5+1==1 && (hand[1]>=10 || hand[3]>=8 || hand[11]>=5 || hand[9]>=7 || hand[25]>=5)){ while(1){ int sjrand=rand()%5+1,sjnum; if(sjrand==1 && hand[1]>=10){ sjnum=rand()%8+1; cout<<"一只猴子从你的手中拿走了"<<sjnum<<"根木条"<<endl; hand[1]-=sjnum; break; } if(sjrand==2 && hand[3]>=8){ sjnum=rand()%4+1; cout<<"一只猴子从你的手中拿走了"<<sjnum<<"个石头"<<endl; hand[3]-=sjnum; break; } if(sjrand==3 && hand[11]>=5){ sjnum=rand()%3+1; cout<<"一条狗从你的手中叼走了"<<sjnum<<"块生肉"<<endl; hand[11]-=sjnum; break; } if(sjrand==4 && hand[9]>=7){ sjnum=rand()%4+1; cout<<"一条狐狸从你的手中衔走了"<<sjnum<<"个浆果"<<endl; hand[9]-=sjnum; break; } if(sjrand==5 && hand[25]>=5){ sjnum=rand()%3+1; cout<<"一只猫从你的手中叼走了"<<sjnum<<"条鱼"<<endl; hand[25]-=sjnum; break; } } }else{ cout<<"无事件发生"<<endl; } if(han){ int YNitems=0; cout<<"-------------------------------------------"<<endl; printf("你拿出了:n"); for(int i=1;i<=HD;i++){ if(hand[i]>0){ cout<<name[i]<<"X"<<hand[i]<<" "; YNitems++; } if(YNitems%4==0)cout<<endl; } cout<<endl; } cout<<"-------------------------------------------"<<endl; cout<<"游戏选项:"<<endl; if(han) cout<<"1 放回背包"<<endl; cout<<"2 背包"<<endl; if(nl>=15) cout<<"3 收集"<<endl; if(nl>=10) cout<<"4 探索"<<endl; if(nl<100) cout<<"5 休息"<<endl; if((time/12)%2!=0 && fire) cout<<"6 睡觉"<<endl; cout<<"7 查看合成表"<<endl; if(nl>=10 && hand[1]>=8 && fire==0 && YNfloorwet==0) cout<<"8 钻木取火"<<endl; if(hand[1]>=2 && fire && YNfloorwet==0) cout<<"9 加柴火"<<endl; if(hand[3]>=1 && nl>=10) cout<<"a 将石头摔成碎石"<<endl; if(nl>=5 && brook) cout<<"b 前往小溪"<<endl; if(nl>=5 && berry) cout<<"c 前往浆果地"<<endl; cout<<"d 前往合成"<<endl; if(hand[3]>=1 && fire) cout<<"e 将石头烤成平滑石"<<endl; if(hand[9]>=1) cout<<"f 食用浆果"<<endl; if(hand[25]>=1 && fire) cout<<"j 将生鱼烤成熟鱼"<<endl; if(hand[26]>=1) cout<<"h 吃熟鱼"<<endl; if(hand[12]>=15 && hand[16]>=50 && nl>=30) cout<<"i 挖矿(花费15块熟肉,50根火把)"<<endl; if(animal==1 && nl>=5) cout<<"j 前往野兽小径"<<endl; if(hand[11]>=1 && fire) cout<<"k 将生肉烤成熟肉"<<endl; if(hand[12]>=1) cout<<"l 吃熟肉"<<endl; if(hand[1]>=10 && fire) cout<<"m 点燃10根木条做成2根火把"<<endl; if(nl>=5 && pasture) cout<<"n 前往打草场"<<endl; if(hand[30]>=20 && nl>=5 && YNfloorwet==1) cout<<"o 吸干雨水"<<endl; SetPos(0,47);//行(y)为2,列(x)为5 cout<<"Main_menu|ESC"; SetPos(1,51); cout<<"用鼠标点!"; int YNpressthekey=1; while(YNpressthekey){ if(ctrlmouse(0,0,47,55)){main_menu();goto Refreshmain;} if(ctrlmouse(0,0,57,59)){system("cls");return;} int t; if(GetAsyncKeyState(49)&0x8000 && han){ for(int i=1;i<=HD;i++) num[i]+=hand[i],hand[i]=0; han=0; YNpressthekey=0; }else if(GetAsyncKeyState(50)&0x8000){ bag(); YNpressthekey=0; }else if(GetAsyncKeyState(51)&0x8000 && nl>=15){ system("cls"); print("你到森林里收集了一点木条和石头"); num[1]+=rand()%10+1; num[3]+=rand()%3+2; nl-=15; YNenergy=1; system("pause"); YNpressthekey=0; }else if(GetAsyncKeyState(52)&0x8000 && nl>=10){ system("cls"); int YNtsrand=rand()%4+1; if(YNtsrand==1){ int tsrand=rand()%4+1; if(tsrand==1 && berry==0){ print("你发现了一片浆果地"); berry=1; system("pause"); }else if(tsrand==2 && brook==0){ print("你发现了一条小溪"); brook=1; system("pause"); }else if(tsrand==3 && animal==0){ print("你发现了一条野兽小径"); animal=1; system("pause"); }else if(tsrand==4 && pasture==0){ print("你发现了一个打草场"); pasture=1; system("pause"); } }else{ print("你什么也没探索到"); system("pause"); } nl-=10; YNenergy=1; YNpressthekey=0; }else if(GetAsyncKeyState(53)&0x8000 && nl<100){ system("cls"); cout<<"休息中"<<endl; Sleep(1000); cout<<"耐力+5"<<endl; nl+=5; if(nl>=100) nl=100; system("pause"); YNpressthekey=0; }else if(GetAsyncKeyState(54)&0x8000 && (time/12)%2!=0 && fire){ system("cls"); cout<<"z";Sleep(1000);cout<<"z";Sleep(1000);cout<<"z";Sleep(1000); system("cls"); cout<<"z";Sleep(1000);cout<<"z";Sleep(1000);cout<<"z";Sleep(1000); time=0; nl=100; YNpressthekey=0; }else if(GetAsyncKeyState(55)&0x8000){ table(); YNpressthekey=0; }else if(GetAsyncKeyState(56)&0x8000 && nl>=10 && hand[1]>=8 && fire==0 && YNfloorwet==0){ nl-=10; system("cls"); hand[1]-=8; fire++; print("火堆燃烧起来了"); YNenergy=1; system("pause"); YNpressthekey=0; }else if(GetAsyncKeyState(57)&0x8000 && hand[1]>=2 && fire && YNfloorwet==0){ system("cls"); hand[1]-=2; fire++; print("火堆熊熊燃烧"); system("pause"); YNpressthekey=0; }else if(GetAsyncKeyState(65)&0x8000 && hand[3]>=1 && nl>=10){ nl-=10; hand[3]--; hand[4]+=rand()%3+1; YNenergy=1; YNpressthekey=0; }else if(GetAsyncKeyState(66)&0x8000 && nl>=5 && brook){ gobrook(); nl-=5; YNenergy=1; YNpressthekey=0; }else if(GetAsyncKeyState(67)&0x8000 && nl>=5 && berry){ goberry(); nl-=5; YNenergy=1; YNpressthekey=0; }else if(GetAsyncKeyState(68)&0x8000){ gotable(); YNpressthekey=0; }else if(GetAsyncKeyState(69)&0x8000 && hand[3]>=1 && fire){ system("cls"); print("烧烤中"); Sleep(1000); hand[3]--; hand[5]++; YNpressthekey=0; }else if(GetAsyncKeyState(70)&0x8000 && hand[9]>=1){ hand[9]--; water+=5; bsd+=5; if(water>100) water=100; if(bsd>100) bsd=100; YNpressthekey=0; }else if(GetAsyncKeyState(71)&0x8000 && hand[25]>=1 && fire){ system("cls"); print("烧烤中"); Sleep(1000); hand[25]--; hand[26]++; YNpressthekey=0; }else if(GetAsyncKeyState(72)&0x8000 && hand[26]>=1){ hand[26]--; bsd+=8; if(bsd>=100) bsd=100; YNpressthekey=0; }else if(GetAsyncKeyState(73)&0x8000 && hand[12]>=15 && hand[16]>=50 && nl>=30){ hand[12]-=15; hand[16]-=50; nl-=30; system("cls"); print("挖掘中"); Sleep(3000); hand[28]+=rand()%10+5; hand[29]+=rand()%5+3; YNpressthekey=0; }else if(GetAsyncKeyState(74)&0x8000 && animal && nl>=5){ goanimal(); nl-=5; YNenergy=1; YNpressthekey=0; }else if(GetAsyncKeyState(75)&0x8000 && hand[11]>=1 && fire){ system("cls"); print("烧烤中"); Sleep(1000); hand[11]--; hand[12]++; YNpressthekey=0; }else if(GetAsyncKeyState(76)&0x8000 && hand[12]>=1){ hand[12]--; bsd+=12; if(bsd>=100) bsd=100; YNpressthekey=0; }else if(GetAsyncKeyState(77)&0x8000 && hand[1]>=10 && fire){ system("cls"); print("点燃中"); Sleep(1000); hand[16]+=2; hand[1]-=10; YNpressthekey=0; }else if(GetAsyncKeyState(78)&0x8000 && nl>=5 && pasture){ gopasture(); nl-=5; YNenergy=1; YNpressthekey=0; }else if(GetAsyncKeyState(79)&0x8000 && nl>=5 && hand[30]>=20 && YNfloorwet==1){ nl-=5; hand[30]-=30; YNfloorwet=0; YNenergy=1; YNpressthekey=0; } } if(fcageplace>0) YNcatchfish++; if(acageplace>0) YNcatchanimal++; if(YNberry==1) berry_time++; if(YNpasture==1) pasture_time++; if(YNenergy==1) bsd--,water--; han=0;for(int i=1;i<=HD;i++){if(hand[i]!=0){han=1;break;}} if(hp<=0||bsd<=0||water<=0)break; } if(hp<=0||bsd<=0||water<=0){ system("cls"); print("你死了......"); Sleep(3000); print("我就说没有人能活下来,呵呵......"); Sleep(3000); system("cls"); print("GAME OVER"); Sleep(5000); return; }else{ system("cls"); print("你居然活了下来,呵呵......"); Sleep(3000); system("cls"); print("GAME OVER"); Sleep(5000); } } void bag(){ int YNitems=0; system("cls"); while(1){ system("cls"); cout<<"0 返回|g a b 丢弃编号为a的物品b件|p a b拿出编号为a的物品b件"<<endl; for(int i=1;i<=HD;i++){ if(num[i]>0){ cout<<i<<":"<<name[i]<<"X"<<num[i]<<" "; YNitems++; } if(YNitems%4==0)cout<<endl; } cout<<endl; char a[2]; scanf("%s",a); if(a[0]=='0')return; else if(a[0]=='g'){ int x,y; scanf("%d%d",&x,&y); if(num[x]>=y)num[x]-=y; } else{ han=1; int x,y; scanf("%d%d",&x,&y); if(num[x]>=y){ hand[x]+=y; num[x]-=y; } } } login(); } void juqing(){ system("cls"); print("冒险者站在夕阳下"); Sleep(1000); print("他知道"); Sleep(1000); print("这不是他的传说"); Sleep(1000); system("cls"); print("没人离开过这里......"); Sleep(1000); print("我这是在哪儿?"); Sleep(1000); print("一阵头痛袭来"); Sleep(1000); print("我好像,什么也不记得了......"); Sleep(1000); } void table(){ system("cls"); print("20个木条 5个平滑石 10个碎石 3个浆果 5个石头 合成 1个捕兽夹"); print("15个木条 3个石头 3个平滑石 2个浆果 20个碎石 合成 1个捕鱼笼"); print("20个木条 合成 4个木板"); print("6个木板 合成 1个木桶"); print("5个金锭 合成 10枚金币"); system("pause"); } void gobrook(){ system("cls"); printf("哗哗哗"); Sleep(1000); while(1){ system("cls"); print("0 返回"); print("1. 喝水(回复10口渴度)"); if(hand[6]>=1 && fcageplace<10) print("2. 放置捕鱼笼"); if(fcageplace>=1 && YNcatchfish>=10) print("3. 查看捕鱼笼"); if(hand[13]>=1) print("4. 用木桶舀水"); /// int brookt; scanf("%d",&brookt); if(brookt==0){ return; } if(brookt==1){ system("cls"); printf("咕嘟嘟"); Sleep(1000); water+=10; if(water>100){ system("cls"); printf("口渴度满了n"); water=100; system("pause"); } } // if(brookt==2){ system("cls"); if(hand[6]>=1 && fcageplace<10){ hand[6]--; fcageplace++; }else if(hand[6]<1){ system("cls"); print("你还没有捕鱼笼!"); system("pause"); }else if(fcageplace==10){ system("cls"); print("捕鱼笼已满!"); system("pause"); } } if(brookt==3){ system("cls"); if(fcageplace>=1 && YNcatchfish>=10){ hand[25]+=fcageplace*(rand()%2+1); YNcatchfish=0; }else if(fcageplace<1){ system("cls"); print("你还未放置捕鱼笼!"); system("pause"); }else if(YNcatchfish<10){ system("cls"); print("捕鱼笼没有捕到东西!"); system("pause"); } } if(brookt==4){ system("cls"); if(hand[13]>=1){ hand[13]--; hand[14]++; print("咕噜噜"); Sleep(1000); system("pause"); }else{ print("你还没有木桶"); system("pause"); } } } } void gotable(){ while(1){ system("cls"); print("0. 返回"); if(hand[1]>=20 && hand[5]>=5 && hand[4]>=10 && hand[9]>=3 && hand[3]>=5){ print("1. 合成捕兽夹"); } if(hand[1]>=15 && hand[3]>=3 && hand[5]>=3 && hand[9]>=2 && hand[4]>=20){ print("2. 合成捕鱼笼"); } if(hand[1]>=20){ print("3. 合成木板"); } if(hand[2]>=6){ print("4. 合成木桶"); } if(hand[29]>=5){ print("5. 合成金币(5个金锭/10个金币)"); } int tablet; scanf("%d",&tablet); if(tablet==0){ return; }if(tablet==1){ if(hand[1]>=20 && hand[5]>=5 && hand[4]>=10 && hand[9]>=3 && hand[3]>=5){ hand[1]-=20; hand[5]-=5; hand[4]-=10; hand[9]-=3; hand[3]-=5; hand[7]++; }else{ system("cls"); print("材料不足!"); system("pause"); } } if(tablet==2){ if(hand[1]>=15 && hand[3]>=3 && hand[5]>=3 && hand[9]>=2 && hand[4]>=20){ hand[1]-=15; hand[3]-=3; hand[5]-=3; hand[9]-=2; hand[4]-=20; hand[6]++; }else{ system("cls"); print("材料不足!"); system("pause"); } } if(tablet==3){ if(hand[1]>=20){ hand[1]-=20; hand[2]+=5; }else{ system("cls"); print("材料不足!"); system("pause"); } } if(tablet==4){ if(hand[2]>=6){ hand[2]-=6; hand[13]+=1; }else{ system("cls"); print("材料不足"); system("pause"); } } if(tablet==5){ if(hand[29]>=5){ hand[29]-=5; hand[27]+=10; }else{ system("cls"); print("材料不足"); system("pause"); } } } } void gopasture(){ while(1){ system("cls"); print("0. 返回"); if(pasture_time>=10) print("1. 打草"); if(YNpasture==0 && hand[30]>=5) print("2. 种草(花费5个茅草)"); int pasturet; scanf("%d",&pasturet); if(pasturet==0){ return; } if(pasturet==1){ if(pasturet==1 && pasture_time>=10){ hand[30]+=rand()%4+10; han=1; YNpasture=0; pasture_time=0; }else{ system("cls"); print("已经打过草了!"); system("pause"); } }else if(pasturet==2){ if(pasturet==2 && YNpasture==0 && hand[30]>=5){ YNpasture=1; hand[30]-=5; }else if(YNpasture==1){ system("cls"); print("草已经种植过了!"); system("pause"); }else if(hand[30]<5){ print("茅草不够!"); } } } } void goberry(){ while(1){ system("cls"); print("0. 返回"); if(berry_time>=10) print("1. 采集浆果"); if(YNberry==0 && hand[9]>=5) print("2. 种植浆果(花费5个浆果)"); int berryt; scanf("%d",&berryt); if(berryt==0){ return; } if(berryt==1){ if(berryt==1 && berry_time>=10){ hand[9]+=rand()%4+7; han=1; YNberry=0; berry_time=0; }else{ system("cls"); print("浆果地已经采集过了!"); system("pause"); } }else if(berryt==2){ if(berryt==2 && YNberry==0 && hand[9]>=5){ YNberry=1; hand[9]-=5; }else if(YNberry==1){ system("cls"); print("浆果地已经种植过了!"); system("pause"); }else if(hand[9]<5){ print("浆果不够!"); } } } } void goanimal(){ while(1){ system("cls"); print("0. 返回"); if(hand[7]>=1 && acageplace<10) print("1. 放置捕兽夹"); if(acageplace>=1 && YNcatchanimal>=20) print("2. 查看捕兽夹"); int animalt; scanf("%d",&animalt); if(animalt==0){ return; } / if(animalt==1){ system("cls"); if(acageplace==10){ system("cls"); print("捕兽夹已满!"); system("pause"); }else if(hand[7]>=1 && acageplace<10){ hand[7]--; acageplace++; }else if(hand[7]<1){ system("cls"); print("你还没有捕兽夹!"); system("pause"); } } if(animalt==2){ system("cls"); if(acageplace>=1 && YNcatchanimal>=20){ hand[11]+=acageplace*(rand()%2+2); YNcatchanimal=0; }else if(acageplace<1){ system("cls"); print("你还未放置捕兽夹!"); system("pause"); }else if(YNcatchanimal<20){ system("cls"); print("捕兽夹没有捕到东西!"); system("pause"); } } } } void create(){ han=1; berry=brook=animal=pasture=1; for(int i=1;i<=HD;i++) hand[i]=num[i]=0; for(int i=1;i<=HD;i++) hand[i]=1000; system("cls"); cout<<"已成功开启"<<endl; system("pause"); } bool ctrlmouse(int cmaa,int cmbb,int cmcc,int cmdd){ int mouse; mouse=GetAsyncKeyState(VK_LBUTTON)&0x8000; POINT pt=Windowpos(); for(int i=cmaa;i<=cmbb;i++) for(int j=cmcc;j<=cmdd;j++) if(pt.y==i && pt.x==j && mouse) return true; return false; } void main_menu(){ backmain: system("cls"); SetPos(0,26);cout<<"About_us"; SetPos(1,26);cout<<"开启创造"; SetPos(2,28);cout<<"返回"; while(1){ if(ctrlmouse(0,0,26,33)){aboutus();goto backmain;} if(ctrlmouse(1,1,26,33)){create();goto backmain;} if(ctrlmouse(2,2,28,31)) return; } } void aboutus(){ system("cls"); while(1){ SetPos(0,0); cout<<"秘境"<<endl; cout<<"开始构建于2020年"<<endl; cout<<"一个休闲游戏,是冒险者的传说的后一部"<<endl; cout<<"由 Beep_Monkey , ForeverCC 出品(点击人名进入luogu主页)"<<endl; if(ctrlmouse(3,3,3,13)){system("start www.luogu.com.cn/user/251779");} if(ctrlmouse(3,3,17,25)){system("start www.luogu.com.cn/user/189163");} cout<<"返回"<<endl; if(ctrlmouse(4,4,0,3)){return;} } return; } void init(){ hide(); srand(time(NULL)); system("color 0E"); system("title 秘境"); system("MODE CON COLS=30 LINES=10"); srand(time(NULL)); cout<<"剧情?输入1:n"; int juqingt; cin>>juqingt; if(juqingt==1)juqing(); system("cls"); print("Beep_Monkey , ForeverCC 出品"); system("pause"); system("MODE CON COLS=60 LINES=40"); return; }
4.数字华容道
复制代码
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#include <bits/stdc++.h> #include <windows.h> #include <conio.h> using namespace std; int num[10005]={0}; int n,p[105][105],x,y,sum; bool iswin(){ int f=1; for(int i=1;i<=n-1;i++){ for(int j=1;j<=n;j++){ if(p[i][j]!=f)return false; f++; } } for(int j=1;j<=n-1;j++){ if(p[n][j]!=f)return false; f++; } return true; } int main(){ srand(time(NULL)); cout<<"Welcome to play n-puzzle!Make sure that you're using Windows System..."<<endl; cout<<"Please input the length:"; cin>>n; x=rand()%n+1; y=rand()%n+1; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==x && j==y)continue; int k=rand()%(n*n-1)+1; while(num[k])k=rand()%(n*n-1)+1; p[i][j]=k; num[k]=1; } } for(int i=1;i<=n*n;i++)num[i]=0; while(!iswin()){ char a; system("cls"); cout<<"---------------------------------"<<endl; cout<<" You have been moved "<<sum<<" steps."<<endl; cout<<" Move: W A S D Restart: R "<<endl; cout<<"---------------------------------"<<endl; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==x && j==y)printf("%-5c",'*'); else printf("%-5d",p[i][j]); } cout<<endl; } a=getch(); if(a=='w' || a=='W'){ if(x!=n){ p[x][y]=p[x+1][y]; x++; } } if(a=='s' || a=='S'){ if(x!=1){ p[x][y]=p[x-1][y]; x--; } } if(a=='a' || a=='A'){ if(y!=n){ p[x][y]=p[x][y+1]; y++; } } if(a=='d' || a=='D'){ if(y!=1){ p[x][y]=p[x][y-1]; y--; } } if(a=='r' || a=='R'){ x=rand()%n+1; y=rand()%n+1; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==x && j==y)continue; int k=rand()%(n*n-1)+1; while(num[k])k=rand()%(n*n-1)+1; p[i][j]=k; num[k]=1; } } for(int i=1;i<=n*n;i++)num[i]=0; sum=0; } sum++; } system("cls"); cout<<"*-----------------*"<<endl; printf("| Total:%-5d |n",sum); cout<<"| You Win! |"<<endl; cout<<"*-----------------*"<<endl; return 0; }
最后
以上就是无辜板栗最近收集整理的关于C++游戏天堂——经典型(2)的全部内容,更多相关C++游戏天堂——经典型(2)内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复