主题:俄罗斯方块游戏 改错
#include<stdio.h>
#include<stdlib.h>
#include<dos.h>
#include<graphics.h>
#define VK_LEFT 0x4b00
#define VK_RIGHT 0x4d00
#define VK_DOWN 0x5000
#define VK_UP 0x4800
#define VK_ESC 0x011b
#define TIMER 0x1c
#define MAX_BOX 19
#define BSIZE 20
#define Sys_x 160
#define Sys_y 25
#define Horizontal_boxs 10
#define Vertical_boxs 15
#define Begin_boxs_x Horizontal_boxs 2
#define FgColor 3
#define BgColor 0
#define LeftWin_x Sys_x+Horizontal_boxs*BSIZE+46
#define false 0
#define true 1
#define MoveLeft 1
#define MoveRight 2
#define MoveDown 3
#define MoveRoll 4
int current_box_numb;
int Curbox_x=Sys_x+Begin_boxs_x*BSIZE,Curbox_y=Sys_y;
int flag_newbox=false;
int speed=0;
int score=0;
int speed_step=30;
void interrupt (*oldtimer)(void);
struct BOARD
{
int var;
int color;
}Table_board[Vertical_boxs][Horizontal_boxs];
struct SHAPE
{
char box[2];
int color;
int next;
};
struct SHAPE shapes[MAX_BOX]=
{
{0x88,0xc0,CYAN,1},
{0xe8,0x0,CYAN,2},
{0xc4,0x40,CYAN,3},
{0x2e,0x0,CYAN,0},
{0x44,0xc0,MAGENTA,5},
{0x8e,0x0,MAGENTA,6},
{0xc8,0x80,MAGENTA,7},
{0xe2,0x0,MAGENTA,4},
{0x8c,0x40,YELLOW,9},
{0x6c,0x0,YELLOW,8},
{0x4c,0x80,BROWN,11},
{0xc6,0x0,BROWN,10},
{0x4e,0x0,WHITE,13},
{0x8c,0x0,WHITE,14},
{0xe4,0x0,WHITE,15},
{0x4c,0x40,WHITE,12},
{0x88,0x88,RED,17},
{0xf0,0x0,RED,16},
{0xcc,0x0,BLUE,18}
};
void initialize(int x,int y,int m, int n)
{
int i;
int j;
int oldx;
oldx=x;
for(j=0;j<n;j++)
{
for(i=0;i<m;i++)
{
Table_board[j][i].var=0;
Table_board[j][i].color=BgColor;
line(x,y,x+BSIZE,y);
line(x,y,x,y+BSIZE);
line(x,y+BSIZE,x+BSIZE,Y+BSIZE);
line(x+BSIZE,y,x+BSIZE,y+BSIZE);
x+=BSIZE;
}
y+=BSIZE;
x=oldx;
}
Curbox_x=x;
Curbox_y=y;
flag_newbox=false;
speed=0;
score=0;
ShowScore(score);
ShowSpeed(speed);
}
void interruptnewtimer(void)
{
(*oldtimer)();
TimerCounter++;
}
void SetTimer(void interrupt(*IntProc)(void))
{
oldtimer=getvect(TIMER);
disable();
setvect(TIMER,IntProc);
enable();
}
void KillTimer()
{
disable();
setvect(TIMER,oldtimer);
enable();
}
void ShowScore(int score)
{
int x,y;
char score_str[5];
setfillstyle(SOLID_FILL,BgColor);
x=LeftWin_x;
y=100;
bar(x-BSIZE,y,x+BSIZE*3,y+BSIZE*3);
sprintf(score_str,"%3d",score);
outtextxy(x,y,"SCORE");
outtextxy(x,y+10,score_str);
}
void ShowSpeed(int speed)
{
int x,y;
char speed_str[5];
setfillstyle(SOLID_FILL,BgColor);
x=LeftWin_x;
y=150;
bar(x-BSIZE,y,x+BSIZE*3,y+BSIZE*3);
sprintf(speed_str,"%3d",speed+1);
outtextxy(x,y,"Level");
outtextxy(x,y+10,speed_str);
outtextxy(x,y+50,"Nextbox");
}
#include<stdlib.h>
#include<dos.h>
#include<graphics.h>
#define VK_LEFT 0x4b00
#define VK_RIGHT 0x4d00
#define VK_DOWN 0x5000
#define VK_UP 0x4800
#define VK_ESC 0x011b
#define TIMER 0x1c
#define MAX_BOX 19
#define BSIZE 20
#define Sys_x 160
#define Sys_y 25
#define Horizontal_boxs 10
#define Vertical_boxs 15
#define Begin_boxs_x Horizontal_boxs 2
#define FgColor 3
#define BgColor 0
#define LeftWin_x Sys_x+Horizontal_boxs*BSIZE+46
#define false 0
#define true 1
#define MoveLeft 1
#define MoveRight 2
#define MoveDown 3
#define MoveRoll 4
int current_box_numb;
int Curbox_x=Sys_x+Begin_boxs_x*BSIZE,Curbox_y=Sys_y;
int flag_newbox=false;
int speed=0;
int score=0;
int speed_step=30;
void interrupt (*oldtimer)(void);
struct BOARD
{
int var;
int color;
}Table_board[Vertical_boxs][Horizontal_boxs];
struct SHAPE
{
char box[2];
int color;
int next;
};
struct SHAPE shapes[MAX_BOX]=
{
{0x88,0xc0,CYAN,1},
{0xe8,0x0,CYAN,2},
{0xc4,0x40,CYAN,3},
{0x2e,0x0,CYAN,0},
{0x44,0xc0,MAGENTA,5},
{0x8e,0x0,MAGENTA,6},
{0xc8,0x80,MAGENTA,7},
{0xe2,0x0,MAGENTA,4},
{0x8c,0x40,YELLOW,9},
{0x6c,0x0,YELLOW,8},
{0x4c,0x80,BROWN,11},
{0xc6,0x0,BROWN,10},
{0x4e,0x0,WHITE,13},
{0x8c,0x0,WHITE,14},
{0xe4,0x0,WHITE,15},
{0x4c,0x40,WHITE,12},
{0x88,0x88,RED,17},
{0xf0,0x0,RED,16},
{0xcc,0x0,BLUE,18}
};
void initialize(int x,int y,int m, int n)
{
int i;
int j;
int oldx;
oldx=x;
for(j=0;j<n;j++)
{
for(i=0;i<m;i++)
{
Table_board[j][i].var=0;
Table_board[j][i].color=BgColor;
line(x,y,x+BSIZE,y);
line(x,y,x,y+BSIZE);
line(x,y+BSIZE,x+BSIZE,Y+BSIZE);
line(x+BSIZE,y,x+BSIZE,y+BSIZE);
x+=BSIZE;
}
y+=BSIZE;
x=oldx;
}
Curbox_x=x;
Curbox_y=y;
flag_newbox=false;
speed=0;
score=0;
ShowScore(score);
ShowSpeed(speed);
}
void interruptnewtimer(void)
{
(*oldtimer)();
TimerCounter++;
}
void SetTimer(void interrupt(*IntProc)(void))
{
oldtimer=getvect(TIMER);
disable();
setvect(TIMER,IntProc);
enable();
}
void KillTimer()
{
disable();
setvect(TIMER,oldtimer);
enable();
}
void ShowScore(int score)
{
int x,y;
char score_str[5];
setfillstyle(SOLID_FILL,BgColor);
x=LeftWin_x;
y=100;
bar(x-BSIZE,y,x+BSIZE*3,y+BSIZE*3);
sprintf(score_str,"%3d",score);
outtextxy(x,y,"SCORE");
outtextxy(x,y+10,score_str);
}
void ShowSpeed(int speed)
{
int x,y;
char speed_str[5];
setfillstyle(SOLID_FILL,BgColor);
x=LeftWin_x;
y=150;
bar(x-BSIZE,y,x+BSIZE*3,y+BSIZE*3);
sprintf(speed_str,"%3d",speed+1);
outtextxy(x,y,"Level");
outtextxy(x,y+10,speed_str);
outtextxy(x,y+50,"Nextbox");
}