c++_坦克大战1.0
目前还有两个功能未开发完 — 待续
附上代码:
#include<windows.h>
#include<conio.h>
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<string>
#include<fstream>
using namespace std;
SYSTEMTIME sys;
int checkpoint,time,time2,times,times2;
int e[20]={1,2,3,4,6,8,10,12,15,18,21,24,28,32,37,42,48,55,65,76};
int e2[20]={100,95,80,76,72,68,64,61,58,55,52,47,43,39,34,30,24,18,15,10};
bool equipment[2][10];
double equipment_health[2][10];
struct tank{
int x,y,d,color,shells_number;
int interval[2];
}I_tank;
struct bullet{
int x,y,d,color;
bool fire;
}shells[100];
struct enemy{
int x,y,d,j,color;
bool go;
}enemies[7];
char checkpoint_name[6][4][8]={
{"Leve 01","Leve 02","Leve 03","Leve 04"},
{"Leve 05","Leve 06","Leve 07","Leve 08"},
{"Leve 09","Leve 10","Leve 11","Leve 12"},
{"Leve 13","Leve 14","Leve 15","Leve 16"},
{"Leve 17","Leve 18","Leve 19","Leve 20"},
{" color "," store "," 关于 "," 退出 "}
};
bool er[29][29]={
{1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,0,1,1,1,1,1,1,1},
{1,0,0,0,0,0,1,0,1,0,1,1,1,1,1,1,0,0,1,1,0,0,1,0,0,0,0,0,1},
{1,0,1,1,1,0,1,0,0,1,0,1,0,0,1,1,0,0,0,1,0,0,1,0,1,1,1,0,1},
{1,0,1,1,1,0,1,0,1,0,0,1,1,1,0,1,0,1,1,0,0,0,1,0,1,1,1,0,1},
{1,0,1,1,1,0,1,0,1,0,1,1,0,1,1,0,0,0,1,1,1,0,1,0,1,1,1,0,1},
{1,0,0,0,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,1},
{1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1},
{0,0,0,0,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
{0,1,0,1,1,1,1,0,1,1,0,1,1,0,1,1,0,0,0,1,0,1,1,0,1,1,0,1,0},
{0,1,0,0,1,0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,0,1,1,1,0},
{1,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,1,0,1,1,0,0,1,0,0},
{0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0,1,1,1,1,1,0,0,0,1,0,0,1},
{0,0,1,1,0,0,1,0,0,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,1,0},
{0,0,0,1,0,1,0,1,1,0,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1},
{1,0,0,1,0,0,1,0,1,1,0,0,1,1,0,1,1,0,1,1,0,1,1,0,0,1,0,0,1},
{1,1,0,0,0,1,0,0,0,1,1,0,1,1,0,1,0,0,0,1,1,1,1,0,0,1,1,1,0},
{0,1,1,0,1,1,1,0,0,1,0,1,0,0,0,1,0,1,1,0,0,1,0,1,1,1,0,0,0},
{1,1,1,0,0,0,0,1,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,1,1,1,0,0,0},
{1,1,0,1,0,1,1,1,0,0,1,1,0,1,1,0,1,0,1,1,0,0,0,0,0,0,1,0,1},
{1,1,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,0,0,1,1,1,1,0,0,0,1,1,0},
{1,1,0,0,0,0,1,1,1,1,0,1,1,1,0,0,1,1,0,1,1,1,1,1,1,1,1,0,1},
{0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0},
{1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,1,1,0,0,1,1,0,1,0,1,0,1,1,0},
{1,0,0,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,1,1,0,0,0,1,1,0,1,0},
{1,0,1,1,1,0,1,0,1,0,1,1,1,1,0,0,0,1,0,1,1,1,1,1,1,0,0,1,1},
{1,0,1,1,1,0,1,0,1,0,1,1,0,1,1,0,0,1,1,0,1,1,0,1,0,0,0,1,0},
{1,0,1,1,1,0,1,0,0,0,1,1,1,1,0,1,0,1,0,1,0,0,0,0,1,1,0,1,1},
{1,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,1,0,1,0,1,1,0,0,1,1,1,0,1},
{1,1,1,1,1,1,1,0,0,1,1,1,0,0,0,1,0,0,1,1,0,1,1,1,1,0,1,0,0}
};
int ccs[20]={10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10};
bool boss[20]={1};
int score;
void I_tank_color();
void enter();
void main_interface(int x,int y);
void Generate_enemy(int i);
void score_g();
void game_over();
void I_tank_mobile(int k);
void shells_fire(int x,int y,int d,int c);
void shells_mobile();
void tank_according(int x,int y,int d,int tank_color);
void tank_clean(int x,int y,int d);
void gotoxy(int x,int y);
void color(int a);
void Initialize();
void Initialize2();
void Initialization_fence();
void fighting();
void store();
void print(char a[],int b);
void cursor(bool a);
void cursor(bool a){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
CursorInfo.bVisible = a;
SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
}
void cundang(){
ofstream cd("cundang.exe");
cd<<true<<endl;
for(int i=0;i<20;i++)cd<<boss[i]<<" ";
cd<<endl;
cd<<I_tank.color<<endl;
for(int l=0;l<2;l++){
for(int i=0;i<20;i++){
cd<<equipment[l][i]<<" ";
cd<<equipment_health[l][i]*1000000<<" ";
}
cd<<endl;
}
cd.close();
SetFileAttributes("cundang.exe",FILE_ATTRIBUTE_HIDDEN );
}
void activity(){
system("cls");
system("color f0");
gotoxy(2,0);
printf("\t\t参与彼岸工作室附加活动:");
for(int i=0;i<29;i++){
gotoxy(2,i+2);
for(int l=0;l<29;l++){
if(er[i][l])color(0);
else color(511);
printf("■");
}
if(i==5) {color(496);printf(" 手");}
if(i==10){color(496);printf(" 机");}
if(i==15){color(496);printf(" 扫");}
if(i==20){color(496);printf(" 一");}
if(i==25){color(496);printf(" 扫");}
}
gotoxy(2,33);
color(496);
printf("\t\t\t光盘行动推动者");
char x;
scanf("%c",&x);
Sleep(3000);
}
void print(char a[],int b){
int s=strlen(a);
for(int i=0;i<s;i++){
printf("%c",a[i]);
Sleep(b);
}
}
void score_g(){
gotoxy(0,0);
color(7);
printf("score:%d/%d",score,ccs[checkpoint]);
gotoxy(10,0);
printf("shells:%d",I_tank.shells_number);
gotoxy(20,0);
int temp=sys.wSecond-time;
int temp2=sys.wMinute-time2;
if(temp<0){
temp=60+temp;
temp2--;
}
printf("存活时间:%d分%d秒\t",times2,times);
gotoxy(40,0);
printf("awsd移动 k发炮 ");
printf("Level %d j暂停\t\t\t",checkpoint+1);
}
void game_over(){
gotoxy(32,21);
color(7);
printf("Game Over!");
gotoxy(32,22);
printf("Score:%d",score);
gotoxy(31,23);
printf("存活时间:%d分%d秒\t",times2,times);
if(ccs[checkpoint]<=score){
MessageBox(NULL,"恭喜你通关了","通关!",MB_OK+48);
boss[checkpoint+1]=1;
cundang();
}else{
MessageBox(NULL,"很遗憾,失败!\n","失败!",MB_OK+16);
gotoxy(31,24);
cout<<ccs[checkpoint]<<"分通关!\n";
}
Sleep(1000);
getch();
if(rand()%5==rand()%5){
if(MessageBox(NULL,"参与彼岸工作室附加活动:\n光盘行动推动者","活动",MB_OKCANCEL+64)==1)activity();
}
main_interface(checkpoint%4,checkpoint/4);
}
void tank_clean(int x,int y,int d){
color(0);
switch(d){
case 0:
gotoxy(x+1,y);
printf("■");
gotoxy(x,y+1);
printf("■■■");
gotoxy(x,y+2);
printf("■■■");
break;
case 1:
gotoxy(x,y);
printf("■■");
gotoxy(x,y+1);
printf("■■■");
gotoxy(x,y+2);
printf("■■");
break;
case 2:
gotoxy(x,y);
printf("■■■");
gotoxy(x,y+1);
printf("■■■");
gotoxy(x+1,y+2);
printf("■");
break;
case 3:
gotoxy(x+1,y);
printf("■■");
gotoxy(x,y+1);
printf("■■■");
gotoxy(x+1,y+2);
printf("■■");
break;
}
color(7);
}
void tank_according(int x,int y,int d,int tank_color){
color(tank_color);
switch(d){
case 0:
gotoxy(x+1,y);
printf("■");
gotoxy(x,y+1);
printf("■■■");
gotoxy(x,y+2);
printf("■■■");
color(7);
break;
case 1:
gotoxy(x,y);
printf("■■");
gotoxy(x,y+1);
printf("■■■");
gotoxy(x,y+2);
printf("■■");
color(7);
break;
case 2:
gotoxy(x,y);
printf("■■■");
gotoxy(x,y+1);
printf("■■■");
gotoxy(x+1,y+2);
printf("■");
color(7);
break;
case 3:
gotoxy(x+1,y);
printf("■■");
gotoxy(x,y+1);
printf("■■■");
gotoxy(x+1,y+2);
printf("■■");
color(7);
break;
}
}
void I_tank_mobile(char k){
tank_clean(I_tank.x,I_tank.y,I_tank.d);
switch(k){
case 'W':
case 'w':
if(I_tank.d!=0)I_tank.d=0;
if(I_tank.y>1) I_tank.y--;
break;
case 'S':
case 's':
if(I_tank.d!=2)I_tank.d=2;
if(I_tank.y<40)I_tank.y++;
break;
case 'A':
case 'a':
if(I_tank.d!=3)I_tank.d=3;
if(I_tank.x>0) I_tank.x--;
break;
case 'D':
case 'd':
if(I_tank.d!=1)I_tank.d=1;
if(I_tank.x<72)I_tank.x++;
break;
case 'K':
case 'k':
if(I_tank.shells_number>0){
if(I_tank.d==0&&I_tank.y>1){shells_fire(I_tank.x+1,I_tank.y-1,I_tank.d,7);I_tank.shells_number--;}
else if(I_tank.d==1&&I_tank.x<72){shells_fire(I_tank.x+3,I_tank.y+1,I_tank.d,7);I_tank.shells_number--;}
else if(I_tank.d==2&&I_tank.y<40){shells_fire(I_tank.x+1,I_tank.y+3,I_tank.d,7);I_tank.shells_number--;}
else if(I_tank.d==3&&I_tank.x>0){shells_fire(I_tank.x-1,I_tank.y+1,I_tank.d,7);I_tank.shells_number--;}
score_g();
}
break;
}
tank_according(I_tank.x,I_tank.y,I_tank.d,I_tank.color);
}
void gotoxy(int x,int y){//位置函数
COORD pos;
pos.X=2*x;
pos.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void color(int a){//颜色函数
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
void Initialize(){
system("color f0");
RECT rect;
HWND hwnd=GetForegroundWindow();
GetWindowRect(hwnd,&rect);
MoveWindow(hwnd,0,0,rect.right-rect.left,rect.bottom-rect.top,TRUE);
system("mode con cols=90 lines=30");
}
void Initialize2(){
system("color f0");
RECT rect;
HWND hwnd=GetForegroundWindow();
GetWindowRect(hwnd,&rect);
MoveWindow(hwnd,0,0,rect.right-rect.left,rect.bottom-rect.top,TRUE);
system("mode con cols=150 lines=51");
}
void Initialization_fence(){
color(0);
for(int i = 0;i < 43;i++){
gotoxy(0,i);
printf("■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■");
}
}
void shells_fire(int x,int y,int d,int c){
for(int i = 0;i < 100;i++){
if(!shells[i].fire){
shells[i].color=c;
color(shells[i].color);
gotoxy(x,y);
printf("●");
shells[i].d=d;
shells[i].x=x;
shells[i].y=y;
shells[i].fire=1;
break;
}
}
}
void shells_mobile(){
for(int i = 0;i < 100;i++){
if(shells[i].fire){
gotoxy(shells[i].x,shells[i].y);
color(0);
printf("●");
if(shells[i].d==0) shells[i].y--;
if(shells[i].d==1) shells[i].x++;
if(shells[i].d==2) shells[i].y++;
if(shells[i].d==3) shells[i].x--;
if(shells[i].x<0||shells[i].y<1||shells[i].y>42||shells[i].x>74){
shells[i].fire=0;
if(shells[i].color==7)I_tank.shells_number++;
score_g();
continue;
}
gotoxy(shells[i].x,shells[i].y);
color(shells[i].color);
printf("●");
if(shells[i].color==7){
for(int l=0;l<7;l++){
if(enemies[l].go){
if(enemies[l].d==0)
if((enemies[l].x+1==shells[i].x&&enemies[l].y==shells[i].y)||(enemies[l].x==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x+1==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x+2==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x==shells[i].x&&enemies[l].y+2==shells[i].y)||(enemies[l].x+1==shells[i].x&&enemies[l].y+2==shells[i].y)||(enemies[l].x+2==shells[i].x&&enemies[l].y+2==shells[i].y)){
shells[i].fire=0;
enemies[l].go=0;
tank_clean(enemies[l].x,enemies[l].y,enemies[l].d);
gotoxy(shells[i].x,shells[i].y);
color(0);
printf("●");
score++;
I_tank.shells_number++;
score_g();
break;
}
if(enemies[l].d==1)
if((enemies[l].x==shells[i].x&&enemies[l].y==shells[i].y)||(enemies[l].x+1==shells[i].x&&enemies[l].y==shells[i].y)||(enemies[l].x==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x+1==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x+2==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x==shells[i].x&&enemies[l].y+2==shells[i].y)||(enemies[l].x+1==shells[i].x&&enemies[l].y+2==shells[i].y)){
shells[i].fire=0;
enemies[l].go=0;
tank_clean(enemies[l].x,enemies[l].y,enemies[l].d);
gotoxy(shells[i].x,shells[i].y);
color(0);
printf("●");
score++;
I_tank.shells_number++;
score_g();
break;
}
if(enemies[l].d==2)
if((enemies[l].x==shells[i].x&&enemies[l].y==shells[i].y)||(enemies[l].x+1==shells[i].x&&enemies[l].y==shells[i].y)||(enemies[l].x+2==shells[i].x&&enemies[l].y==shells[i].y)||(enemies[l].x==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x+1==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x+2==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x+1==shells[i].x&&enemies[l].y+2==shells[i].y)){
shells[i].fire=0;
enemies[l].go=0;
tank_clean(enemies[l].x,enemies[l].y,enemies[l].d);
gotoxy(shells[i].x,shells[i].y);
color(0);
printf("●");
score++;
I_tank.shells_number++;
score_g();
break;
}
if(enemies[l].d==3)
if((enemies[l].x+1==shells[i].x&&enemies[l].y==shells[i].y)||(enemies[l].x+2==shells[i].x&&enemies[l].y==shells[i].y)||(enemies[l].x==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x+1==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x+2==shells[i].x&&enemies[l].y+1==shells[i].y)||(enemies[l].x+1==shells[i].x&&enemies[l].y+2==shells[i].y)||(enemies[l].x+2==shells[i].x&&enemies[l].y+2==shells[i].y)){
shells[i].fire=0;
enemies[l].go=0;
tank_clean(enemies[l].x,enemies[l].y,enemies[l].d);
gotoxy(shells[i].x,shells[i].y);
color(0);
printf("●");
score++;
I_tank.shells_number++;
score_g();
break;
}
}
}
}else if(shells[i].color==4){
if(I_tank.d==0)
if((I_tank.x+1==shells[i].x&&I_tank.y==shells[i].y)||(I_tank.x==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x+1==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x+2==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x==shells[i].x&&I_tank.y+2==shells[i].y)||(I_tank.x+1==shells[i].x&&I_tank.y+2==shells[i].y)||(I_tank.x+2==shells[i].x&&I_tank.y+2==shells[i].y)){
shells[i].fire=0;
tank_clean(I_tank.x,I_tank.y,I_tank.d);
gotoxy(shells[i].x,shells[i].y);
color(0);
printf("●");
game_over();
break;
}
if(I_tank.d==1)
if((I_tank.x==shells[i].x&&I_tank.y==shells[i].y)||(I_tank.x+1==shells[i].x&&I_tank.y==shells[i].y)||(I_tank.x==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x+1==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x+2==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x==shells[i].x&&I_tank.y+2==shells[i].y)||(I_tank.x+1==shells[i].x&&I_tank.y+2==shells[i].y)){
shells[i].fire=0;
tank_clean(I_tank.x,I_tank.y,I_tank.d);
gotoxy(shells[i].x,shells[i].y);
color(0);
printf("●");
game_over();
break;
}
if(I_tank.d==2)
if((I_tank.x==shells[i].x&&I_tank.y==shells[i].y)||(I_tank.x+1==shells[i].x&&I_tank.y==shells[i].y)||(I_tank.x+2==shells[i].x&&I_tank.y==shells[i].y)||(I_tank.x==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x+1==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x+2==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x+1==shells[i].x&&I_tank.y+2==shells[i].y)){
shells[i].fire=0;
tank_clean(I_tank.x,I_tank.y,I_tank.d);
gotoxy(shells[i].x,shells[i].y);
color(0);
printf("●");
game_over();
break;
}
if(I_tank.d==3)
if((I_tank.x+1==shells[i].x&&I_tank.y==shells[i].y)||(I_tank.x+2==shells[i].x&&I_tank.y==shells[i].y)||(I_tank.x==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x+1==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x+2==shells[i].x&&I_tank.y+1==shells[i].y)||(I_tank.x+1==shells[i].x&&I_tank.y+2==shells[i].y)||(I_tank.x+2==shells[i].x&&I_tank.y+2==shells[i].y)){
shells[i].fire=0;
tank_clean(I_tank.x,I_tank.y,I_tank.d);
gotoxy(shells[i].x,shells[i].y);
color(0);
printf("●");
game_over();
break;
}
}
}
}
}
void Generate_enemy(int i){
enemies[i].go=1;
enemies[i].d=rand()%4;
enemies[i].x=rand()%64+8;
enemies[i].y=rand()%32+8;
enemies[i].color=4;
tank_according(enemies[i].x,enemies[i].y,enemies[i].d,enemies[i].color);
}
void fighting(){
for(int i=0;i<7;i++)enemies[i].go=0;
for(int i=0;i<100;i++)shells[i].fire=0;
I_tank.shells_number=6;I_tank.d=0;I_tank.x=0;I_tank.y=0;score=0;
srand(rand());
I_tank.shells_number = 6;
I_tank.y=1;
Initialize2();
Initialization_fence();
tank_according(I_tank.x,I_tank.y,I_tank.d,I_tank.color);
int j=0,jg=rand()%50+500,j2=0;
GetLocalTime( &sys );
time=sys.wSecond;
time2=sys.wMinute;
score_g();
int x=0;
while(1){
if(ccs[checkpoint]<=score)game_over();
Sleep(8);
GetLocalTime( &sys );
srand(rand());
j++;
j2++;
for(int i=0;i<7;i++){
if(enemies[i].go&&enemies[i].j%7==0){
if(rand()%100<e[checkpoint]){
tank_clean(enemies[i].x,enemies[i].y,enemies[i].d);
if(rand()%2==0){
if(I_tank.x<enemies[i].x){
enemies[i].x--;
enemies[i].d=3;
}else{
enemies[i].x++;
enemies[i].d=1;
}
}else{
if(I_tank.y<enemies[i].y){
enemies[i].y--;
enemies[i].d=0;
}else{
enemies[i].y++;
enemies[i].d=2;
}
}
tank_according(enemies[i].x,enemies[i].y,enemies[i].d,enemies[i].color);
}
if(rand()%e2[checkpoint]==0){
if(enemies[i].d==0)shells_fire(enemies[i].x+1,enemies[i].y-1,0,4);
if(enemies[i].d==1)shells_fire(enemies[i].x+3,enemies[i].y+1,1,4);
if(enemies[i].d==2)shells_fire(enemies[i].x+1,enemies[i].y+3,2,4);
if(enemies[i].d==3)shells_fire(enemies[i].x-1,enemies[i].y+1,3,4);
}
}else if(enemies[i].go){
enemies[i].j++;
}
}
if(j%7==0){
color(7);
times=sys.wSecond-time;
times2=sys.wMinute-time2;
if(times<0){
times=60+times;
times2--;
}
gotoxy(20,0);
printf("存活时间:%d分%d秒\t",times2,times);
shells_mobile();
}
if(j2%jg==0){
for(int i=0;i<7;i++)if(!enemies[i].go){Generate_enemy(i);break;}
jg=rand()%50+400;
j2=0;
}
if(_kbhit()){
char k=_getch();
if(k=='J'||k=='j'){
GetLocalTime( &sys );
int timek=sys.wSecond,timek2=sys.wMinute;
gotoxy(55,0);
color(7);
printf("暂停中…");
x++;
gotoxy(60,0);
int temp,temp2;
while(1){
char k=getch();
if(k=='J'||k=='j')break;
}
GetLocalTime( &sys );
temp=sys.wSecond-timek;
temp2=sys.wMinute-timek2;
if(temp<0){
temp=60+temp;
temp2--;
}
time+=temp;
time2+=temp2;
if(time<0){
time=60+time;
time2--;
}
score_g();
}
I_tank_mobile(k);
}
}
}
void I_tank_color(){
system("cls");
system("color 0f");
int x=0,y=0;
BX:
gotoxy(5,0);
printf("坦克颜色选择:");
int c=1,c2;
for(int i=2;i<=8;i+=2){
for(int l=0;l<4;l++){
gotoxy(l*7+3,i);
if(c==4)c++;
color(c);
printf("color %d",c);
if((i/2-1)==y&&x==l){printf(" ■");c2=c;}
else if(c==I_tank.color)printf(" ●");
else printf(" ");
if(c==15)break;
c++;
}
}
char k=getch();
if(k=='a'||k=='A')if(x>0)x--;
if(k=='w'||k=='W')if(y>0)y--;
if(k=='s'||k=='S')if(y<3)y++;
if(k=='d'||k=='D')if(x<3&&(y!=3||x<1))x++;
if(k==13){
I_tank.color=c2;
cundang();
return;
}
goto BX;
}
void store(){
SH:
printf("\t\t\t商店\n");
}
void main_interface(int x,int y){
system("cls");
system("color f0");
ifstream dq("cundang.exe");
bool w;
dq>>w;
if(!w){
dq.close();
ofstream cd("cundang.exe");
cd<<true<<endl;
cd<<true<<" ";
cd.close();
}else{
for(int i=0;i<20;i++){
dq>>boss[i];
}
dq>>I_tank.color;
if(I_tank.color==0)I_tank.color=2;
dq.close();
}
XB:
Initialize();
gotoxy(0,0);
printf("主界面 awsd选择 回车确认 Sakuyark:sakuyark.com 一键打开(f)");
gotoxy(5,2);
for(int i=0;i<6;i++){
gotoxy(2,(i+1)*2);
for(int l=0;l<4;l++){
int s;
if(i==0)s=l;
if(i==1)s=l+4;
if(i==2)s=l+8;
if(i==3)s=l+12;
if(i==4)s=l+16;
if(boss[s])color(498);
if(i==y&&l==x)color(500);
else if(!boss[s])color(496);
printf("●%s",checkpoint_name[i][l]);
color(496);
printf(" ");
}
}
gotoxy(0,12);
char k=getch();
if(k=='a'||k=='A'){
if(x>0)x--;
goto XB;
}
if(k=='w'||k=='W'){
if(y>0)y--;
goto XB;
}
if(k=='s'||k=='S'){
if(y<5)y++;
goto XB;
}
if(k=='d'||k=='D'){
if(x<3)x++;
goto XB;
}
if(k==13){
if(y==5){
if(x==0)I_tank_color();
if(x==1)store();
if(x==3){cundang();exit(1);}
goto XB;
}
if(y==0)checkpoint=x;
if(y==1)checkpoint=x+4;
if(y==2)checkpoint=x+8;
if(y==3)checkpoint=x+12;
if(y==4)checkpoint=x+16;
if(boss[checkpoint]==1)fighting();
else MessageBox(NULL,"请先通过前一关","提示",MB_OK+16);
goto XB;
}
if(k=='f'||k=='F'){
system("start https://sakuyark.com");
goto XB;
}
goto XB;
}
void enter(){
Initialize();
cursor(0);
gotoxy(18,11);char a[]="坦 克 大 战";print(a,75);
gotoxy(18,12);char b[]="T a n k s w a r.";print(b,75);
Sleep(500);
gotoxy(17,14);
printf("加载中…");
main_interface(0,0);
}
int main(){
I_tank.color = 2;
enter();
return 0;
}
代码较之前有小改动,
如发现bug请在评论栏中提出
谢谢