栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

跳动方块

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

跳动方块

#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 j=0;j             Map[i][j]=false;
    for(int i=0;i         Map[i][0]=Map[i][X-1]=true;
    for(int i=0;i         Map[0][i]=Map[Y-1][i]=true;
    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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/857328.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号