文档详情

俄罗斯方块 c语言代码qaiywm4f.doc

发布:2018-08-28约1.56万字共14页下载文档
文本预览下载声明
#include stdio.h #include bios.h #include dos.h #include graphics.h #include string.h #include stdlib.h #define true 1 #define false 0 #define BoardWidth 12 #define BoardHeight 23 #define _INNER_HELPER /*inner helper method */ /*Scan Codes Define*/ enum KEYCODES { K_ESC =0x011b, K_UP =0x4800, /* upward arrow */ K_LEFT =0x4b00, K_DOWN =0x5000, K_RIGHT =0x4d00, K_SPACE =0x3920, K_P =0x1970 }; /* the data structure of the block */ typedef struct tagBlock { char c[4][4]; /* cell fill info array, 0-empty, 1-filled */ int x; /* block position cx [ 0,BoardWidht -1] */ int y; /* block position cy [-4,BoardHeight-1] */ char color; /* block color */ char size; /* block max size in width or height */ char name; /* block name (the blocks shape) */ } Block; /* games global info */ int FrameTime= 1300; int CellSize= 18; int BoardLeft= 30; int BoardTop= 30; /* next block grid */ int NBBoardLeft= 300; int NBBoardTop= 30; int NBCellSize= 10; /* score board position */ int ScoreBoardLeft= 300; int ScoreBoardTop=100; int ScoreBoardWidth=200; int ScoreBoardHeight=35; int ScoreColor=LIGHTCYAN; /* infor text postion */ int InfoLeft=300; int InfoTop=200; int InfoColor=YELLOW; int BorderColor=DARKGRAY; int BkGndColor=BLACK; int GameRunning=true; int TopLine=BoardHeight-1; /* top empty line */ int TotalScore=100; char info_score[20]; char info_help[255]; char info_common[255]; /* our board, Board[x][y][0]-isFilled, Board[x][y][1]-fillColor */ unsigned char Board[BoardWidth][BoardHeight][2]; char BufferCells[4][4]; /* used to judge if can rotate block */ Block curBlock; /* current moving block */ Block nextBlock; /* next Block to appear */ /* function list */ int GetKeyCode(); int CanMove(int dx,int dy); int CanRotate(); int RotateBlock(Block *bloc
显示全部
相似文档