资源描述:
《小游戏源代码.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、页眉内容/*************************************Desc:俄罗斯方块游戏*By:hoodlum1980:30************************************/#include#include#include#include#include#include#definetrue1#definefalse0#defineBoardWidth12#defineBoar
2、dHeight23#define_INNER_HELPER/*innerhelpermethod*//*ScanCodesDefine*/enumKEYCODES{K_ESC=0x011b,K_UP=0x4800,/*upwardarrow*/K_LEFT=0x4b00,K_DOWN=0x5000,K_RIGHT=0x4d00,K_SPACE=0x3920,K_P=0x1970};/*thedatastructureoftheblock*/typedefstructtagBlock{charc[4][4];/*cellfillin
3、foarray,0-empty,1-filled*/intx;/*blockpositioncx[0,BoardWidht-1]*/inty;/*blockpositioncy[-4,BoardHeight-1]*/charcolor;/*blockcolor*/charsize;/*blockmaxsizeinwidthorheight*/charname;/*blockname(theblock'sshape)*/}Block;/*game'sglobalinfo*/intFrameTime=1300;intCellSize=
4、18;intBoardLeft=30;intBoardTop=30;/*nextblockgrid*/精心整理页眉内容intNBBoardLeft=300;intNBBoardTop=30;intNBCellSize=10;/*scoreboardposition*/intScoreBoardLeft=300;intScoreBoardTop=100;intScoreBoardWidth=200;intScoreBoardHeight=35;intScoreColor=LIGHTCYAN;/*infortextpostion*/i
5、ntInfoLeft=300;intInfoTop=200;intInfoColor=YELLOW;intBorderColor=DARKGRAY;intBkGndColor=BLACK;intGameRunning=true;intTopLine=BoardHeight-1;/*topemptyline*/intTotalScore=100;charinfo_score[20];charinfo_help[255];charinfo_common[255];/*ourboard,Board[x][y][0]-isFilled,B
6、oard[x][y][1]-fillColor*/unsignedcharBoard[BoardWidth][BoardHeight][2];charBufferCells[4][4];/*usedtojudgeifcanrotateblock*/BlockcurBlock;/*currentmovingblock*/BlocknextBlock;/*nextBlocktoappear*//*functionlist*/intGetKeyCode();intCanMove(intdx,intdy);intCanRotate();i
7、ntRotateBlock(Block*block);intMoveBlock(Block*block,intdx,intdy);voidDrawBlock(Block*block,int,int,int);voidEraseBlock(Block*block,int,int,int);voidDisplayScore();voidDisplayInfo(char*text);voidGenerateBlock(Block*block);voidNextBlock();voidInitGame();intPauseGame();v
8、oidQuitGame();/*GetKeyCode*/int_INNER_HELPERGetKeyCode(){intkey=0;if(bioskey(1))精心整理页眉内容{key=bioskey(0);}returnkey;}/*displa