今天之间网超哥来为大家解答以上的问题。俄罗斯方块c语言教程codeblocks,c语言俄罗斯方块源代码相信很多小伙伴还不知道,现在让我们一起来看看吧!
1、#include #include #include #define mDRAW 5 #define mLINE 6 #define mADOWN 7 #define mGEN 8 #define mLEFT 75 #define mRIGHT 77 #define mSPACE 57 #define mDOWN 80 #define mESC 1 #define TIMEINT 2 #define MAXX 9 #define MAXY 30 #define BACKCOLOR BLACK #define WINX 50 #define WINY 470 #define GAP 6 #define AREAX (WINX+GAP) #define AREAY (WINY-GAP) #define BOXW 15 int oldarea[MAXY+1][MAXX]; int area[MAXY+1][MAXX]; int actW,actH,actX,actY; int curX,curY,curColor,curW,curH; int newX,newY,newColor,newW,newH; int active; int box[4][4]; int FORCOLOR; int MESSAGE; int BOX[7][4][4]={ { {1,1,1,1}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} },{ {1,1,1,0}, {1,0,0,0}, {0,0,0,0}, {0,0,0,0} },{ {1,1,1,0}, {0,0,1,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} },{ {1,1,0,0}, {0,1,1,0}, {0,0,0,0}, {0,0,0,0} },{ {0,1,1,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} } }; void init(); void draw(); int genBox(); int getKey(); void lineFull(); int moveLeft(); int moveRight(); int moveDown(); int rotate(); int getW(); int getH(); void clearOldBox(); void putNewBox(); int collisionRotate(int box[][4]); void getMessage(); void dispatchMessage(); int timeCome(); void fallDown(); int gameOver(); main() { int i; init(); do { getMessage(); dispatchMessage(); } while(!gameOver()); getch(); closegraph(); } void getMessage() { if(MESSAGE) return; if(timeCome()) { MESSAGE=mADOWN; return; } if(bioskey(1)) { MESSAGE=bioskey(0)>>8; return; } } void dispatchMessage() { switch(MESSAGE) { case mLEFT: moveLeft();break; case mRIGHT: moveRight();break; case mADOWN: moveDown();break; case mSPACE: rotate();break; case mDOWN: fallDown(); break; case mDRAW: draw();break; case mLINE: lineFull();break; case mGEN: genBox();break; case mESC: closegraph(); exit(0); default: MESSAGE=0; } } void fallDown() { while(active) { moveDown(); draw(); } MESSAGE=mLINE; } int timeCome() { static long tm, old; tm=biostime(0,tm); if(tm-old
本文就为大家分享到这里,希望小伙伴们会喜欢。