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
| #include<bits/stdc++.h> #include<windows.h> #include<conio.h> #define sleep(a) Sleep((a)*1000) using namespace std; char b; bool a[9][9][4]={true,false}; int f,ti,ti2,guanshu=1,tgs,fs,i,j; FILE *fin,*fout; int main();
void sr(){ fin=fopen("cd.cd","rb"); fscanf(fin,"%d%d%d",&guanshu,&f,&tgs); fclose(fin); } void cd(){ fout=fopen("cd.cd","wb"); fprintf(fout,"%d\n%d\n%d",guanshu,f,tgs); fclose(fout); } void kfz(){ system("CLS"); qqqq:printf("你已进入开发者模式\n请选择你要进行的操作\n"); printf("a.cmd\nb.电脑关机\nc.退出程序\nd.修改分数\ne.退出开发者模式\nf.清屏\ng.修改天个数\n"); scanf("%c",&b); if(b=='a'){ system("CLS"); system("cmd"); } else if(b=='b'){ cd(); system("shutdown -s -t 10 -c 电脑炸了"); } else if(b=='c'){ exit(0); } else if(b=='d'){ system("CLS"); printf("请输入修改后的分数(0-10分第一关,11-20分第二关……)\n"); scanf("%d",&fs); f=fs; return; } else if(b=='e'){ return; } else if(b=='f'){ for(int i=0;i<9;i++){ for(int j=0;j<9;j++){ a[i][j][2]=false; } } return; } else if(b=='g'){ system("cls"); scanf("%d",&tgs); return; } else{ system("CLS"); printf("请输入规定字母"); sleep(3); goto qqqq; } } void dy(){ system("CLS"); printf("wasd移动,按e退出,按q清理你所在位置所在行\n"); for(int i=0;i<9;i++){ for(int j=0;j<9;j++){ if(a[i][j][0]){ if(a[i][j][1]){ f++; cd(); a[i][j][1]=false; } printf("你"); } else if(a[i][j][2]) printf("墙"); else if(a[i][j][1]) printf("币"); else if(a[i][j][3]) printf("天"); else if(!(a[i][j][0])&&!(a[i][j][1])&&!(a[i][j][2])&&!(a[i][j][3])) printf(" "); } printf("|\n"); } for(int i=0;i<18;i++) printf("-"); printf("┘\n当前分数:%d分\n运行时间:%d秒\n天个数:%d\n版本号:2.1.3",f,clock()/CLOCKS_PER_SEC,tgs); } void xunhuan(int fenshu){ while(f<=fenshu){ if(kbhit()!=0){ b=getch(); if(b=='T'){ kfz(); } if(b=='w'){ if(i>0&&!a[i-1][j][2]){ a[i][j][0]=false; i-=1; a[i][j][0]=true; system("CLS"); dy(); } } if(b=='s'&&!a[i+1][j][2]){ if(i<8){ a[i][j][0]=false; i+=1; a[i][j][0]=true; system("CLS"); dy(); } } if(b=='d'&&!a[i][j+1][2]){ if(j<8){ a[i][j][0]=false; j+=1; a[i][j][0]=true; system("CLS"); dy(); } } if(b=='a'&&!a[i][j-1][2]){ if(j>0){ a[i][j][0]=false; j-=1; a[i][j][0]=true; system("CLS"); dy(); } } if(b=='e'){ exit(0); } if(a[i][j][3]){ tgs++; a[i][j][3]=false; } if(b=='q'){ for(int I=0;I<9;I++){ a[I][j][2]=false; } for(int J=0;J<9;J++){ a[i][J][2]=false; } dy(); tgs--; } } if(clock()/CLOCKS_PER_SEC-ti2>=1){ system("CLS"); dy(); ti2=clock()/CLOCKS_PER_SEC; if(clock()/CLOCKS_PER_SEC-ti>=3){ aa:ti=clock()/CLOCKS_PER_SEC; srand(rand()); int q=rand()%9; srand(rand()); int w=rand()%9; if((!a[q][w][2])&&(!a[q][w][1])) a[q][w][1]=true; else goto aa; } } } } void dinguan(int n) { if(n>3){ qweqwe:srand(rand()); int q=rand()%9; srand(rand()); int w=rand()%9; if((!a[q][w][2])&&(!a[q][w][1])) a[q][w][3]=true; else goto qweqwe; } for(int i=0;i<5*n;i++){ srand(rand()); if(!(a[rand()%9][rand()%9][2])) a[rand()%9][rand()%9][2]=true; } system("CLS"); dy(); xunhuan(10*n); } int main(){ printf("欢迎进入由细淘开发的细天游戏\n"); Sleep(500); sr(); for(;;guanshu++){ cd(); sr(); system("CLS"); printf("进入第%d关",guanshu); sleep(2); dinguan(guanshu); } return 0; }
|