#include
#include
using namespace std;
const int X=50,Y=10;
const int x=12;int y=8,y_z,k;
bool Map[Y][X],z[3][3][3];
char c;
long long df=0;
void csh();
void _cin();
void _cout();
bool _Gameover();
int main(){
csh();
_cout();
printf("按空格键开始游戏……n");
c=getch();
srand(time(NULL));
while(true){
k=rand()%3;y_z=50;
while(y_z>=0){
if(_Gameover()){
printf("Game over!n");
system("pause");
return 0;
}
_cin();
if(_Gameover()){
printf("Game over!n");
system("pause");
return 0;
}
_cout();
df++;
y_z-=2;
}
}
}
void csh(){
for(int i=0;i
for(int i=0;i
for(int i=0;i
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
for(int l=0;l<3;l++)
z[i][j][l]=false;
z[0][0][1]=z[0][1][1]=z[0][2][1]=z[1][0][1]=z[1][1][0]=z[1][1][1]=z[1][2][0]=z[1][2][1]=z[2][0][1]=z[2][1][1]=z[2][1][2]=z[2][2][0]=z[2][2][1]=z[2][2][2]=true;
return;
}
void _cout(){
system("cls");
printf("得分:%dn",df);
for(int i=0;i
for(int j=0;j
if(i==y&&j==x) printf("O");
else if(Map[i][j]) printf("#");
else if(z[k][i-6][j-y_z]&&i>=6&&i-6<3&&j>=y_z&&j-y_z<3) printf("*");
else printf(" ");
}
printf("n");
}
_sleep(25);
return;
}
void _cin(){
if(kbhit()!=0){
while(kbhit()!=0)
c=getch();
if(c==' '){
y-=3;y_z-=2;df++;
_cout();
y--;y_z-=2;df++;
_cout();
y++;y_z-=2;df++;
_cout();
y+=3;y_z-=2;df++;
}
}
return;
}
bool _Gameover(){
if(z[k][y-6][x-y_z-1]&&y>=6&&y-6<3&&y_z+1<=x&&x-y_z-1<3)
return true;
return false;
}//qybcjmy



