#include
#include
#include
#define ESC 27
#define UP 328
#define DOWN 336
#define LEFT 331
#define RIGHT 333
#define BLANK 32
#define BOTTOM 2
#define CANNOT 1
#define CAN 0
#define MAX 30
#define F1 315
#define ADD 43
#define EQUAL 61
#define DEC 45
#define SOUNDs 115
#define SOUNDS 83
#define PAUSEP 80
#define PAUSEp 112
void Init();
void Down();
void GoOn();
void ksdown();
void Display(int color);
void Give();
int Touch(int x,int y,int dx,int dy);
int GeyKey();
void Select();
void DetectFill();
void GetScores();
void Fail();
void Help();
void Quit();
void DrawBox(int x,int y,int Color);
void OutTextXY(int x,int y,char *String);
void DispScore(int x,int y,char Ch);
void DrawNext(int Color);
int Heng=12,Shu=20; /*横竖*/
int Position[MAX][MAX];
int middle[MAX][MAX];
int ActH,ActS;
int Act,Staus;
int i,j,k;
int Wid=10;
int NoPass=CAN;
float Delays=15000;
int BeginH=250,BeginS=7;
float Seconds=0;
int Scores=0;
int flag=1;
int Sounds=CAN;
int PreAct,NextAct;
int a[8][4][4][4]={{{1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0},
{1,1,1,1,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},
{1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0}},
{{1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,1,1,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},
{0,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0},
{1,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0}},
{{1,0,0,0,1,1,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,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0}},
{{0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0},
{1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0},
{0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0},
{1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0}},
{{1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0},
{1,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0},
{1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0},
{0,1,0,0,0,1,0,0,1,1,0,0,0,0,0,0}},
{{0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0},
{1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0},
{1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0}},
{{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}};
int b[4][4];
main(int argc,char *argv[])
{
if (argc!=1)
{
if (argv[1]!="")
Heng=atoi(argv[1]);
if (argv[2]!="")
Shu=atoi(argv[2]);
}
Init(); /*初始化界面*/
PreAct=random(8); /*取得当前的方块*/
for(;;) /*以下是游戏流程*/
{
NextAct=random(8); /*取得下一个方块*/
DrawNext(1); /*画出下一个方块*/
Act=PreAct;
if (Heng%2==0) ActH=Heng/2;
else ActH=(Heng-1)/2;
ActS=0; /*方块开始从游戏空间的中间下落*/
Staus=0; /*取开始的状态*/
NoPass=CAN; /*物体可以下落*/
Give(); /*取得当前的方块*/
Display(Act+1); /*显示当前的方块,每种方块的颜色不同*/
GoOn(); /*游戏的算法精髓所在*/
PreAct=NextAct; /*方块下落完毕,取得下一个方块*/