#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include<time.h>
#include<string.h>
#include<dos.h>
#include<bios.h>
#define ESC 0x11b
#define UP 0x4800
#define DOWN 0x5000
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define YES 0x1579
#define NO 0x316e
#define CELL 20
void randompoint();
void nextdraw();
void tempdraw();
void move();
void save();
void showdown();
void showleft();
void showright();
void showup(int select);
void cover();
void draw();
void initigrid();
void scangrid();
void repaint();
void getsave();
/******************dingyi quanju bianliang***********/
int arg[4][2]; //记录初始坐标
int arg2[4][2]={0}; //记录运动中坐标
int block[4][2]={0}; //运动中坐标
int block2[4][2]={0}; //记录下一个方块坐标
int cells[14][21]={0}; //游戏区域每个小方格状态
int top=19;
int key;
int blockid; //panduan dangqian de fangkuai xingzhuang
int blockid2; //record the size of the tempblock
int blockid1;
int flag=0; //jilu xuanzhuan cishu
/**********************han shu shen ming*******************/
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
initigrid();
/* initialize graphics, local variables
*/
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk)
/* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
/* terminate with an error code */
}
/* select drawing color */
setcolor(getmaxcolor());
/* select fill color */
setfillstyle(SOLID_FILL,LIGHTGRAY);
/* draw a border around the screen */
rectangle(60, 60, 300,460);
rectangle(56,56,304,464);
rectangle(400,60,480,140);
rectangle(396,56,484,144);
rectangle(340,260,500,340);
line(340,280,500,280);
line(340,310,500,310);
/* wait for a key */
getch();
/* fill in sunmain region */
floodfill(61,61 , getmaxcolor());//fill the main area color
setfillstyle(SOLID_FILL,LIGHTBLUE);
floodfill(401,61,getmaxcolor()); //set the upright area color
setwritemode(0);
/********draw little retangles************/
for(int i=0;i<20;i++)
line(60,i*CELL+60,300,i*CELL+60);
for(i=0;i<12;i++)
line(i*CELL+60,60,i*CELL+60,460);
/**********draw little retangles of the submain area*****/
for(i=0;i<4;i++)
line(400,i*CELL+60,480,i*CELL+60);
for(i=0;i<4;i++)
line(400+i*CELL,60,400+i*CELL,140);