不管代码怎么
求你能运行就运行一下
看看效果
#include<graphics.h>
#include<dos.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<bios.h>
#define ESC 0x011b
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define ENTER 0x1c0d
#define LX 60
#define LY 60
#define BLONG 20
#define MX 16
#define MY 20
#define BKCOLOR 0
#define WAITTIME 40
#define BOXSPACE 2
#define NX (MX+4)
#define NY 7
#define DX (MX/2)
#define DY -3
void InitGra();
int play();
char *ntos(int n, char *c);
int RandomColor();
void InitGame();
int CheckNext(int x1 ,int y1);
void DrawBox(int x1,int y1,struct boxes *box,int in);
void ClearBox(int x1,int y1,struct boxes *box);
void ClearMem(int x1,int y1,struct boxes *box);
void DrawMem(int x1,int y1,struct boxes *box);
int LeftMove();
int RightMove();
int DownMove();
int turn();
int check();
int IsAdd();
int IsOver();
void add();
void GameOver();
int map[MX][MY];
struct boxes
{int number;
int t;
int color;
int box[4][4][2];
}*now,*next;
int x,y,score=0;
char c[8];
struct boxes mybox[6]={
{4,0,0,{{0,0,1,0,0,1,1,1},{0,0,1,0,0,1,1,1},
{0,0,1,0,0,1,1,1},{0,0,1,0,0,1,1,1}}},
{4,0,0,{{0,0,0,1,0,2,0,3},{0,0,1,0,2,0,3,0},
{0,0,0,1,0,2,0,3},{0,0,1,0,2,0,3,0}}},
{4,0,0,{{0,0,1,0,1,1,1,2},{2,0,0,1,1,1,2,1},
{0,0,0,1,0,2,1,2},{0,0,1,0,2,0,0,1}}},
{4,0,0,{{0,0,0,1,0,2,1,0},{0,0,1,0,2,0,2,1},
{0,2,1,0,1,1,1,2},{0,0,0,1,1,1,2,1}}},
{4,0,0,{{0,0,0,1,1,1,0,2},{0,0,1,0,2,0,1,1},
{0,1,1,0,1,1,1,2},{1,0,0,1,1,1,2,1}}},
{4,0,0,{{0,0,0,1,1,1,1,2},{1,0,2,0,0,1,1,1},
{0,0,0,1,1,1,1,2},{1,0,2,0,0,1,1,1}}}
};
void InitGra()
{
int dr=DETECT,mode=0;
registerbgidriver(EGAVGA_driver);
initgraph(&dr,&mode,"");
}
char *ntos(int n, char *c)
{
long i=0,j,k;
if (n==0)
{
c[0]='0';
c[1]=0;
return c;
}
for(j=5;j>=0;j--)
{
k=n/pow(10,j);
if(k>0||n==0)
{
c[i++]=k+'0';
n=n-k*pow(10,j);
}
}
c[i]=0;
return©;
}
int RandomColor()
{int c;
while((c = random(16))==BKCOLOR );
return c;
}
void InitGame()
{
int i,j;
for(i=0;i<MX;i++)
{
for(j=0;j<MY;j++)
map[i][j]=BKCOLOR;
}
settextstyle(0,0,3);
setcolor(1);
outtextxy(200,10,"Tetris Box");
setbkcolor (BKCOLOR);
setcolor(6);
setlinestyle(1,0,1);
for(i=1;i<MX;i++)
line(LX+i*BLONG-1,LY,LX+i*BLONG-1,LY+MY*BLONG);
for(i=1;i<MY;i++)
line(LX,LY+i*BLONG-1,LX+MX*BLONG,LY+i*BLONG-1);
randomize();
setlinestyle(0,0,3);
setcolor(1);
rectangle(LX-3,LY-3,LX+BLONG*MX+3,LY+BLONG*MY+3);
rectangle(LX+NX*BLONG-10,LY+NY*BLONG-10
,LX+(NX+4)*BLONG,LY+(NY+4)*BLONG);
setcolor(1);
settextstyle(0,0,3);
outtextxy(420,50,"Score:");
setcolor(4);
outtextxy(430,100,ntos(score,c));
now=&mybox[random(5)];
next=&mybox[random(5)];
now->color=RandomColor();
next->color=RandomColor();
DrawBox(NX,NY,next,0);
x=DX;y=DY;
DrawBox(x,y,now,1);
}
int CheckNext(int x1 ,int y1)
{int i,x2,y2,t,r=0;
t=now->t;
for(i=0;i<now->number;i++)
{ x2=x1+now->box[t][i][0];
y2=y1+now->box[t][i][1];
求你能运行就运行一下
看看效果
#include<graphics.h>
#include<dos.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<bios.h>
#define ESC 0x011b
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define ENTER 0x1c0d
#define LX 60
#define LY 60
#define BLONG 20
#define MX 16
#define MY 20
#define BKCOLOR 0
#define WAITTIME 40
#define BOXSPACE 2
#define NX (MX+4)
#define NY 7
#define DX (MX/2)
#define DY -3
void InitGra();
int play();
char *ntos(int n, char *c);
int RandomColor();
void InitGame();
int CheckNext(int x1 ,int y1);
void DrawBox(int x1,int y1,struct boxes *box,int in);
void ClearBox(int x1,int y1,struct boxes *box);
void ClearMem(int x1,int y1,struct boxes *box);
void DrawMem(int x1,int y1,struct boxes *box);
int LeftMove();
int RightMove();
int DownMove();
int turn();
int check();
int IsAdd();
int IsOver();
void add();
void GameOver();
int map[MX][MY];
struct boxes
{int number;
int t;
int color;
int box[4][4][2];
}*now,*next;
int x,y,score=0;
char c[8];
struct boxes mybox[6]={
{4,0,0,{{0,0,1,0,0,1,1,1},{0,0,1,0,0,1,1,1},
{0,0,1,0,0,1,1,1},{0,0,1,0,0,1,1,1}}},
{4,0,0,{{0,0,0,1,0,2,0,3},{0,0,1,0,2,0,3,0},
{0,0,0,1,0,2,0,3},{0,0,1,0,2,0,3,0}}},
{4,0,0,{{0,0,1,0,1,1,1,2},{2,0,0,1,1,1,2,1},
{0,0,0,1,0,2,1,2},{0,0,1,0,2,0,0,1}}},
{4,0,0,{{0,0,0,1,0,2,1,0},{0,0,1,0,2,0,2,1},
{0,2,1,0,1,1,1,2},{0,0,0,1,1,1,2,1}}},
{4,0,0,{{0,0,0,1,1,1,0,2},{0,0,1,0,2,0,1,1},
{0,1,1,0,1,1,1,2},{1,0,0,1,1,1,2,1}}},
{4,0,0,{{0,0,0,1,1,1,1,2},{1,0,2,0,0,1,1,1},
{0,0,0,1,1,1,1,2},{1,0,2,0,0,1,1,1}}}
};
void InitGra()
{
int dr=DETECT,mode=0;
registerbgidriver(EGAVGA_driver);
initgraph(&dr,&mode,"");
}
char *ntos(int n, char *c)
{
long i=0,j,k;
if (n==0)
{
c[0]='0';
c[1]=0;
return c;
}
for(j=5;j>=0;j--)
{
k=n/pow(10,j);
if(k>0||n==0)
{
c[i++]=k+'0';
n=n-k*pow(10,j);
}
}
c[i]=0;
return©;
}
int RandomColor()
{int c;
while((c = random(16))==BKCOLOR );
return c;
}
void InitGame()
{
int i,j;
for(i=0;i<MX;i++)
{
for(j=0;j<MY;j++)
map[i][j]=BKCOLOR;
}
settextstyle(0,0,3);
setcolor(1);
outtextxy(200,10,"Tetris Box");
setbkcolor (BKCOLOR);
setcolor(6);
setlinestyle(1,0,1);
for(i=1;i<MX;i++)
line(LX+i*BLONG-1,LY,LX+i*BLONG-1,LY+MY*BLONG);
for(i=1;i<MY;i++)
line(LX,LY+i*BLONG-1,LX+MX*BLONG,LY+i*BLONG-1);
randomize();
setlinestyle(0,0,3);
setcolor(1);
rectangle(LX-3,LY-3,LX+BLONG*MX+3,LY+BLONG*MY+3);
rectangle(LX+NX*BLONG-10,LY+NY*BLONG-10
,LX+(NX+4)*BLONG,LY+(NY+4)*BLONG);
setcolor(1);
settextstyle(0,0,3);
outtextxy(420,50,"Score:");
setcolor(4);
outtextxy(430,100,ntos(score,c));
now=&mybox[random(5)];
next=&mybox[random(5)];
now->color=RandomColor();
next->color=RandomColor();
DrawBox(NX,NY,next,0);
x=DX;y=DY;
DrawBox(x,y,now,1);
}
int CheckNext(int x1 ,int y1)
{int i,x2,y2,t,r=0;
t=now->t;
for(i=0;i<now->number;i++)
{ x2=x1+now->box[t][i][0];
y2=y1+now->box[t][i][1];