C 语言编俄罗斯方块行吗.

如题!

38 浏览 8 回复
  void   int   line   setcolor   10  

回复

    C 语言连操作系统都编出来了。你说行不行

    武娉

    我晕。。不要在这问白痴问题好不好?C语言都编不出来那什么能编出来啊。我用VB也就一下午就编出来了。用C语言的话还要简单些!

    郭力兴

    当然可以,C语言什么都能实现

    潘明

    no problem

    石冽嫔

    当然,请不要低估c的强大

    万良彪

    理论上来说C语言可以在计算机上实现任何可能的功能~~

    彭国兴

    真的很佩服那位VB一下午能编出来,C语言更简单的高手啊~用C语言可是可以但难度太大。慢慢来吧朋友。反正我是编不出来,VB倒还可以。C语言就算编个界面出来都让人头大~

    金利盛

    直接给你贴个程序把
    #include<dos.h>
    #include<stdlib.h>
    #include<conio.h>
    #include<graphics.h>
    #include<stdio.h>
    #include
    #define LEFT 0x4b
    #define RIGHT 0x4d
    #define DOWN 0x50
    #define UP 0x48
    #define CHANGE 0x20
    #define ENTER 0x0d
    #define ESC 0x1b
    #define F1 0x3600
    #define F2 0x3c00
    #define DefaultX 5
    #define DefaultY 1
    static unsigned shape[7][4][4][4]={
    { /*Do you know the mean ?... */
    {{0,1,1,0},{0,1,1,0},{0,0,0,0},{0,0,0,0}},/*shape[0][0][0][0] like this */
    {{0,1,1,0},{0,1,1,0},{0,0,0,0},{0,0,0,0}},/* 0 1 1 0 | 1:visiable*/
    {{0,1,1,0},{0,1,1,0},{0,0,0,0},{0,0,0,0}},/* 0 1 1 0 | 0:hidden */
    {{0,1,1,0},{0,1,1,0},{0,0,0,0},{0,0,0,0}},/* 0 0 0 0 | */
    }, /* 0 0 0 0 | */
    { /*shape[1][0][0][0] like this */
    {{0,0,0,0},{1,1,1,1},{0,0,0,0},{0,0,0,0}},/* 0 0 0 0 */
    {{0,0,1,0},{0,0,1,0},{0,0,1,0},{0,0,1,0}},/* 1 1 1 1 */
    {{0,0,0,0},{1,1,1,1},{0,0,0,0},{0,0,0,0}},/* 0 0 0 0 */
    {{0,0,1,0},{0,0,1,0},{0,0,1,0},{0,0,1,0}},/* 0 0 0 0 */
    }, /*shape[2][0][0][0] like this */
    { /* 0 1 0 0 */
    {{0,1,0,0},{1,1,1,0},{0,0,0,0},{0,0,0,0}},/* 1 1 1 0 */
    {{0,1,0,0},{0,1,1,0},{0,1,0,0},{0,0,0,0}},/* 0 0 0 0 */
    {{0,0,0,0},{1,1,1,0},{0,1,0,0},{0,0,0,0}},/* 0 0 0 0 */
    {{0,1,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}},/*shape[3][0][0][0] like this */
    }, /* 1 0 0 0 */
    { /* 1 1 0 0 */
    {{1,0,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}},/* 0 1 0 0 */
    {{0,0,0,0},{0,1,1,0},{1,1,0,0},{0,0,0,0}},/* 0 0 0 0 */
    {{1,0,0,0},{1,1,0,0},{0,1,0,0},{0,0,0,0}},
    {{0,0,0,0},{0,1,1,0},{1,1,0,0},{0,0,0,0}},
    },
    {
    {{0,1,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}},
    {{0,0,0,0},{1,1,0,0},{0,1,1,0},{0,0,0,0}},
    {{0,1,0,0},{1,1,0,0},{1,0,0,0},{0,0,0,0}},
    {{0,0,0,0},{1,1,0,0},{0,1,1,0},{0,0,0,0}},
    },
    {
    {{1,0,0,0},{1,0,0,0},{1,1,0,0},{0,0,0,0}},
    {{0,0,0,0},{1,1,1,0},{1,0,0,0},{0,0,0,0}},
    {{1,1,0,0},{0,1,0,0},{0,1,0,0},{0,0,0,0}},
    {{0,0,0,0},{0,0,1,0},{1,1,1,0},{0,0,0,0}},
    },
    {
    {{0,1,0,0},{0,1,0,0},{1,1,0,0},{0,0,0,0}},
    {{0,0,0,0},{1,0,0,0},{1,1,1,0},{0,0,0,0}},
    {{1,1,0,0},{1,0,0,0},{1,0,0,0},{0,0,0,0}},
    {{0,0,0,0},{1,1,1,0},{0,0,1,0},{0,0,0,0}},
    },
    };
    unsigned back[22][14];/* Game zone size= 22 X 12*/
    /*游戏区域虽然是 20 X 10 ,这里使用 22 X 14 是一个编程的技巧,
    这样免去了数组越界的检查,这种方法经常用在图形设计中。
    */
    char ShapeColor[7]={LIGHTGRAY,LIGHTGREEN,LIGHTCYAN,LIGHTRED,LIGHTMAGENTA,YELLOW,WHITE}; /* RusGrid color */
    char DigitalShape[10]={0xf7,0x03,0x3e,0x1f,0xcb,0xdd,0xfd,0x13,0xff,0xdf};/*for draw Didital*/
    /********************************************
    b7 b6 b5 b4 b3 b2 b1 b0
    0 1 1 1 1 0 1 1 1
    1 0 0 0 0 0 0 1 1
    2 0 0 1 1 1 1 1 0
    3 0 0 0 1 1 1 1 1
    4 1 0 0 0 1 0 1 1
    5 1 1 0 1 1 1 0 1
    ___b4__
    | |
    b7| |
    | |b1
    |___b3__|
    | |
    b5| |b0
    | |
    |___b2__|
    **********************************************/
    char JamosBack[11]={4,6,12,13,11,10,2,3,9,1,8};
    static unsigned counter=0;
    /* 'counter' used to count the wait time,
    例如给定的时间为 2 秒钟,而在这段时间里count能由0 增加到 OVERTIME,如果
    没有被中断。超时后,应当处理超时操作。但是如果该时间片里有中断,则处理
    相应的中断操作,中断返回置 count=0
    */
    int CurrentShape,x=6,y=0,Status=0;
    /*currentshape:方块形状,0---6;
    status:旋转角度 0:0 1:90 2:180 3:270;
    x,y: 方块左上角坐标
    */
    unsigned long TotalMark=0; /*当前得分*/
    unsigned int Erasered=0,PastedTime=0;/*Erasered:已经清除的行数;PastedTime:已经过去的时间*/
    int Speed=0;/*当前速度*/
    int CEr=0; /*由CEr 据一定的算法改变速度 Speed**/
    int TimeDelay[10]={21,18,17,15,13,11,9,7,5,3};/*难度是通过速度体现的*/
    char NewShape[2];/*游戏中NewShape[0]:当前活动的方块;NewShape[1]:下一个活动的方块*/
    /* All Function Declare */
    /* Begin */
    void openkey(); /*取消键盘屏蔽*/
    void closekey();/*屏蔽键盘 */
    void PutStar(); /*绘繁星样的背景*/
    void Message(char *Msg );/*Show Message during Game*/
    void DrawDigital(int x,int y,int a);/*画数字*/
    void ArtClear();/*清除屏幕*/
    void GameEnd();/*游戏结束时调用*/
    void Quit_Restart();/*询问是否要退出游戏*/
    void ShowTitle();/*show welcome*/
    void DrawShape(int x,int y,int color);/*Draw one unit of RusGrid */
    void DrawNull(int x,int y); /*like before but Draw nothing */
    void show( ); /* show RusGrid */
    void DrawScore();/*当有新的行被清除是就重新写得分*/
    int CreateNewShape();/*产生下一个方块的形状*/
    void GoLeft( ); /*左移*/
    void GoRight( );/*右移*/
    void GoDown( ); /*下落*/
    void ChageShape( ); /*route the RusGrid*/
    void DrawFace(); /*Draw the game zone include back[][] ,active RusGrid and so on*/
    void GameQuit();/*quit game*/
    void GamePlay();/*play game*/
    void GameInit();/*初始化全局变量*/
    /* End */
    /* All Function Declare */
    void main()
    {
    GamePlay();
    }
    /****************************************************************/
    /*==============================================================*/
    /********Under is function define********************************/
    void Message(char *Msg )
    {
    setfillstyle(1,8);
    bar(362,348,509,398);
    setcolor(15);
    outtextxy(368,355,Msg);
    }
    void DrawDigital(int x,int y,int a)
    {
    /*****************************************************************
    DigitalShape[10]={0xf7,0x03,0x3e,0x1f,0xcb,0xdd,0xfd,0x13,0xff,0xdf};
    b7 b6 b5 b4 b3 b2 b1 b0
    0 1 1 1 1 0 1 1 1
    1 0 0 0 0 0 0 1 1
    2 0 0 1 1 1 1 1 0
    3 0 0 0 1 1 1 1 1
    4 1 0 0 0 1 0 1 1
    5 1 1 0 1 1 1 0 1
    ___b4__
    | |
    b7| |
    | |b1
    |___b3__|
    | |
    b5| |b0
    | |
    |___b2__|
    ***********************************************************************/
    int i=7;
    int tempcolor=((DigitalShape[a]>>i)&1)*3+8;
    setcolor(tempcolor);
    /*printf("%d",(DigitalShape[a]>>i)&1);*/
    line(x,y+1,x,y+15);
    line(x+1,y+2,x+1,y+14);
    line(x+2,y+3,x+2,y+13);
    i--;/*跳过i=6*/
    i--;/*i=5*/
    tempcolor=((DigitalShape[a]>>i)&1)*3+8;
    setcolor(tempcolor);
    line(x,y+17,x,y+31);
    line(x+1,y+18,x+1,y+30);
    line(x+2,y+19,x+2,y+29);
    i--;/*i=4*/
    tempcolor=((DigitalShape[a]>>i)&1)*3+8;
    setcolor(tempcolor);
    line(x+1,y,x+16,y);
    line(x+2,y+1,x+15,y+1);
    line(x+3,y+2,x+14,y+2);
    i--;/*i=3*/
    tempcolor=((DigitalShape[a]>>i)&1)*3+8;
    setcolor(tempcolor);
    line(x+2,y+15,x+15,y+15);
    line(x+1,y+16,x+16,y+16);
    line(x+2,y+17,x+15,y+17);
    i--;/*i=2*/
    tempcolor=((DigitalShape[a]>>i)&1)*3+8;
    setcolor(tempcolor);
    line(x+3,y+30,x+14,y+30);
    line(x+2,y+31,x+15,y+31);
    line(x+1,y+32,x+16,y+32);
    i--;/*i=1*/
    tempcolor=((DigitalShape[a]>>i)&1)*3+8;
    setcolor(tempcolor);
    line(x+15,y+3,x+15,y+13);
    line(x+16,y+2,x+16,y+14);
    line(x+17,y+1,x+17,y+15);
    i--;/*i=0*/
    tempcolor=((DigitalShape[a]>>i)&1)*3+8;
    setcolor(tempcolor);
    line(x+15,y+19,x+15,y+29);
    line(x+16,y+18,x+16,y+30);
    line(x+17,y+17,x+17,y+31);
    }
    void ArtClear()
    { int i;
    for( i=480;i>=0;i-=2)
    { setcolor(3);
    line(0,i-14,639,i-14);delay(10);
    setcolor(9);
    line(0,i-12,639,i-12);delay(10);
    setcolor(1);
    line(0,i-10,639,i-10);delay(10);
    setcolor(getbkcolor());
    line(0,i-8,639,i-8);
    setcolor(3);
    line(0,i-6,639,i-6);delay(10);
    setcolor(9);
    line(0,i-4,639,i-4);delay(10);
    setcolor(1);
    line(0,i-2,639,i-2);delay(10);
    setcolor(getbkcolor());
    line(0,i,639,i);
    }
    }
    void GameEnd()
    {
    int i,j;
    cleardevice();setbkcolor(0);
    for(i=0;i<11;i++)
    {
    setcolor(JamosBack[i]);
    line(200,i*8+100,440,i*8+100);
    }
    delay(1000);
    for(j=0;j<17;j++)
    for(i=0;i<11;i++)
    {
    setcolor(JamosBack[(i+j)%16]);
    line(200,i*8+100,440,i*8+100);
    delay(4);
    }
    setcolor(YELLOW);
    outtextxy(260,200,"[ Game Over ]");
    gotoxy(12,16);
    printf("This Program is Designed by Jamos in 2002");
    gotoxy(12,17);
    printf("Please mailto jamosnet@163.com or visit my homepage ");
    gotoxy(12,18);
    printf("http://jamos.51.net if you have any question.");
    gotoxy(12,20);
    printf("I really hold these truths that all codes are created FREE.");
    gotoxy(12,21);
    printf("Thank for uesing......");
    getch();
    getch();
    Quit_Restart();
    }
    void Quit_Restart()
    {
    int choise=0,temp;
    int i,j;
    setcolor(BLACK);
    for( j=189;j<480;j++)
    {
    line(0,j,640,j);
    delay(5);
    }
    /* setfillstyle(1,8);*/
    setcolor(15);
    outtextxy(200,220,"What are you want to do ?");
    outtextxy(265,260,"Quit");
    outtextxy(325,260,"Restart");
    setcolor(14);
    circle(254,264,4);
    setcolor(8);
    circle(314,264,4);
    while((temp=bioskey(0))!=7181 )/*if not enter*/
    {
    if(temp==283)/* ESC*/
    { choise=0;
    break;
    }
    if(temp==19200)/* LEFT */
    { setcolor(8);
    circle(314,264,4);
    choise=0;
    setcolor(14);
    circle(254,264,4);
    }
    if(temp==19712)/* RIGHT */
    { setcolor(8);
    circle(254,264,4);
    choise=1;
    setcolor(14);
    circle(314,264,4);
    }
    }
    if(choise==0)/*quit*/
    {
    clrscr();
    closegraph();
    exit(0);
    }
    /*else Restart*/
    GamePlay();
    }
    void ShowTitle()
    {
    int gdriver=DETECT,gmode,errorcode,i,j,k;
    initgraph(&gdriver,&gmode,"");
    errorcode=graphresult();
    if (errorcode!=grOk)
    {
    printf("Graphics error: %s\n\007",grapherrormsg(errorcode));
    exit(1);
    }
    /*registerbgidriver(EGAVGA_driver);*/
    /*regiserbgifont(TRIPLEX_FONT);*/
    PutStar();
    setbkcolor(0); /* This line needs to be changed */
    for(i=0;i<11;i++)
    {
    setcolor(JamosBack[i]);
    line(200,i*8+100,440,i*8+100);
    }
    delay(1000);
    for(j=0;j<17;j++)
    for(i=0;i<11;i++)
    {
    setcolor(JamosBack[(i+j)%16]);
    line(200,i*8+100,440,i*8+100);
    delay(4);
    }
    setcolor(14);
    outtextxy(220,161,"Press any key to start...");
    getch();
    ArtClear();
    cleardevice();
    setbkcolor(9);
    }
    void DrawShape(int x,int y,int color)
    {
    int i;
    int posX,posY;
    setcolor(color);
    posX = x<<4; posY = y<<4;
    for( i=0;i<15;i++)
    line(posX,posY+i,posX+14,posY+i);
    setcolor(8);
    line(posX+15,posY+1,posX+15,posY+15);
    line(posX+1,posY+15,posX+15,posY+15);
    setcolor(color-8);
    line(posX+2,posY+2,posX+12,posY+2);
    line(posX+2,posY+2,posX+2,posY+12);
    }
    void DrawNull(int x,int y)
    { int i;
    int posX,posY;
    posX = x<<4; posY = y<<4;
    setcolor(getbkcolor());/*用背景色填充,相当于清除原图象*/
    for( i=0;i<16;i++)
    line(posX,posY+i,posX+15,posY+i);
    }
    void show( )
    { /*相对于坐标(0,0),以 16 X 16 大小划分屏幕*/
    /*得到的网格与棋盘相似,每个网格用新坐标定位*/
    /*在本程序中 back[0][0]==>(6,4)
    back[0][1]==>(7,4)
    back[0][2]==>(8,4)
    ......
    back[1][0]==>(6,5)
    back[1][1]==>(7,5)
    back[1][2]==>(8,5)
    ......
    back[i][j]==>(6+j,4+i)
    根据这个关系可以方便地额完成以下程序
    */
    int l,p;
    int temp,i,j;
    /*The background should be draw,no matter what the status be*/
    unsigned int bufferBack[20][10];/*把要画的图形存放到数组bufferBack中,这样可以消除屏幕的抖动现象*/
    for( i=0;i<20;i++)
    { for( j=2;j<12;j++)
    {
    bufferBack[i][j-2] = back[i][j];
    }
    }
    for( l=0;l<4;l++)/*Draw the grid which current active */
    for( p=0;p<4;p++)
    {
    if(l+x<2||x+l>12||p+y>19)
    continue;
    if(shape[CurrentShape][Status][p][l]==1)
    /*DrawShape(6+l+x,4+p+y,ShapeColor[CurrentShape]);*/
    bufferBack[p+y][x+l-2] = ShapeColor[CurrentShape];
    }
    for( i=0;i<20;i++)
    { for( j=2;j<12;j++)
    { switch( bufferBack[i][j-2] )
    {
    case 0: DrawNull(6+j,4+i); break;
    case 1: DrawShape(6+j,4+i,BLUE); break;/*方块的颜色为蓝色*/
    default : DrawShape(6+j,4+i,bufferBack[i][j-2]);
    }
    }
    }
    }
    void DrawScore()
    /*画得分的同是也画了清除的行数*/
    { int i;
    unsigned long temp=TotalMark;
    for( i=0;i<7;i++)
    {
    DrawDigital(477-i*20,65,temp%10);
    temp/=10;
    }
    temp=Erasered;
    for(i=0;i<4;i++)
    {
    DrawDigital(491-i*20,111,temp%10);
    temp/=10;
    }
    if(Erasered==0)
    return;
    DrawDigital(466,293,Speed);
    return;
    }
    int CreateNewShape()
    { int l,p;
    NewShape[1]=NewShape[0];
    NewShape[0]=rand()%7;
    setfillstyle(1,0);
    bar(447,240,514,288);
    for( l=0;l<4;l++)
    for( p=0;p<4;p++)
    if(shape[NewShape[0]][0][p][l]==1)
    DrawShape(28+l,15+p,ShapeColor[7]);
    return NewShape[1];
    }
    int Possible(int x,int y,int CurrentShape,int Status)
    { int i,j;
    for( i=0;i<4;i++)
    {
    for( j=0;j<4;j++)
    {
    if(shape[CurrentShape][Status][i][j]+back[y+i][x+j]==2)
    return 0;
    }
    }
    return 1;
    }
    void GoLeft( )
    {
    if(Possible(x-1,y,CurrentShape,Status))
    { x--;
    show( );
    }
    }
    void GoRight( )
    {
    if(Possible(x+1,y,CurrentShape,Status))
    { x++;
    show( );
    }
    }
    void GoDown( )
    { int i,j;
    int r,l;
    int rr,ll;
    int AllAreOne=1,temp=0;
    int bar=0;/* how many rows are ok*/
    if(Possible(x,y+1,CurrentShape,Status))
    {
    y++;
    show( );
    return;
    }
    /*If down error deal the game */
    TotalMark+=3*CurrentShape;
    for( i=0;i<4;i++)
    for( j=0;j<4;j++)
    back[i+y][j+x]+=shape[CurrentShape][Status][i][j];
    for( r=1;r<20;r++)/* clear ok row and update Erasered CEr temp */
    {
    for( l=2;l<13;l++)
    { if(back[r][l]==0)
    AllAreOne=0;
    }
    if(AllAreOne==1)
    {
    for( rr=r;rr>0;rr--)
    for( ll=2;ll<13;ll++)
    back[rr][ll]=back[rr-1][ll];
    Erasered++;
    CEr++;
    temp++;
    bar++;
    }
    AllAreOne=1;
    }
    TotalMark+=10*temp;
    switch(bar)/*more ok bars more scores */
    { case 0:
    break;
    case 1:
    TotalMark+=100;
    break;
    case 2:
    TotalMark+=100*3;
    break;
    case 3:
    TotalMark+=100*5;
    break;
    case 4:
    TotalMark+=100*7;
    break;
    default:
    TotalMark+=100*10;
    }
    /*Create a new shape and continue */
    CurrentShape=CreateNewShape();
    x=DefaultX;y=DefaultY;Status=0;
    show( );
    counter=0;
    if(!Possible(x,y,CurrentShape,Status))
    {
    getch();/* Now Game Over*/
    GameEnd();
    }
    if(CEr>=20)
    {/*when total ok bars reack 20 then update speed*/
    Speed=(Speed+1)%10;
    CEr/=20;
    }
    DrawScore();
    while (kbhit())
    {
    getch();
    }
    delay(500);
    return;
    }
    void ChageShape( )
    {
    if(Possible(x,y,CurrentShape,(Status+1)%4))
    Status=(Status+1)%4;
    show( );
    }
    void DrawFace()
    { int i;
    int temp;
    int randfillstyle;/*make the game space fillstyle randmize*/
    randfillstyle=rand()%12;
    if( randfillstyle<2) randfillstyle=8;
    setcolor(15);
    line(351,59,519,59);
    line(351,60,518,60);
    line(351,59,351,156);
    line(352,59,352,155);
    setcolor(7);
    line(518,61,518,154);
    line(519,60,519,154);
    line(353,155,519,155);
    line(352,156,519,156);
    setcolor(8);
    for( i=61;i<155;i++)
    line(353,i,517,i);
    setcolor(7);
    line(427,106,512,106);
    line(428,107,511,107);
    line(427,106,427,147);
    line(428,106,428,146);
    setcolor(15);
    line(512,106,512,147);
    line(511,107,511,146);
    line(428,146,511,146);
    line(427,147,512,147);
    settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
    setcolor(14);
    outtextxy(357,119,"Erasered");
    outtextxy(370,130,"Level:");
    setcolor(15);
    line(352,167,519,167);
    line(352,168,518,168);
    line(352,169,352,407);
    line(353,169,353,406);
    setcolor(7);
    line(519,167,519,407);
    line(518,168,518,406);
    line(352,407,519,407);
    line(353,406,519,406);
    line(524,55,89,55); /*outter border 1st*/
    line(524,55,524,411);
    line(89,411,524,411);
    line(89,55,89,411);
    line(524,56,89,56); /*outter border 2nd */
    line(525,55,525,411);
    line(89,410,524,410);
    line(88,55,88,411);
    setfillstyle(randfillstyle,15); /*set fillstyle 2:'-' 3:'///' 4:'///'(BK) 5:'\\\'(BK)*/
    bar(94,59,336,406);/* 6:'\\\' 7:'grid' 8:'x grid' 9:'dot' 10:'wide dot' 11:'close dot'*/
    /*draw pasted time zone */
    line(427,106+64,512,106+64);
    line(428,107+64,511,107+64);
    line(427,106+64,427,147+64);
    line(428,106+64,428,146+64);
    setcolor(15);
    line(512,106+64,512,147+64);
    line(511,107+64,511,146+64);
    line(428,146+64,511,146+64);
    line(427,147+64,512,147+64);
    setcolor(8);
    for(i=107+64+1;i<147+64-1;i++)
    line(429,i,510,i);
    setcolor(15);
    /* end draw pasted time */
    for(i=0;i<8;i++)
    DrawDigital(357+i*20,65,0);
    for(i=0;i<4;i++)
    DrawDigital(431+i*20,111,0);
    setfillstyle(1,8);
    setcolor(14);
    outtextxy(357,177,"Pasted");
    outtextxy(370,188,"Time:");
    for(i=0;i<4;i++)
    DrawDigital(431+i*20,173,0);
    setcolor(14);
    outtextxy(366,250,"Next Shape");
    setcolor(10);
    outtextxy(366,294,"Current");
    outtextxy(382,309,"Level");
    setcolor(6);
    outtextxy(366,334,"Message:");
    bar(362,348,509,398);
    DrawDigital(466,293,Speed);
    }
    void GameQuit()
    {
    int choise=0,temp;
    setfillstyle(1,8);
    bar(362,348,509,398);
    setcolor(15);
    outtextxy(378,355,"Are you sure to");
    outtextxy(368,368,"quit game?");
    outtextxy(410,388,"Yes");
    outtextxy(470,388,"No");
    setcolor(14);
    circle(399,392,4);
    while((temp=bioskey(0))!=7181 )/*if not enter*/
    { if(temp==4209)/* q*/
    exit(0);
    if(temp==4978)/* r */
    GamePlay();
    if(temp==7681)/* Ctrl+A*/
    { TotalMark+=1000;
    /*show( );*/
    DrawScore();
    }
    if(temp==283)/* ESC*/
    { choise=1;
    break;
    }
    if(temp==19200)/* LEFT */
    { setcolor(8);
    circle(459,392,4);
    choise=0;
    setcolor(14);
    circle(399,392,4);
    }
    if(temp==19712)/* RIGHT */
    { setcolor(8);
    circle(399,392,4);
    choise=1;
    setcolor(14);
    circle(459,392,4);
    }
    }
    if(choise==0)
    {
    GameEnd();
    }
    setfillstyle(1,8);
    bar(362,348,509,398);
    return;
    }
    void GamePlay()
    { unsigned char c = 0;
    unsigned long temp;
    int i,flag=0;
    GameInit();/*must be init*/
    ShowTitle();
    randomize();/*Init rand manchine*/
    NewShape[0]=rand()%7;
    DrawFace();
    CurrentShape=CreateNewShape();
    show( );
    while ( kbhit() ) getch();/*清空键盘缓存*/
    while(1)
    {
    if(kbhit())
    {
    c=getch();
    if(c==0)
    c=getch();
    closekey();
    openkey();
    switch(c)
    {
    case 'V' :
    Speed=(Speed+1)%10;
    DrawDigital(466,293,Speed);
    Message("Add Speed");
    break;
    case 'v' :
    if(!Speed) break;/*if Speed ==0 return*/
    Speed=(Speed-1)%10;
    DrawDigital(466,293,Speed);
    Message("Dec Speed");
    break;
    case 's':
    case 'S':
    case DOWN :
    while (Possible(x,y+1+1,CurrentShape,Status))
    {
    y++;
    /*show();*/
    }
    Message("Go Down The Shape");
    break;
    case 'a':
    case 'A':
    case LEFT :
    GoLeft( );
    Message("Go Left The Shape");
    break;
    case 'd':
    case 'D':
    case RIGHT :
    GoRight( );
    Message("Go Right The Shape");
    break;
    case UP:
    case ENTER:
    case CHANGE :
    ChageShape( );
    Message("Change The Shape");
    break;
    case ESC :
    GameQuit();
    }
    }
    delay(TimeDelay[Speed]*50); counter++;
    PastedTime++;flag=PastedTime%40;
    temp=PastedTime/50;/*draw pasted time*/
    if(!flag)/*draw time when flag==0 */
    for(i=0;i<4;i++)
    { DrawDigital(491-i*20,173,temp%10);
    temp/=10;
    }
    if((counter%=TimeDelay[Speed])==(TimeDelay[Speed]-1))
    {
    GoDown(); /* printf("%d",counter);*/
    counter=0;
    }
    }
    }
    void GameInit()
    {
    int i,j;
    /* Init the var*/
    counter=0;
    CurrentShape=0,x=6,y=0,Status=0;
    TotalMark=0;
    Erasered=0;
    PastedTime=0;
    Speed=0;
    CEr=0;
    /*Init the back[i][j]*/
    for(i=0;i<14;i++)
    for(j=0;j<22;j++)
    { if( i>1&&i<12&&j<20)
    back[j][i]=0;
    else
    back[j][i]=1;
    }
    /*================back[i][j]=====================*/
    /*{
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,0,0,0,0,0,0,0,0,0,0,1,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1}};*/
    }
    void closekey()
    { unsigned int al;
    al=0xba;
    outportb(0x21,al);
    }
    void openkey()
    { unsigned int al;
    al=0xb8;
    outportb(0x21,al);
    }
    void PutStar()
    { int seed=1858;
    int i,dotx,doty,h,w,color,maxcolor;
    maxcolor=getmaxcolor();
    h=getmaxx();
    w=getmaxy();
    srand(seed);
    for(i=0;i<500;i++)
    {
    dotx=i%150+random(w-1);
    doty=1+random(h-1);
    color=random(maxcolor);
    setcolor(color);
    putpixel(dotx,doty,color);
    /* circle(dotx+1,doty+1,0);*/
    }
    srand(seed);
    }

    吕芃

相关信息

这道程序用C 语言怎么编? !!!!急!!

已知有N个人围成一圈,假设从第S个人从1开始报数,当有人报数为M或M的倍数,该人出圈,请用C语言编程,把这N个人的顺序求出来。 假设N=100 S=1 M=10 hust\_jerome - 魔法学徒 一级 你的答案有错误,我运行过,但是结果不对。 急求另外一种方法!!!!!!!!!!!!!!!!!!!! 最好能够详细一些。

17 浏览 2 回复   void   s1   10   for   100  

C ++ #define预处理

<p>我需要知道,它在C ++中的#define指令声明全局标签?环球我的意思是可见的每一个文件? P&gt; </p><p>我在使用Visual Studio 2008,(想,如果该事项) P&gt; </p>

59 浏览 1 回复   gt   文件   一个   ++   定义  

c语言void func1(int i);是什么意思

43 设已有定义: char \*st="how are you"; 下列程序段中正确的是b为什么,其他3项哪里错了? a char a[11], \*p; strcpy(p=a+1,&st[4]); b char a[11]; strcpy(++a, st); c char a[11]; strcpy(a, st); d char a...

37 浏览 2 回复   int   函数   arr   func1   void  

c语言:void reverse(int a[], int n)是什么意思

34 以下程序中的函数reverse的功能是将a所指数组重的内容进行逆置 void reverse(int a[], int n) {int i,t; for(i=0;i<n/2;i++) {t=a[i];a[i]=a[n-1-i];a[n-1-i]=t;} } main() {int b[10]={1,2,3,4,5,6,7,8,9,10}; int i,s=0; reverse...

37 浏览 2 回复   fp   int   dat   d1   文件  

#ifndef 和#define 在C++中什么意思?

如题!

45 浏览 3 回复   常量   定义   const   字符   程序