{"id":7751,"date":"2024-07-07T18:01:01","date_gmt":"2024-07-07T10:01:01","guid":{"rendered":""},"modified":"2024-07-07T18:01:01","modified_gmt":"2024-07-07T10:01:01","slug":"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801","status":"publish","type":"post","link":"https:\/\/mushiming.com\/7751.html","title":{"rendered":"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801"},"content":{"rendered":"

\u76ee\u5f55<\/strong><\/p>\n

\n

\u524d\u8a00<\/p>\n

\u4e00\u3001\u6e38\u620f\u622a\u56fe\u548c\u5168\u90e8\u4ee3\u7801<\/p>\n

1.\u6e38\u620f\u622a\u56fe<\/p>\n

2.\u6e90\u4ee3\u7801<\/p>\n

\u5934\u6587\u4ef6\u4ee3\u7801<\/p>\n

cpp\u6587\u4ef6\u4ee3\u7801<\/p>\n

\u4e8c\u3001easyX\u5e93\u5b89\u88c5<\/p>\n

\u4e09\u3001\u5b8f\u5b9a\u4e49\u3001\u53d8\u91cf\u7684\u8bf4\u660e<\/p>\n

1.\u65b9\u5757\u50cf\u7d20<\/p>\n

2.\u6e38\u620f\u5730\u56fe\u533a\u57df<\/p>\n

3.\u9884\u751f\u6210\u65b9\u5757\u533a\u57df<\/p>\n

4.\u73a9\u5bb6\u6570\u636e\u7ed3\u6784<\/p>\n

5.\u6240\u6709\u65b9\u5757\u6570\u636e\u5e93<\/p>\n

6.\u5f53\u524d\u63a7\u5236\u65b9\u5757\u6570\u636e\u7ed3\u6784<\/p>\n

\u56db\u3001\u4e3b\u51fd\u6570tetrisrun()<\/p>\n

\u4e94\u3001\u4ee3\u7801\u548c\u6240\u6709\u51fd\u6570\u8bf4\u660e<\/p>\n

1. tetrisInit()<\/p>\n

2.tetrisDraw()<\/p>\n

3.tetrisNewBlock() \u51fd\u6570<\/p>\n

4.tetrisMoveUp() \u51fd\u6570<\/p>\n

5.tetrisMoveDown() \u51fd\u6570<\/p>\n

6.tetrisMoveLeft() \u51fd\u6570<\/p>\n

7.tetrisMoveRight() \u51fd\u6570<\/p>\n

8.tetrisLoadBlock() \u51fd\u6570<\/p>\n

9.tetrisIsOver() \u51fd\u6570<\/p>\n

10.tetrisQuit() \u51fd\u6570<\/p>\n

11.tetrisKeyHandle() \u51fd\u6570<\/p>\n

12.tetrisReset() \u51fd\u6570<\/p>\n

13.tetrisRemove() \u51fd\u6570<\/p>\n

\u603b\u7ed3<\/p>\n<\/div>\n


\n

\u524d\u8a00<\/h2>\n

\u4f7f\u7528easyX\u5e93\uff0c\u57fa\u4e8ec\/c++\uff0c\u5b9e\u73b0\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f\u3002<\/p>\n

\u4f5c\u8005\u4f7f\u7528\u7684\u662fVS2010\u7248\u672c\uff0cVS2019\u7248\u672c\u4e5f\u53ef\u7528\u3002<\/p>\n


\n

\u4e00\u3001\u6e38\u620f\u622a\u56fe\u548c\u5168\u90e8\u4ee3\u7801<\/strong><\/p>\n

    \n
  • \n

    1.\u6e38\u620f\u622a\u56fe<\/h3>\n<\/li>\n<\/ul>\n

    \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801\"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n

    \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n

    \n

      \n
    • \n

      2.\u6e90\u4ee3\u7801<\/h3>\n<\/li>\n<\/ul>\n
      \n

      \u53ef\u76f4\u63a5\u62f7\u8d1d\uff0c\u5e76\u8fd0\u884c\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f<\/p>\n<\/blockquote>\n

        \n
      • \n

        \u5934\u6587\u4ef6\u4ee3\u7801<\/h4>\n<\/li>\n<\/ul>\n
        #pragma once #define GAMEMAP1 200 \/\/ \u9884\u751f\u6210\u65b9\u5757\u533a\u57df #define GAMEMAP2 10 #define GAMEMAP3 500 #define GAMEMAP4 610 #define GAMEMAP5 40 \/\/ \u6e38\u620f\u5730\u56fe\u533a\u57df #define GAMEMAP6 50 #define GAMEMAP7 140 #define GAMEMAP8 130 #define GAMEGUIDE1 40 \/\/ \u6309\u952e\u8bf4\u660e #define GAMEGUIDE2 300 #define GAMEGUIDE3 150 #define GAMEGUIDE4 440 #define GAMELEVEL1 30 \/\/ \u6e38\u620f\u7b49\u7ea7\u533a\u57df #define GAMELEVEL2 160 #define GAMERANK1 30 \/\/ \u6e38\u620frank\u5206\u6570 #define GAMERANK2 190 #define TETRISWIDTH 15 \/\/ \u6e38\u620f\u5730\u56fe\u5bbd #define TETRISHEIGHT 30 \/\/ \u6e38\u620f\u5730\u56fe\u9ad8 #define BLOCKTYPE 8 \/\/ \u65b9\u5757\u79cd\u7c7b\u6570 #define BLOCKSTYLE 4 \/\/ \u6bcf\u79cd\u65b9\u5757\u7684\u6837\u5f0f\u6570 #define BLOCKSPACE 20 \/\/ \u65b9\u5757\u5360\u7528\u7a7a\u95f4 5 x 4 #define SIDELENGTH 20 \/\/ \u65b9\u5757\u8fb9\u957f 20 \u50cf\u7d20 #define ESC 27 #define CLEARKEY(); { while(_kbhit()) { _getch(); } } \/\/ \u6e05\u9664\u6309\u952e\u8f93\u5165\u7f13\u5b58 enum BLOCKCOLER { BLOCKNONE, BLOCKBLUE, BLOCKGREEN, BLOCKCYAN, BLOCKRED, BLOCKMAGENTA, BLOCKBROWN, BLOCKYELLOW, }; typedef struct _GAME_TETRIS { int ttime; \/\/ \u8ba1\u65f6 int ctime; \/\/ \u8ba1\u65f6 int level; \/\/ \u5f53\u524d\u6e38\u620f\u7b49\u7ea7 int rank; \/\/ \u5f53\u524d\u6e38\u620f\u5206\u6570 int key; \/\/ \u73a9\u5bb6\u6309\u952e\u503c int blockType; \/\/ \u5f53\u524d\u65b9\u5757\u7c7b\u578b int blockStyle; \/\/ \u5f53\u524d\u65b9\u5757\u671d\u5411 bool moveFlag; \/\/ \u79fb\u52a8\u6807\u8bc6\uff0c\u6807\u8bc6\u4e3a1\u65f6\uff0c\u79fb\u52a8\u5f53\u524d\u65b9\u5757 bool newBlockFlag; \/\/ \u8f7d\u5165\u65b0\u65b9\u5757\u6807\u8bc6\uff0c\u5f53\u6807\u8bc6\u4e3a\u771f\u65f6\uff0c\u5c06\u9884\u751f\u6210\u7684\u968f\u673a\u65b9\u5757\u8f7d\u5165\u5730\u56fe bool gameOverFlag; \/\/ \u6e38\u620f\u7ed3\u675f\u6807\u8bc6 }GAME_TETRIS; typedef struct _GAME_PREBLOCK { int tetrisPreBlock[BLOCKSPACE]; \/\/ \u9884\u751f\u6210\u7684\u65b9\u5757\u6570\u7ec4 int blockType,blockStyle; \/\/ \u9884\u751f\u6210\u65b9\u5757\u7684\u7c7b\u578b\u548c\u671d\u5411 }GAME_PREBLOCK; typedef struct _GAME_MOVE_BLOCK { int blockSite[4][2]; \/\/ 4\u4e2a\u65b9\u5757\u683c\u5750\u6807 int blockColor; \/\/ \u65b9\u5757\u989c\u8272 }GAME_MOVE_BLOCK; void tetrisrun(void); void tetrisInit(void); void tetrisDraw(void); void tetrisNewBlock(void); void tetrisMoveUp(void); void tetrisMoveDown(void); void tetrisMoveLeft(void); void tetrisMoveRight(void); void tetrisLoadBlock(void); void tetrisIsOver(void); void tetrisQuit(void); void tetrisKeyHandle(void); void tetrisReset(void); void tetrisRemove(void); <\/code><\/pre>\n
          \n
        • \n

          cpp\u6587\u4ef6\u4ee3\u7801<\/h4>\n<\/li>\n<\/ul>\n
          #include \"stdafx.h\" #include \"tetrisnew.h\" #include<graphics.h> #include<conio.h> #include<stdio.h> #include<time.h> \/\/ \u6240\u6709\u65b9\u5757\u6570\u7ec4\u5e93 const int block[BLOCKTYPE][BLOCKSTYLE][BLOCKSPACE] = { \/\/ \u603b\u5171\u67098\u79cd\u65b9\u5757\uff0c\u6bcf\u79cd\u65b9\u5757\u67094\u79cd\u6837\u5f0f \/\/ 'I'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKBLUE, BLOCKBLUE, BLOCKBLUE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE }, { BLOCKBLUE, BLOCKBLUE, BLOCKBLUE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE } }, \/\/ 'Z'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ \u53cd'Z'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ 'T'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ 'T'\u5f62\u65b9\u5757 X 2 \u589e\u52a0T\u5f62\u65b9\u5757\u51fa\u73b0\u6982\u7387 { { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ '\u7530'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ 'L'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKBROWN, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKBROWN, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKBROWN, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ \u53cd'L'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKYELLOW,BLOCKYELLOW, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKYELLOW,BLOCKYELLOW,BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } } }; \/\/ \u6e38\u620f\u5b9e\u65f6\u753b\u9762 int tetrisMap[TETRISHEIGHT][TETRISWIDTH] = { }; GAME_TETRIS player; \/\/ \u73a9\u5bb6\u6570\u636e GAME_PREBLOCK preBlock; \/\/ \u9884\u751f\u6210\u65b9\u5757\u6570\u636e GAME_MOVE_BLOCK moveBlock; \/\/ \u5f53\u524d\u63a7\u5236\u65b9\u5757\u6570\u636e int main(void) { tetrisrun(); return 0; } void tetrisrun(void) { tetrisInit(); while(1) { player.ctime = GetTickCount(); if( (player.ctime - 500 + 30*player.level) > player.ttime ) { player.moveFlag = TRUE; player.ttime = GetTickCount(); } if(player.moveFlag) { player.moveFlag = FALSE; tetrisMoveDown(); tetrisDraw(); } if(_kbhit()) { player.key = _getch(); tetrisKeyHandle(); } if(player.newBlockFlag) { player.newBlockFlag = FALSE; tetrisLoadBlock(); tetrisRemove(); tetrisNewBlock(); tetrisIsOver(); } if(player.gameOverFlag) { player.gameOverFlag = FALSE; break; } } } void tetrisInit(void) { int i,j,k; HWND window = initgraph(510, 620); SetWindowText(window, \"\u4fc4\u7f57\u65af\u65b9\u5757 - by\u8012\u9633\u963f\u6770\"); \/\/SetWindowPos(window,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); rectangle(GAMEMAP1 - 2,GAMEMAP2 - 2,GAMEMAP3 + 2,GAMEMAP4 + 2); rectangle(GAMEMAP5 - 2,GAMEMAP6 - 2,GAMEMAP7 + 2,GAMEMAP8 + 2); rectangle(GAMEGUIDE1 - 5,GAMEGUIDE2 - 5,GAMEGUIDE3 + 5,GAMEGUIDE4 + 5); outtextxy(GAMEMAP5 + 10 ,GAMEMAP6 - 26,\"\u4e0b\u4e2a\u65b9\u5757\"); settextcolor(GREEN); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 ,\"W \uff1a\u6539\u53d8\u5f62\u72b6\"); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 25 ,\"A \uff1a\u65b9\u5757\u5de6\u79fb\"); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 50 ,\"S \uff1a\u65b9\u5757\u53f3\u79fb\"); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 75 ,\"D \uff1a\u65b9\u5757\u4e0b\u79fb\"); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 100 ,\"R \uff1a\u91cd\u65b0\u5f00\u59cb\"); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 125 ,\"ESC\uff1a\u9000\u51fa\u6e38\u620f\"); memset ( &player, 0, sizeof ( GAME_TETRIS ) ); memset ( &preBlock, 0, sizeof ( GAME_PREBLOCK ) ); memset(tetrisMap,0,sizeof(tetrisMap)); player.ttime = GetTickCount(); srand((unsigned)time(NULL)); i = (rand() + 1) % BLOCKTYPE; j = rand() % BLOCKSTYLE; for(k = 0; k < BLOCKSPACE;k++) { preBlock.tetrisPreBlock[k] = block[i][j][k]; } preBlock.blockType = i; preBlock.blockStyle = j; tetrisNewBlock(); } void tetrisDraw(void) { int i,j; int x,y; char ch[20]; settextstyle(20,12,\"\u5b8b\u4f53\"); settextcolor(CYAN); if(player.level < 10) { sprintf_s(ch, \"%s%d\",\"LEVEL\uff1a\", player.level); } else { sprintf_s(ch, \"%s\",\"LEVEL\uff1aMAX\"); } outtextxy(GAMELEVEL1,GAMELEVEL2,ch); settextcolor(LIGHTBLUE); sprintf_s(ch, \"%s%d\",\"RANK\uff1a\", player.rank); outtextxy(GAMERANK1,GAMERANK2,ch); setfillcolor(BLACK); solidrectangle(GAMEMAP5,GAMEMAP6,GAMEMAP7,GAMEMAP8); for(i = 0; i < BLOCKSPACE; i++) { switch(preBlock.tetrisPreBlock[i]) { case BLOCKNONE: continue; break; case BLOCKBLUE: setfillcolor(BLUE); break; case BLOCKGREEN: setfillcolor(GREEN); break; case BLOCKCYAN: setfillcolor(CYAN); break; case BLOCKRED: setfillcolor(RED); break; case BLOCKMAGENTA: setfillcolor(MAGENTA); break; case BLOCKBROWN: setfillcolor(BROWN); break; case BLOCKYELLOW: setfillcolor(YELLOW); break; } fillrectangle(GAMEMAP5 + (i%5) * SIDELENGTH ,GAMEMAP6 + (i\/5) * SIDELENGTH ,GAMEMAP5 + ((i%5)+1)*SIDELENGTH ,GAMEMAP6 + ((i\/5)+1) * SIDELENGTH ); } setfillcolor(BLACK); solidrectangle(GAMEMAP1,GAMEMAP2,GAMEMAP3,GAMEMAP4); for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0]; y = moveBlock.blockSite[i][1]; switch(moveBlock.blockColor) { case BLOCKNONE: continue; break; case BLOCKBLUE: setfillcolor(BLUE); break; case BLOCKGREEN: setfillcolor(GREEN); break; case BLOCKCYAN: setfillcolor(CYAN); break; case BLOCKRED: setfillcolor(RED); break; case BLOCKMAGENTA: setfillcolor(MAGENTA); break; case BLOCKBROWN: setfillcolor(BROWN); break; case BLOCKYELLOW: setfillcolor(YELLOW); break; } fillrectangle(GAMEMAP1 + y * SIDELENGTH ,GAMEMAP2 + x * SIDELENGTH ,GAMEMAP1 + (y+1)*SIDELENGTH ,GAMEMAP2 + (x+1) * SIDELENGTH ); } for(i = 0; i < TETRISHEIGHT; i++) { for(j = 0; j < TETRISWIDTH; j++) { switch(tetrisMap[i][j]) { case BLOCKNONE: continue; break; case BLOCKBLUE: setfillcolor(BLUE); break; case BLOCKGREEN: setfillcolor(GREEN); break; case BLOCKCYAN: setfillcolor(CYAN); break; case BLOCKRED: setfillcolor(RED); break; case BLOCKMAGENTA: setfillcolor(MAGENTA); break; case BLOCKBROWN: setfillcolor(BROWN); break; case BLOCKYELLOW: setfillcolor(YELLOW); break; } fillrectangle(GAMEMAP1 + j * SIDELENGTH ,GAMEMAP2 + i * SIDELENGTH ,GAMEMAP1 + (j+1)*SIDELENGTH ,GAMEMAP2 + (i+1) * SIDELENGTH ); } } } void tetrisNewBlock(void) { int i,j,k; k = 0; for(i = 0; i < BLOCKSPACE; i++) { if(preBlock.tetrisPreBlock[i]) { moveBlock.blockColor = preBlock.tetrisPreBlock[i]; moveBlock.blockSite[k][0] = i\/5; moveBlock.blockSite[k][1] = 5 + i%5; k++; } } player.blockType = preBlock.blockType; player.blockStyle = preBlock.blockStyle; srand((unsigned)time(NULL)); i = rand() % BLOCKTYPE; j = rand() % BLOCKSTYLE; for(k = 0; k < BLOCKSPACE;k++) { preBlock.tetrisPreBlock[k] = block[i][j][k]; } preBlock.blockType = i; preBlock.blockStyle = j; } void tetrisMoveUp(void) { int i,k; int bStyle; int ux,uy; \/\/ \u6539\u53d8\u65b9\u5757\u671d\u5411\u524d\u540e\uff0c\u65b9\u5757\u683c\u7684\u4f4d\u79fb\u77e2\u91cf int blocksite2[4][2]; \/\/ \u8bb0\u5f55\u6539\u53d8\u671d\u5411\u524d\uff0c4\u4e2a\u65b9\u5757\u7684\u65b9\u5757\u5e93\u5750\u6807 int blocksite3[4][2]; \/\/ \u8bb0\u5f55\u6539\u53d8\u671d\u5411\u540e\uff0c4\u4e2a\u65b9\u5757\u7684\u65b9\u5757\u5e93\u5750\u6807 int blocksite4[4][2]; \/\/ \u8bb0\u5f55\u6539\u53d8\u671d\u5411\u540e\uff0c4\u4e2a\u65b9\u5757\u7684\u6e38\u620f\u5730\u56fe\u5750\u6807 k = 0; for(i = 0; i < BLOCKSPACE; i++) { if(k > 3) { break; } if(block[player.blockType][player.blockStyle][i]) { blocksite2[k][0] = i \/ 5; blocksite2[k][1] = i % 5; k++; } } k = 0; bStyle = (player.blockStyle + 1)%BLOCKSTYLE; for(i = 0; i < BLOCKSPACE; i++) { if(k > 3) { break; } if(block[player.blockType][bStyle][i]) { blocksite3[k][0] = i \/ 5; blocksite3[k][1] = i % 5; k++; } } for(i = 0; i < 4; i++) { ux = blocksite3[i][0] - blocksite2[i][0]; uy = blocksite3[i][1] - blocksite2[i][1]; blocksite4[i][0] = moveBlock.blockSite[i][0] + ux; blocksite4[i][1] = moveBlock.blockSite[i][1] + uy; if( (blocksite4[i][0] < 0) || (blocksite4[i][1] < 0) || (blocksite4[i][0] > TETRISHEIGHT - 1) || (blocksite4[i][1] > TETRISWIDTH - 1) || ( tetrisMap[blocksite4[i][0]][blocksite4[i][1]] ) ) { return; } } for(i = 0;i < 4; i++) { moveBlock.blockSite[i][0] = blocksite4[i][0]; moveBlock.blockSite[i][1] = blocksite4[i][1]; } player.blockStyle = bStyle; } void tetrisMoveDown(void) { int i; int x,y; for(i = 0; i < 4; i++) { if(moveBlock.blockSite[i][0] > TETRISHEIGHT - 2) { player.newBlockFlag = TRUE; return; } } for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0] + 1; y = moveBlock.blockSite[i][1]; if(tetrisMap[x][y]) { player.newBlockFlag = TRUE; return; } } for(i = 0; i < 4; i++) { moveBlock.blockSite[i][0]++; } } void tetrisMoveLeft(void) { int i; int x,y; for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0]; y = moveBlock.blockSite[i][1]; if( (y - 1) < 0 || tetrisMap[x][y - 1]) { return; } } for(i = 0; i < 4; i++) { moveBlock.blockSite[i][1]--; } } void tetrisMoveRight(void) { int i; int x,y; \/\/k = 0; for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0]; y = moveBlock.blockSite[i][1]; if( ((y + 1) >= TETRISWIDTH) || (tetrisMap[x][y + 1]) ) { return; } } for(i = 0; i < 4; i++) { moveBlock.blockSite[i][1]++; } } void tetrisLoadBlock(void) { int i; int x,y; for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0]; y = moveBlock.blockSite[i][1]; if(!tetrisMap[x][y]) { tetrisMap[x][y] = moveBlock.blockColor; } } } void tetrisIsOver(void) { int i; int x,y; for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0]; y = moveBlock.blockSite[i][1]; if(tetrisMap[x][y]) { player.gameOverFlag = TRUE; tetrisDraw(); tetrisQuit(); return; } } } void tetrisQuit(void) { int key,flag; flag = player.gameOverFlag; key = MessageBox(NULL,\"\u662f\u5426\u9000\u51fa\u6e38\u620f\uff1f\",\"\u63d0\u793a\",MB_YESNO| MB_SYSTEMMODAL); switch(key) { case IDYES: player.gameOverFlag = TRUE; break; case IDNO: player.gameOverFlag = FALSE; break; default: break; } while(flag && !player.gameOverFlag) { key = MessageBox(NULL,\"\u68c0\u6d4b\u5230\u6e38\u620f\u5df2\u65e0\u6cd5\u7ee7\u7eed\uff0c\\n\u8bf7\u9009\u62e9\\\"\u662f\\\": \u9000\u51fa\u6e38\u620f\uff1b\\n\u6216\u8005\u9009\u62e9\\\"\u5426\\\": \u91cd\u542f\u6e38\u620f\uff1b\",\"\u63d0\u793a\",MB_YESNO| MB_SYSTEMMODAL); switch(key) { case IDYES: player.gameOverFlag = TRUE; break; case IDNO: tetrisInit(); player.gameOverFlag = FALSE; return; default: break; } } CLEARKEY(); } void tetrisKeyHandle(void) { switch(player.key) { case 'w': case 'W': tetrisMoveUp(); break; case 'a': case 'A': tetrisMoveLeft(); break; case 's': case 'S': player.moveFlag = TRUE; player.ttime = GetTickCount(); return; case 'd': case 'D': tetrisMoveRight(); break; case ESC: tetrisQuit(); break; case 'r': case 'R': tetrisReset(); break; default: break; } tetrisDraw(); } void tetrisReset(void) { int key; key = MessageBox(NULL,\"\u662f\u5426\u91cd\u65b0\u5f00\u59cb\u6e38\u620f\uff1f\",\"\u63d0\u793a\",MB_YESNO| MB_SYSTEMMODAL); CLEARKEY(); switch(key) { case IDYES: tetrisInit(); break; case IDNO: break; default: break; } } void tetrisRemove(void) { int i,j,m,n; int flag,bnum; bnum = 0; for(i = TETRISHEIGHT - 1; i >= 0; i-- ) { flag = 0; for(j = 0; j < TETRISWIDTH; j++) { if(!tetrisMap[i][j]) { flag = 1; break; } } if(flag) { continue; } bnum++; for(j = 0; j < TETRISWIDTH; j++) { tetrisMap[i][j] = BLOCKNONE; } for(m = i; m > 0; m--) { for(n = 0; n < TETRISWIDTH; n++) { tetrisMap[m][n] = tetrisMap[m - 1][n]; } } i++; } if(!bnum) { return; } switch(bnum) { case 0: break; case 1: player.rank += 10; break; case 2: player.rank += 20; break; case 3: player.rank += 40; break; case 4: player.rank += 80; break; default: break; } player.level = player.rank\/100; if(player.level > 10) { player.level = 10; } } <\/code><\/pre>\n

          \u4e8c\u3001easyX\u5e93\u5b89\u88c5<\/h2>\n

          EasyX Graphics Library for C++<\/p>\n

          \u8fdb\u5165\u4ee5\u4e0a\u94fe\u63a5\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5easyX\u5e93<\/p>\n

          \u4e09\u3001\u5b8f\u5b9a\u4e49\u3001\u53d8\u91cf\u7684\u8bf4\u660e<\/h2>\n
            \n
          • \n

            1.\u65b9\u5757\u50cf\u7d20<\/h4>\n<\/li>\n<\/ul>\n

            \u65b9\u5757\u4e3a\u6b63\u65b9\u5f62\uff0c\u5927\u5c0f\u4e3a20X20\u50cf\u7d20<\/p>\n

            #define SIDELENGTH 20<\/code><\/pre>\n
              \n
            • \n

              2.\u6e38\u620f\u5730\u56fe\u533a\u57df<\/h4>\n<\/li>\n<\/ul>\n

              \u6e38\u620f\u5730\u56fe\u4e3a\u77e9\u5f62\uff0c\u5927\u5c0f\u4e3a600X300\u50cf\u7d20\uff0c\u56db\u4e2a\u89d2\u5750\u6807\u4e3a\u4e0b\u9762\u7684\u5b8f\u5b9a\u4e49\u3002<\/p>\n

              #define GAMEMAP1 200 #define GAMEMAP2 10 #define GAMEMAP3 500 #define GAMEMAP4 610<\/code><\/pre>\n

               \u4f7f\u7528rectangle\u51fd\u6570\uff0c\u586b\u5165\u56db\u4e2a\u89d2\u5750\u6807\uff0c\u753b\u51fa\u6e38\u620f\u5730\u56fe\u8fb9\u754c<\/p>\n

              rectangle(GAMEMAP1 - 2,GAMEMAP2 - 2,GAMEMAP3 + 2,GAMEMAP4 + 2);<\/code><\/pre>\n

               \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n

              \u628a\u5730\u56fe\u630920X20\u50cf\u7d20\u5206\u5272\uff0c\u5c31\u662f30X15\u4e2a\u65b9\u5757\uff0c\u8fd9\u6837\u5c31\u628a\u5730\u56fe\u8f6c\u6362\u4e3a\u5750\u6807\u7684\u5f62\u5f0f\u4e86\uff0c\u9009\u4e2d\u4e00\u4e2a\u65b9\u5757\u683c\uff0c\u518d\u8fdb\u884c\u6d82\u8272\uff0c\u5c31\u662f\u4e00\u4e2a\u76f8\u5e94\u7684\u65b9\u5757\u4e86\u3002<\/p>\n

                \n
              • \n

                3.\u9884\u751f\u6210\u65b9\u5757\u533a\u57df<\/h4>\n<\/li>\n<\/ul>\n

                \u9884\u751f\u6210\u65b9\u5757\u533a\u57df\u4e3a100X80\u50cf\u7d20\u7684\u77e9\u5f62\uff0c\u56db\u4e2a\u89d2\u5750\u6807\u5982\u4e0b\u5b8f\u5b9a\u4e49<\/p>\n

                #define GAMEMAP5 40 \/\/ \u9884\u751f\u6210\u65b9\u5757\u533a\u57df #define GAMEMAP6 50 #define GAMEMAP7 140 #define GAMEMAP8 130<\/code><\/pre>\n

                \u4f7f\u7528rectangle\u51fd\u6570\uff0c\u586b\u5165\u56db\u4e2a\u89d2\u5750\u6807\uff0c\u753b\u51fa\u6e38\u620f\u5730\u56fe\u8fb9\u754c<\/p>\n

                rectangle(GAMEMAP5 - 2,GAMEMAP6 - 2,GAMEMAP7 + 2,GAMEMAP8 + 2); <\/code><\/pre>\n<\/p>\n

                \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801\"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n<\/p>\n

                \u628a\u533a\u57df\u6309\u716720X20\u50cf\u7d20\u5206\u5272\uff0c\u5c31\u662f4X5\u4e2a\u65b9\u5757\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u8f6c\u6362\u4e3a\u5750\u6807\u7684\u5f62\u5f0f\uff1b<\/p>\n

                \u6839\u636e\u968f\u673a\u5f97\u5230\u7684\u65b9\u5757\u79cd\u7c7b\uff0c\u6362\u7b97\u6210\u56db\u4e2a\u5750\u6807\uff0c\u518d\u9009\u62e9\u989c\u8272\u8fdb\u884c\u586b\u5145\uff0c\u5c31\u53ef\u4ee5\u5f97\u5230\u9884\u751f\u6210\u7684\u65b9\u5757\u4e86\u3002<\/p>\n

                  \n
                • \n

                  4.\u73a9\u5bb6\u6570\u636e\u7ed3\u6784<\/h4>\n<\/li>\n<\/ul>\n
                  typedef struct _GAME_TETRIS { int ttime; \/\/ \u8ba1\u65f6 int ctime; \/\/ \u8ba1\u65f6 int level; \/\/ \u5f53\u524d\u6e38\u620f\u7b49\u7ea7 int rank; \/\/ \u5f53\u524d\u6e38\u620f\u5206\u6570 int key; \/\/ \u73a9\u5bb6\u6309\u952e\u503c int blockType; \/\/ \u5f53\u524d\u65b9\u5757\u7c7b\u578b int blockStyle; \/\/ \u5f53\u524d\u65b9\u5757\u671d\u5411 bool moveFlag; \/\/ \u79fb\u52a8\u6807\u8bc6\uff0c\u6807\u8bc6\u4e3a1\u65f6\uff0c\u79fb\u52a8\u5f53\u524d\u65b9\u5757 bool newBlockFlag; \/\/ \u8f7d\u5165\u65b0\u65b9\u5757\u6807\u8bc6\uff0c\u5f53\u6807\u8bc6\u4e3a\u771f\u65f6\uff0c\u5c06\u9884\u751f\u6210\u7684\u968f\u673a\u65b9\u5757\u8f7d\u5165\u5730\u56fe bool gameOverFlag; \/\/ \u6e38\u620f\u7ed3\u675f\u6807\u8bc6 }GAME_TETRIS;<\/code><\/pre>\n
                  \n

                  GAME_TETRIS        player;        \/\/ \u73a9\u5bb6\u6570\u636e<\/p>\n<\/blockquote>\n

                  player\u4f1a\u4fdd\u5b58\u73a9\u5bb6\u5728\u6e38\u620f\u4e2d\u7684\u6570\u636e\uff0cttime\u548cctime\u662f\u7528\u6765\u5b9a\u65f6\u7684\uff0c\u6bcf\u9694\uff08500ms - \u7b49\u7ea7*30\u6beb\u79d2\uff09\uff0c\u4f1a\u5c06moveflag\u7f6e1\uff0c\u65b9\u5757\u4e0b\u964d\u4e00\u884c\uff1b<\/p>\n

                  level\u548crank\u662f\u73a9\u5bb6\u5f53\u524d\u83b7\u5f97\u5206\u6570\uff0c\u5df2\u7ecf\u6839\u636e\u5206\u6570\u5f97\u5230\u7684level\uff1b<\/p>\n

                  key\u662f\u73a9\u5bb6\u6309\u4e0b\u7684\u952e\u76d8\u8f93\u5165\u503c\uff1b<\/p>\n

                  blockType\u548cblockStyle\u662f\u73a9\u5bb6\u5f53\u524d\u63a7\u5236\u65b9\u5757\u7684\u65b9\u5757\u7c7b\u578b\u548c\u65b9\u5757\u671d\u5411\uff0c\u7528\u6765\u5224\u5b9a\u65b9\u5757\u662f\u5426\u53ef\u4ee5\u5de6\u3001\u53f3\u3001\u4e0b\u79fb\u3001\u53d8\u6362\u5f62\u6001\uff1b<\/p>\n

                  moveflag\uff0c\u79fb\u52a8\u6807\u8bc6\uff0c\u6807\u8bc6\u4e3a1\u65f6\uff0c\u5f53\u524d\u65b9\u5757\u4f1a\u4e0b\u79fb\u4e00\u884c\uff1b<\/p>\n

                  bewBlockFlag\uff0c\u65b0\u65b9\u5757\u6807\u8bc6\uff0c\u6807\u8bc6\u4e3a1\u65f6\uff0c\u4f1a\u6267\u884c\u4ee5\u4e0b\u51fd\u6570\uff1a\u5f53\u524d\u65b9\u5757\u8f7d\u5165\u6e38\u620f\u5730\u56fe\u3001\u6d88\u9664\u6ee1\u884c\u7684\u65b9\u5757\u3001\u751f\u6210\u65b0\u7684\u65b9\u5757\u3001\u5224\u65ad\u6e38\u620f\u662f\u5426\u7ed3\u675f\uff1b<\/p>\n

                  gameOverFlag\uff0c\u6e38\u620f\u7ed3\u675f\u6807\u8bc6\uff0c\u6807\u8bc6\u4e3a1\u65f6\uff0c\u4f1a\u8ba9\u73a9\u5bb6\u9009\u62e9\u7ed3\u675f\u6e38\u620f\uff0c\u6216\u91cd\u65b0\u5f00\u59cb\u6e38\u620f<\/p>\n

                    \n
                  • \n

                    5.\u6240\u6709\u65b9\u5757\u6570\u636e\u5e93<\/h4>\n<\/li>\n<\/ul>\n

                    \u6570\u636e\u5e93\u662f\u4e00\u4e2a\u4e09\u7ef4\u6570\u7ec4<\/p>\n

                    \u603b\u5171\u67098\u79cd\u7c7b\u578b\u7684\u65b9\u5757\uff0c\u6bcf\u4e2a\u7c7b\u578b\u7684\u65b9\u5757\u989c\u8272\u90fd\u4e0d\u4e00\u6837\uff1b\u6bcf\u4e2a\u65b9\u5757\u67094\u4e2a\u6837\u5f0f\uff08\u671d\u5411\uff09\uff1b\u6bcf\u79cd\u65b9\u5757\u7684\u6bcf\u79cd\u671d\u5411\u90fd\u662f\u4e00\u4e2a5X4\u7684\u65b9\u5757\u77e9\u5f62\u3002<\/p>\n

                    \u751f\u6210\u65b0\u65b9\u5757\u65f6\uff0c\u5c31\u4f1a\u4ece\u65b9\u5757\u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u65b9\u5757\u6570\u636e\u3002<\/p>\n

                    #define BLOCKTYPE 8 \/\/ \u65b9\u5757\u79cd\u7c7b\u6570 #define BLOCKSTYLE 4 \/\/ \u6bcf\u79cd\u65b9\u5757\u7684\u6837\u5f0f\u6570 #define BLOCKSPACE 20 \/\/ \u65b9\u5757\u5360\u7528\u7a7a\u95f4 5 x 4<\/code><\/pre>\n
                    const int block[BLOCKTYPE][BLOCKSTYLE][BLOCKSPACE] = { \/\/ \u603b\u5171\u67098\u79cd\u65b9\u5757\uff0c\u6bcf\u79cd\u65b9\u5757\u67094\u79cd\u6837\u5f0f \/\/ 'I'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKBLUE, BLOCKBLUE, BLOCKBLUE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE }, { BLOCKBLUE, BLOCKBLUE, BLOCKBLUE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBLUE, BLOCKNONE, BLOCKNONE } }, \/\/ 'Z'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKGREEN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ \u53cd'Z'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKCYAN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ 'T'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ 'T'\u5f62\u65b9\u5757 X 2 \u589e\u52a0T\u5f62\u65b9\u5757\u51fa\u73b0\u6982\u7387 { { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKRED, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ '\u7530'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKMAGENTA,BLOCKMAGENTA,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ 'L'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKBROWN, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKBROWN, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKBROWN, BLOCKBROWN, BLOCKBROWN, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } }, \/\/ \u53cd'L'\u5f62\u65b9\u5757 { { BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKYELLOW,BLOCKYELLOW, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE }, { BLOCKNONE, BLOCKYELLOW,BLOCKYELLOW,BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKYELLOW,BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE, BLOCKNONE } } };<\/code><\/pre>\n
                      \n
                    • \n

                      6.\u5f53\u524d\u63a7\u5236\u65b9\u5757\u6570\u636e\u7ed3\u6784<\/h4>\n<\/li>\n<\/ul>\n
                      typedef struct _GAME_MOVE_BLOCK { int blockSite[4][2]; \/\/ 4\u4e2a\u65b9\u5757\u683c\u5750\u6807 int blockColor; \/\/ \u65b9\u5757\u989c\u8272 }GAME_MOVE_BLOCK;<\/code><\/pre>\n
                      \n

                      GAME_MOVE_BLOCK moveBlock;    \/\/ \u5f53\u524d\u63a7\u5236\u65b9\u5757\u6570\u636e<\/p>\n<\/blockquote>\n

                      \u6570\u636e\u7ed3\u6784\u7531\u4e24\u90e8\u5206\u7ec4\u6210\uff0c\u4e00\u4e2a\u662f\u4fdd\u5b58\u4e86\u56db\u4e2a\u65b9\u5757\u5750\u6807\u7684\u4e8c\u7ef4\u6570\u7ec4\uff1b\u4e00\u4e2a\u662f\u5f53\u524d\u63a7\u5236\u65b9\u5757\u7684\u989c\u8272\uff1b<\/p>\n

                      \u6709\u4e86\u5750\u6807\u548c\u989c\u8272\uff0c\u5c31\u53ef\u4ee5\u5728\u6e38\u620f\u5730\u56fe\u4e2d\uff0c\u51c6\u786e\u7684\u753b\u51fa\u5f53\u524d\u63a7\u5236\u65b9\u5757\u3002<\/p>\n

                      \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n

                      \u56db\u3001\u4e3b\u51fd\u6570tetrisrun()<\/h2>\n
                        \n
                      • 1.\u51fd\u6570\u8bf4\u660e<\/li>\n<\/ul>\n

                        \u4e3b\u51fd\u6570\u7531\u4e00\u4e2a\u521d\u59cb\u5316\u51fd\u6570\uff0c\u548c\u4e00\u4e2a\u6b7b\u5faa\u73af\u7ec4\u6210\uff1b\u521d\u59cb\u5316\u6e38\u620f\u6570\u636e\u540e\uff0c\u4f1a\u5728\u6b7b\u5faa\u73afwhile(1)\u4e2d\u4e0d\u505c\u7684\u6267\u884c\u6e38\u620f\u6570\u636e\u5904\u7406\uff0c\u76f4\u5230\u73a9\u5bb6\u9009\u62e9\u9000\u51fa\u6e38\u620f\u3002<\/p>\n

                        \u901a\u8fc7\u4e3b\u51fd\u6570\uff0c\u4e5f\u80fd\u770b\u51fa\u6765\u6574\u4e2a\u4ee3\u7801\u7684\u8fd0\u884c\u903b\u8f91\uff0c\u4e86\u89e3\u7f16\u7a0b\u601d\u8def\u3002<\/p>\n

                        void tetrisrun(void) { tetrisInit(); while(1) { \/\/ (\u6bcf500\u6beb\u79d2 - \u6e38\u620f\u7b49\u7ea7*30\u6beb\u79d2)\u8fd0\u884c\u4e00\u6b21\uff0c\u65b9\u5757\u4e0b\u79fb player.ctime = GetTickCount(); if( (player.ctime - 500 + 30*player.level) > player.ttime ) { player.moveFlag = TRUE; player.ttime = GetTickCount(); } \/\/ \u5982\u679c\u79fb\u52a8\u6807\u8bc6\u4e3a1\uff0c\u5219\u5f53\u524d\u65b9\u5757\u4e0b\u79fb if(player.moveFlag) { player.moveFlag = FALSE; tetrisMoveDown(); tetrisDraw(); } \/\/ \u7528\u6237\u6309\u952e\u5904\u7406 if(_kbhit()) { player.key = _getch(); tetrisKeyHandle(); } \/\/ \u5c06\u9884\u751f\u6210\u7684\u968f\u673a\u65b9\u5757\u8f7d\u5165\u6e38\u620f\u5730\u56fe if(player.newBlockFlag) { player.newBlockFlag = FALSE; \/\/ \u5c06\u5f53\u524d\u65b9\u5757\u8f7d\u5165\u6e38\u620f\u5730\u56fe tetrisLoadBlock(); \/\/ \u6d88\u9664\u6ee1\u884c\u7684\u65b9\u5757 tetrisRemove(); \/\/ \u751f\u6210\u65b0\u7684\u65b9\u5757 tetrisNewBlock(); \/\/ \u5224\u65ad\u6e38\u620f\u662f\u5426\u7ed3\u675f tetrisIsOver(); } \/\/ \u6e38\u620f\u7ed3\u675f\u5904\u7406 if(player.gameOverFlag) { player.gameOverFlag = FALSE; break; } } }<\/code><\/pre>\n
                          \n
                        •  2.\u8ba1\u65f6\u90e8\u5206<\/li>\n<\/ul>\n
                          \n

                          \/\/ (\u6bcf500\u6beb\u79d2 - \u6e38\u620f\u7b49\u7ea7*30\u6beb\u79d2)\u8fd0\u884c\u4e00\u6b21\uff0c\u65b9\u5757\u4e0b\u79fb
                                  player.ctime = GetTickCount();
                                  if( (player.ctime - 500 + 30*player.level) > player.ttime )
                                  {    
                                      player.moveFlag = TRUE;
                                      player.ttime = GetTickCount();
                                  }<\/p>\n<\/blockquote>\n

                          \u7b2c\u4e00\u90e8\u5206\uff0c\u8ba1\u65f6\u90e8\u5206\uff1a\u901a\u8fc7\u8bb0\u5f55\u4e24\u4e2a\u65f6\u95f4\u53d8\u91cf\u7684\u65f6\u95f4\u5dee\uff0c\u6765\u5f97\u5230\u4e00\u4e2a\u5468\u671f\u6267\u884c\u7684\u6807\u8bc6<\/p>\n

                          1.\u521d\u59cb\u5316\u65f6\uff0c\u5148\u7ed9\u53d8\u91cfplayer.ttime\u8d4b\u503c\uff0c\u83b7\u5f97\u5f53\u65f6\u7684\u65f6\u95f4\u6570\u636e\uff1b<\/p>\n

                          2.\u6bcf\u6b21\u4e3b\u7a0b\u5e8f\u5faa\u73af\u65f6\uff0c\u90fd\u4f1a\u7ed9\u53e6\u4e00\u4e2a\u53d8\u91cfplayer.ctime\u8d4b\u503c\uff0c\u83b7\u5f97\u6700\u65b0\u7684\u65f6\u95f4\u6570\u636e\uff1b<\/p>\n

                          3.\u4ee5\u9ed8\u8ba4\u7684500ms\u5468\u671f\u4e3a\u4f8b\uff0c\u5982\u679c\u6700\u65b0\u7684\u65f6\u95f4player.ctime\u51cf\u53bb500ms\uff0c\u8fd8\u662f\u5927\u4e8e\u5f53\u65f6\u7684\u65f6\u95f4player.ttime\uff0c\u8bf4\u660e\u79bb\u7b2c\u4e00\u6b21\u7ed9player.ttime\u8d4b\u503c\uff0c\u5df2\u7ecf\u8fc7\u53bb\u4e86500ms\uff0c\u6ee1\u8db3\u4e00\u4e2a\u5468\u671f\uff1b<\/p>\n

                          4.\u6b64\u65f6\uff0c\u7ed9\u5468\u671f\u6267\u884c\u6807\u8bc6 player.moveFlag\u7f6e1\uff1b\u8868\u793a\u5f53\u524d\u65b9\u5757\u9700\u8981\u4e0b\u79fb\u4e86\uff0c\u5c06\u4f1a\u5728\u540e\u9762\u7684\u51fd\u6570\u5904\u7406\uff0c\u5e76\u5c06\u6807\u8bc6\u7f6e0\uff0c\u7b49\u5f85\u4e0b\u4e00\u6b21\u5468\u671f\u6765\u4e34\uff1b<\/p>\n

                          5.\u518d\u7ed9player.ttime\u8d4b\u503c\uff0c\u83b7\u5f97\u5f53\u65f6\u7684\u65f6\u95f4\u6570\u636e\uff0c\u5f00\u59cb\u6267\u884c\u4e0b\u4e00\u6b21500ms\u7684\u5468\u671f\u8ba1\u7b97\u3002<\/p>\n

                            \n
                          • 3.\u65b9\u5757\u79fb\u52a8<\/li>\n<\/ul>\n
                            \n

                            \/\/ \u5982\u679c\u79fb\u52a8\u6807\u8bc6\u4e3a1\uff0c\u5219\u5f53\u524d\u65b9\u5757\u4e0b\u79fb
                                    if(player.moveFlag)
                                    {
                            \n
                                        player.moveFlag = FALSE;<\/p>\n

                                        tetrisMoveDown();
                                        tetrisDraw();
                                    }<\/p>\n<\/blockquote>\n

                            \u7b2c\u4e8c\u90e8\u5206\uff0c\u65b9\u5757\u79fb\u52a8\uff1a\u6bcf\u8fc7\u4e00\u4e2a\u5468\u671f\uff0c\u65b9\u5757\u79fb\u52a8\u6807\u8bc6player.moveFlag\u7f6e1\uff0c\u6267\u884c\u8fd9\u90e8\u5206\u51fd\u6570<\/p>\n

                            1.\u5148\u5c06\u79fb\u52a8\u6807\u8bc6player.moveFlag\u7f6e0\uff0c\u65b9\u4fbf\u4e0b\u4e00\u6b21\u5468\u671f\u7684\u6267\u884c\uff1b<\/p>\n

                            2.\u6267\u884c\u65b9\u5757\u4e0b\u79fb\u51fd\u6570tetrisMoveDown()\uff0c\u5bf9\u65b9\u5757\u8fdb\u884c\u4e0b\u79fb\u5904\u7406\uff1b\u5982\u679c\u65b9\u5757\u5230\u8fbe\u6e38\u620f\u5e95\u90e8\uff0c\u6216\u8005\u4e0b\u65b9\u5df2\u7ecf\u5b58\u5728\u65b9\u5757\uff0c\u5c31\u4f1a\u5c06\u751f\u6210\u65b0\u65b9\u5757\u6807\u8bc6player.newBlockFlag\u7f6e1\uff0c\u8fdb\u884c\u540e\u9762\u7684\u5904\u7406\uff1b<\/p>\n

                            3.\u6267\u884c\u7ed8\u5236\u5730\u56fe\u51fd\u6570tetrisDraw()\uff0c\u753b\u51fa\u65b9\u5757\u4e0b\u79fb\u540e\u7684\u753b\u9762\u3002<\/p>\n

                              \n
                            • 4.\u6309\u952e\u5904\u7406<\/li>\n<\/ul>\n
                              \n

                              \/\/ \u7528\u6237\u6309\u952e\u5904\u7406
                                      if(_kbhit())
                                      {    
                                          player.key = _getch();
                                          tetrisKeyHandle();
                                      }<\/p>\n<\/blockquote>\n

                              \u7b2c\u4e09\u90e8\u5206\uff0c\u6309\u952e\u5904\u7406\uff1a\u5bf9\u7528\u6237\u7684\u6309\u952e\u8fdb\u884c\u5904\u7406\uff0c\u63a7\u5236\u65b9\u5757\u7684\u79fb\u52a8\u3001\u6e38\u620f\u7684\u8fdb\u7a0b<\/p>\n

                              1._kbhit()\u51fd\u6570\uff0c\u6bcf\u5f53\u68c0\u6d4b\u5230\u7528\u6237\u6309\u4e0b\u6309\u952e\u65f6\uff0c\u4f1a\u8fd4\u56deTRUE\uff0c\u6b64\u65f6if\u6761\u4ef6\u4e3a\u771f\uff0c\u6267\u884cif\u91cc\u9762\u7684\u4ee3\u7801\uff1b<\/p>\n

                              2.\u901a\u8fc7_getch()\u51fd\u6570\uff0c\u5c06\u7528\u6237\u6309\u952e\u503c\u8d4b\u7ed9\u53d8\u91cfplayer.key\uff1b<\/p>\n

                              3.\u6267\u884c\u6309\u952e\u5904\u7406\u51fd\u6570tetrisKeyHandle()\uff0c\u5bf9\u4e0d\u540c\u7684\u6309\u952e\u8fdb\u884c\u4e0d\u540c\u7684\u5904\u7406<\/p>\n

                                \n
                              • 5.\u65b0\u65b9\u5757\u5904\u7406<\/li>\n<\/ul>\n
                                \n

                                \/\/ \u5c06\u9884\u751f\u6210\u7684\u968f\u673a\u65b9\u5757\u8f7d\u5165\u6e38\u620f\u5730\u56fe
                                        if(player.newBlockFlag)
                                        {
                                \n
                                            player.newBlockFlag = FALSE;
                                            \/\/ \u5c06\u5f53\u524d\u65b9\u5757\u8f7d\u5165\u6e38\u620f\u5730\u56fe
                                            tetrisLoadBlock();
                                            \/\/ \u6d88\u9664\u6ee1\u884c\u7684\u65b9\u5757
                                            tetrisRemove();
                                            \/\/ \u751f\u6210\u65b0\u7684\u65b9\u5757
                                            tetrisNewBlock();
                                            \/\/ \u5224\u65ad\u6e38\u620f\u662f\u5426\u7ed3\u675f
                                            tetrisIsOver();
                                        }<\/p>\n<\/blockquote>\n

                                \u7b2c\u56db\u90e8\u5206\uff0c\u65b0\u65b9\u5757\u5904\u7406\uff1a\u6bcf\u5f53\u5f53\u524d\u65b9\u5757\u5230\u8fbe\u6e38\u620f\u5e95\u90e8\uff0c\u6216\u8005\u5f53\u524d\u65b9\u5757\u4e0b\u4e00\u884c\u5df2\u5b58\u5728\u65b9\u5757\u65f6\uff0c\u4f1a\u5c06\u65b0\u65b9\u5757\u6807\u8bc6player.newBlockFlag\u7f6e1\uff0c\u6267\u884cif\u91cc\u9762\u7684\u4ee3\u7801\u3002<\/p>\n

                                1.\u5148\u628a\u65b0\u65b9\u5757\u6807\u8bc6player.newBlockFlag\u6e050\uff0c\u9632\u6b62\u91cd\u590d\u6267\u884c\uff1b<\/p>\n

                                2.\u5f53\u524d\u65b9\u5757\u5df2\u4e0d\u80fd\u4e0b\u79fb\uff0c\u6267\u884ctetrisLoadBlock()\u51fd\u6570\uff0c\u628a\u5f53\u524d\u65b9\u5757\u56fa\u5b9a\u5230\u6e38\u620f\u5730\u56fe\uff0c\u4e0d\u518d\u79fb\u52a8\uff1b<\/p>\n

                                3.\u56fa\u5b9a\u65b9\u5757\u540e\uff0c\u6267\u884ctetrisRemove()\u51fd\u6570\uff0c\u68c0\u6d4b\u5e76\u6d88\u9664\u6ee1\u884c\u7684\u65b9\u5757\uff0c\u5e76\u901a\u8fc7\u6d88\u9664\u7684\u884c\u6570\uff0c\u589e\u52a0RANK\u5206\uff0c\u6539\u53d8level\u7b49\u7ea7\uff1b<\/p>\n

                                4.\u6d88\u9664\u6ee1\u884c\u540e\uff0c\u6267\u884ctetrisNewBlock()\u51fd\u6570\uff0c\u5c06\u9884\u751f\u6210\u7684\u65b9\u5757\u8f7d\u5165\u6e38\u620f\uff0c\u6210\u4e3a\u5f53\u524d\u63a7\u5236\u65b9\u5757\uff0c\u5e76\u751f\u6210\u65b0\u7684\u968f\u673a\u65b9\u5757\uff0c\u8f7d\u5165\u5230\u9884\u751f\u6210\u65b9\u5757\u5730\u56fe\uff1b<\/p>\n

                                5.\u751f\u6210\u65b0\u65b9\u5757\u540e\uff0c\u6267\u884c tetrisIsOver()\u51fd\u6570\uff0c\u5224\u65ad\u5f53\u524d\u63a7\u5236\u65b9\u5757\u662f\u5426\u548c\u6e38\u620f\u5730\u56fe\u6709\u91cd\u53e0\uff0c\u5982\u679c\u91cd\u53e0\uff0c\u5219\u6e38\u620f\u7ed3\u675f\uff0c\u5c06\u7ed3\u675f\u6807\u8bc6player.gameOverFlag\u7f6e1\uff0c\u5e76\u8ba9\u7528\u6237\u9009\u62e9\u662f\u7ed3\u675f\u6e38\u620f\u8fd8\u662f\u91cd\u65b0\u5f00\u59cb\u3002<\/p>\n

                                  \n
                                • 6.\u6e38\u620f\u7ed3\u675f<\/li>\n<\/ul>\n
                                  \n

                                  \/\/ \u6e38\u620f\u7ed3\u675f\u5904\u7406
                                          if(player.gameOverFlag)
                                          {
                                  \n
                                              player.gameOverFlag = FALSE;
                                              break;
                                          }<\/p>\n<\/blockquote>\n

                                  \u7b2c\u4e94\u90e8\u5206\uff0c\u6e38\u620f\u7ed3\u675f\u5904\u7406\uff1a\u5982\u679c\u7528\u6237\u51b3\u5b9a\u7ed3\u675f\u6e38\u620f\uff0c \u5219\u9000\u51fawhile\uff081\uff09\u6b7b\u5faa\u73af\uff0c\u9000\u51fa\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n

                                  \u4e94\u3001\u4ee3\u7801\u548c\u6240\u6709\u51fd\u6570\u8bf4\u660e<\/h2>\n

                                  \u4e0a\u9762\u5df2\u7ecf\u89e3\u91ca\u8fc7\u4e3b\u51fd\u6570tetrisrun()\uff0c\u63a5\u4e0b\u6765\u4f1a\u8be6\u7ec6\u89e3\u91ca\u6bcf\u4e00\u4e2a\u51fd\u6570<\/p>\n

                                    \n
                                  • \n

                                    1. tetrisInit()<\/h4>\n<\/li>\n<\/ul>\n

                                    \u521d\u59cb\u5316\u51fd\u6570\uff0c\u7a0b\u5e8f\u4f1a\u5148\u8fd0\u884c\u521d\u59cb\u5316\u51fd\u6570\uff0c\u7136\u540e\u518d\u8fdb\u5165while\uff081\uff09\u6b7b\u5faa\u73af\uff0c\u8fd0\u884c\u4fc4\u7f57\u65af\u65b9\u5757\u6e38\u620f\uff1b<\/p>\n

                                    void tetrisInit(void) { int i,j,k; HWND window = initgraph(510, 620); \/\/ \u521d\u59cb\u5316\u7a97\u53e3\u5927\u5c0f SetWindowText(window, \"\u4fc4\u7f57\u65af\u65b9\u5757 - by\u8012\u9633\u963f\u6770\"); \/\/ \u8bbe\u7f6e\u5f53\u524d\u7a97\u53e3\u7684\u6807\u9898 \/\/SetWindowPos(window,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); \/\/ \u7f6e\u9876 rectangle(GAMEMAP1 - 2,GAMEMAP2 - 2,GAMEMAP3 + 2,GAMEMAP4 + 2); \/\/ \u7ed8\u5236\u6e38\u620f\u5730\u56fe\u8303\u56f4 rectangle(GAMEMAP5 - 2,GAMEMAP6 - 2,GAMEMAP7 + 2,GAMEMAP8 + 2); \/\/ \u7ed8\u5236\u9884\u751f\u6210\u65b9\u5757\u65b9\u4f4d rectangle(GAMEGUIDE1 - 5,GAMEGUIDE2 - 5,GAMEGUIDE3 + 5,GAMEGUIDE4 + 5); \/\/ \u7ed8\u5236\u6309\u952e\u8bf4\u660e outtextxy(GAMEMAP5 + 10 ,GAMEMAP6 - 26,\"\u4e0b\u4e2a\u65b9\u5757\"); settextcolor(GREEN); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 ,\"W \uff1a\u6539\u53d8\u5f62\u72b6\"); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 25 ,\"A \uff1a\u65b9\u5757\u5de6\u79fb\"); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 50 ,\"S \uff1a\u65b9\u5757\u53f3\u79fb\"); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 75 ,\"D \uff1a\u65b9\u5757\u4e0b\u79fb\"); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 100 ,\"R \uff1a\u91cd\u65b0\u5f00\u59cb\"); outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 125 ,\"ESC\uff1a\u9000\u51fa\u6e38\u620f\"); \/\/ \u521d\u59cb\u5316\u6e38\u620f\u6570\u636e memset ( &player, 0, sizeof ( GAME_TETRIS ) ); memset ( &preBlock, 0, sizeof ( GAME_PREBLOCK ) ); memset(tetrisMap,0,sizeof(tetrisMap)); player.ttime = GetTickCount(); \/\/ \u83b7\u53d6\u968f\u673a\u6570\uff0c\u751f\u6210\u7b2c\u4e00\u4e2a\u968f\u673a\u65b9\u5757 srand((unsigned)time(NULL)); \/\/ \u83b7\u53d6\u968f\u673a\u6570\uff0c\u751f\u6210\u65b0\u7684\u968f\u673a\u65b9\u5757 i = (rand() + 1) % BLOCKTYPE; j = rand() % BLOCKSTYLE; for(k = 0; k < BLOCKSPACE;k++) { preBlock.tetrisPreBlock[k] = block[i][j][k]; } preBlock.blockType = i; preBlock.blockStyle = j; \/\/ \u628a\u7b2c\u4e00\u4e2a\u968f\u673a\u65b9\u5757\u52a0\u8f7d\u8fdb\u6e38\u620f\uff0c\u5e76\u751f\u6210\u4e0b\u4e00\u4e2a\u968f\u673a\u65b9\u5757 tetrisNewBlock(); }<\/code><\/pre>\n<\/p>\n
                                    \n

                                    HWND window = initgraph(510, 620);    \/\/ \u521d\u59cb\u5316\u7a97\u53e3\u5927\u5c0f
                                    SetWindowText(window, \"\u4fc4\u7f57\u65af\u65b9\u5757 - by\u8012\u9633\u963f\u6770\");    \/\/ \u8bbe\u7f6e\u5f53\u524d\u7a97\u53e3\u7684\u6807\u9898
                                    \/\/SetWindowPos(window,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);    \/\/ \u7f6e\u9876<\/p>\n<\/blockquote>\n

                                    1.\u521d\u59cb\u5316\u7a97\u53e3\uff0c\u5b9a\u4e49\u7a97\u53e3\u5927\u5c0f\uff0c\u8bbe\u7f6e\u7a97\u53e3\u6807\u9898\uff0c\u5c4f\u853d\u7684SetWindowPos()\u51fd\u6570\u662f\u7528\u4e8e\u7ed9\u6e38\u620f\u7f6e\u9876\u7684\uff0c\u7f6e\u9876\u4e4b\u540e\uff0c\u603b\u662f\u4f1a\u663e\u793a\u5728WINDOWS\u7684\u6700\u9876\u5c42\uff0c\u7c7b\u4f3c\u4e8e\u5fae\u4fe1\u7684\u7f6e\u9876\uff1b<\/p>\n<\/p>\n

                                    \n

                                    rectangle(GAMEMAP1 - 2,GAMEMAP2 - 2,GAMEMAP3 + 2,GAMEMAP4 + 2);        \/\/ \u7ed8\u5236\u6e38\u620f\u5730\u56fe\u8303\u56f4
                                        rectangle(GAMEMAP5 - 2,GAMEMAP6 - 2,GAMEMAP7 + 2,GAMEMAP8 + 2);        \/\/ \u7ed8\u5236\u9884\u751f\u6210\u65b9\u5757\u65b9\u4f4d
                                        rectangle(GAMEGUIDE1 - 5,GAMEGUIDE2 - 5,GAMEGUIDE3 + 5,GAMEGUIDE4 + 5);        \/\/ \u7ed8\u5236\u6309\u952e\u8bf4\u660e<\/p>\n

                                        outtextxy(GAMEMAP5 + 10 ,GAMEMAP6 - 26,\"\u4e0b\u4e2a\u65b9\u5757\");
                                        settextcolor(GREEN);
                                        outtextxy(GAMEGUIDE1 ,GAMEGUIDE2        ,\"W   \uff1a\u6539\u53d8\u5f62\u72b6\");
                                        outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 25    ,\"A    \uff1a\u65b9\u5757\u5de6\u79fb\");
                                        outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 50    ,\"S    \uff1a\u65b9\u5757\u53f3\u79fb\");
                                        outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 75    ,\"D    \uff1a\u65b9\u5757\u4e0b\u79fb\");
                                        outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 100    ,\"R    \uff1a\u91cd\u65b0\u5f00\u59cb\");
                                        outtextxy(GAMEGUIDE1 ,GAMEGUIDE2 + 125    ,\"ESC\uff1a\u9000\u51fa\u6e38\u620f\");<\/p>\n<\/blockquote>\n

                                    2.rectangle()\u51fd\u6570\u662f\u6839\u636e\u4f60\u8f93\u5165\u7684\u56db\u4e2a\u5750\u6807\uff0c\u7ed8\u5236\u4e00\u4e2a\u77e9\u5f62\uff0c\u8fd9\u91cc\u7ed8\u5236\u4e86\u6e38\u620f\u5730\u56fe\u3001\u9884\u751f\u6210\u65b9\u5757\u5730\u56fe\u3001\u6309\u952e\u8bf4\u660e\u6846\uff1b<\/p>\n

                                    outtextxy(x,y,string)\u51fd\u6570\u662f\u6839\u636e\u4f60\u8f93\u5165\u7684\u8d77\u70b9\u5750\u6807\uff0c\u8fd8\u6709\u540e\u9762\u7684\u5b57\u7b26\u4e32\uff0c\u5728\u76f8\u5e94\u4f4d\u7f6e\u6253\u5370\u5b57\u7b26\u4e32\u5185\u5bb9\uff1b<\/p>\n

                                    settextcolor(GREEN)\u51fd\u6570\u662f\u8bbe\u7f6e\u6253\u5370\u5b57\u7b26\u4e32\u7684\u989c\u8272\uff1b<\/p>\n<\/p>\n

                                    \n

                                    \/\/ \u521d\u59cb\u5316\u6e38\u620f\u6570\u636e
                                        memset ( &player, 0, sizeof ( GAME_TETRIS ) );
                                        memset ( &preBlock, 0, sizeof ( GAME_PREBLOCK ) );
                                        memset(tetrisMap,0,sizeof(tetrisMap));
                                        player.ttime = GetTickCount();<\/p>\n<\/blockquote>\n

                                    3. memset()\u51fd\u6570\u662f\u91cd\u7f6e\u7ed3\u6784\u6216\u8005\u6570\u636e\u7684\u6570\u636e\uff0c\u5c06\u4ed6\u4eec\u7f6e0\uff1b<\/p>\n

                                    \u7136\u540e\u7ed9player.ttime\u8d4b\u503c\u5f53\u65f6\u7684\u65f6\u95f4\uff0c\u65b9\u4fbf\u540e\u9762\u7528\u6765\u5224\u5b9a500ms\u5468\u671f\u3002<\/p>\n<\/p>\n

                                    \n

                                    \/\/ \u83b7\u53d6\u968f\u673a\u6570\uff0c\u751f\u6210\u7b2c\u4e00\u4e2a\u968f\u673a\u65b9\u5757
                                        srand((unsigned)time(NULL));        \/\/ \u83b7\u53d6\u968f\u673a\u6570\uff0c\u751f\u6210\u65b0\u7684\u968f\u673a\u65b9\u5757
                                        i = (rand() + 1) % BLOCKTYPE;
                                        j = rand() % BLOCKSTYLE;
                                        for(k = 0; k < BLOCKSPACE;k++)
                                        {
                                    \n
                                            preBlock.tetrisPreBlock[k] = block[i][j][k];
                                        }
                                        preBlock.blockType = i;
                                        preBlock.blockStyle = j;
                                        \/\/ \u628a\u7b2c\u4e00\u4e2a\u968f\u673a\u65b9\u5757\u52a0\u8f7d\u8fdb\u6e38\u620f\uff0c\u5e76\u751f\u6210\u4e0b\u4e00\u4e2a\u968f\u673a\u65b9\u5757
                                        tetrisNewBlock();    <\/p>\n<\/blockquote>\n

                                    4.\u5173\u4e8e\u968f\u673a\u6570\u751f\u6210\uff0c\u5206\u4e3a\u4f2a\u968f\u673a\u548c\u771f\u968f\u673a\uff0c\u8fd9\u4e2a\u5efa\u8bae\u8bfb\u8005\u4eec\u81ea\u5df1\u53bb\u67e5\u9605\u76f8\u5173\u8d44\u6599\uff1b<\/p>\n

                                    \u901a\u8fc7\u751f\u6210\u7684\u968f\u673a\u6570\uff0c\u518d\u5206\u522b\u53d6\u65b9\u5757\u7c7b\u578b\u548c\u5f62\u72b6\uff08\u671d\u5411\uff09\u7684\u4f59\u6570\uff0c\u5c31\u80fd\u5f97\u5230\u4e00\u4e2a\u968f\u673a\u65b9\u5757\u7684\u6570\u636e\u4e86\uff1b<\/p>\n

                                    \u5f97\u5230\u7b2c\u4e00\u4e2a\u968f\u673a\u65b9\u5757\u540e\uff0c\u518d\u6267\u884c tetrisNewBlock()\u51fd\u6570\uff0c\u628a\u7b2c\u4e00\u4e2a\u968f\u673a\u65b9\u5757\u8f7d\u5165\u6e38\u620f\u5730\u56fe\uff0c\u518d\u751f\u6210\u65b0\u7684\u968f\u673a\u65b9\u5757\uff0c\u8f7d\u5165\u9884\u751f\u6210\u65b9\u5757\u5730\u56fe\u3002<\/p>\n

                                      \n
                                    • \n

                                      2.tetrisDraw()<\/h4>\n<\/li>\n<\/ul>\n

                                      \u7ed8\u5236\u51fd\u6570\uff0c\u6839\u636e\u5f53\u524d\u6e38\u620f\u6570\u636e\uff0c\u7ed8\u5236\u6574\u4e2a\u6e38\u620f\u753b\u9762\u3002<\/p>\n

                                      void tetrisDraw(void) { int i,j; int x,y; char ch[20]; \/\/ \u66f4\u65b0RANK\u5206\u6570\u548cLEVEL\u7b49\u7ea7 settextstyle(20,12,\"\u5b8b\u4f53\"); \/\/ \u8bbe\u7f6e\u5b57\u4f53\u548c\u5927\u5c0f settextcolor(CYAN); \/\/ \u8bbe\u7f6e\u5b57\u4f53\u989c\u8272 if(player.level < 10) { sprintf_s(ch, \"%s%d\",\"LEVEL\uff1a\", player.level); } else { \/\/ \u7b49\u7ea7\u4e3a10\u65f6\uff0c\u663e\u793a\u6700\u5927max sprintf_s(ch, \"%s\",\"LEVEL\uff1aMAX\"); } outtextxy(GAMELEVEL1,GAMELEVEL2,ch); settextcolor(LIGHTBLUE); sprintf_s(ch, \"%s%d\",\"RANK\uff1a\", player.rank); outtextxy(GAMERANK1,GAMERANK2,ch); \/\/ \u7ed8\u5236\u9884\u751f\u6210\u65b9\u5757\u7684\u80cc\u666f\u677f setfillcolor(BLACK); solidrectangle(GAMEMAP5,GAMEMAP6,GAMEMAP7,GAMEMAP8); \/\/ \u7ed8\u5236\u9884\u751f\u6210\u7684\u65b9\u5757 for(i = 0; i < BLOCKSPACE; i++) { switch(preBlock.tetrisPreBlock[i]) { case BLOCKNONE: \/\/ \u7a7a continue; break; case BLOCKBLUE: \/\/ \u84dd\u8272 setfillcolor(BLUE); break; case BLOCKGREEN: \/\/ \u7eff\u8272 setfillcolor(GREEN); break; case BLOCKCYAN: \/\/ \u9752\u8272 setfillcolor(CYAN); break; case BLOCKRED: \/\/ \u7ea2\u8272 setfillcolor(RED); break; case BLOCKMAGENTA: \/\/ \u6df1\u7ea2\u8272 setfillcolor(MAGENTA); break; case BLOCKBROWN: \/\/ \u7070\u8272 setfillcolor(BROWN); break; case BLOCKYELLOW: setfillcolor(YELLOW); break; } \/\/ \u586b\u5145\u76f8\u5e94\u533a\u57df fillrectangle(GAMEMAP5 + (i%5) * SIDELENGTH ,GAMEMAP6 + (i\/5) * SIDELENGTH ,GAMEMAP5 + ((i%5)+1)*SIDELENGTH ,GAMEMAP6 + ((i\/5)+1) * SIDELENGTH ); } \/\/ \u7ed8\u5236\u6e38\u620f\u5730\u56fe\u80cc\u666f\u677f setfillcolor(BLACK); solidrectangle(GAMEMAP1,GAMEMAP2,GAMEMAP3,GAMEMAP4); \/\/ \u7ed8\u5236\u5f53\u524d\u63a7\u5236\u65b9\u5757\u76844\u4e2a\u65b9\u5757\u683c for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0]; y = moveBlock.blockSite[i][1]; switch(moveBlock.blockColor) { case BLOCKNONE: continue; break; case BLOCKBLUE: setfillcolor(BLUE); break; case BLOCKGREEN: setfillcolor(GREEN); break; case BLOCKCYAN: setfillcolor(CYAN); break; case BLOCKRED: setfillcolor(RED); break; case BLOCKMAGENTA: setfillcolor(MAGENTA); break; case BLOCKBROWN: setfillcolor(BROWN); break; case BLOCKYELLOW: setfillcolor(YELLOW); break; } \/\/ \u586b\u5145\u76f8\u5e94\u533a\u57df fillrectangle(GAMEMAP1 + y * SIDELENGTH ,GAMEMAP2 + x * SIDELENGTH ,GAMEMAP1 + (y+1)*SIDELENGTH ,GAMEMAP2 + (x+1) * SIDELENGTH ); } \/\/ \u7ed8\u5236\u6e38\u620f\u5b9e\u65f6\u753b\u9762 for(i = 0; i < TETRISHEIGHT; i++) { for(j = 0; j < TETRISWIDTH; j++) { switch(tetrisMap[i][j]) { case BLOCKNONE: continue; break; case BLOCKBLUE: setfillcolor(BLUE); break; case BLOCKGREEN: setfillcolor(GREEN); break; case BLOCKCYAN: setfillcolor(CYAN); break; case BLOCKRED: setfillcolor(RED); break; case BLOCKMAGENTA: setfillcolor(MAGENTA); break; case BLOCKBROWN: setfillcolor(BROWN); break; case BLOCKYELLOW: setfillcolor(YELLOW); break; } \/\/ \u586b\u5145\u76f8\u5e94\u533a\u57df fillrectangle(GAMEMAP1 + j * SIDELENGTH ,GAMEMAP2 + i * SIDELENGTH ,GAMEMAP1 + (j+1)*SIDELENGTH ,GAMEMAP2 + (i+1) * SIDELENGTH ); } } }<\/code><\/pre>\n<\/p>\n
                                      \n

                                      \/\/ \u66f4\u65b0RANK\u5206\u6570\u548cLEVEL\u7b49\u7ea7
                                          settextstyle(20,12,\"\u5b8b\u4f53\");    \/\/ \u8bbe\u7f6e\u5b57\u4f53\u548c\u5927\u5c0f
                                          settextcolor(CYAN);            \/\/ \u8bbe\u7f6e\u5b57\u4f53\u989c\u8272
                                          if(player.level < 10)
                                          {
                                      \n
                                              sprintf_s(ch, \"%s%d\",\"LEVEL\uff1a\", player.level);
                                          }
                                          else
                                          {    \/\/ \u7b49\u7ea7\u4e3a10\u65f6\uff0c\u663e\u793a\u6700\u5927max
                                              sprintf_s(ch, \"%s\",\"LEVEL\uff1aMAX\");
                                          }
                                          outtextxy(GAMELEVEL1,GAMELEVEL2,ch);
                                          settextcolor(LIGHTBLUE);
                                          sprintf_s(ch, \"%s%d\",\"RANK\uff1a\", player.rank);
                                          outtextxy(GAMERANK1,GAMERANK2,ch);<\/p>\n<\/blockquote>\n

                                      1.\u8bbe\u7f6e\u8f93\u51fa\u5b57\u7b26\u7684\u5927\u5c0f\u548c\u5b57\u4f53\uff0c\u518d\u8bbe\u7f6e\u989c\u8272\uff1b<\/p>\n

                                      \u7b49\u7ea7\u572810\u7ea7\u4ee5\u4e0b\u65f6\uff0c\u7167\u5e38\u663e\u793a\uff1b10\u7ea7\u53ca\u4ee5\u4e0a\u65f6\uff0c\u663e\u793aMAX\uff1b<\/p>\n<\/p>\n

                                      \n

                                      \/\/ \u7ed8\u5236\u9884\u751f\u6210\u65b9\u5757\u7684\u80cc\u666f\u677f
                                          setfillcolor(BLACK);
                                          solidrectangle(GAMEMAP5,GAMEMAP6,GAMEMAP7,GAMEMAP8);<\/p>\n<\/blockquote>\n

                                      2.  setfillcolor(BLACK)\u8bbe\u7f6e\u586b\u5145\u989c\u8272\uff1bsolidrectangle(GAMEMAP5,GAMEMAP6,GAMEMAP7,GAMEMAP8) \u6839\u636e\u56db\u4e2a\u5750\u6807\uff0c\u4f7f\u7528\u8bbe\u7f6e\u597d\u7684\u586b\u5145\u989c\u8272\u586b\u5145\u77e9\u5f62\u533a\u57df\uff0c\u5b9e\u9645\u5c31\u662f\u7ed8\u5236\u4e00\u4e2a\u5e26\u767d\u8272\u8fb9\u6846\u7684\u9ed1\u8272\u77e9\u5f62\u3002<\/p>\n<\/p>\n

                                      \n

                                      \/\/ \u7ed8\u5236\u9884\u751f\u6210\u7684\u65b9\u5757
                                          for(i = 0; i < BLOCKSPACE; i++)
                                          {
                                      \n
                                              switch(preBlock.tetrisPreBlock[i])
                                              {
                                      \n
                                                  case BLOCKNONE:                \/\/ \u7a7a
                                                      continue;
                                                      break;
                                                  case BLOCKBLUE:                \/\/ \u84dd\u8272
                                                      setfillcolor(BLUE);
                                                      break;
                                                  case BLOCKGREEN:            \/\/ \u7eff\u8272
                                                      setfillcolor(GREEN);
                                                      break;
                                                  case BLOCKCYAN:                \/\/ \u9752\u8272
                                                      setfillcolor(CYAN);
                                                      break;
                                                  case BLOCKRED:                \/\/ \u7ea2\u8272
                                                      setfillcolor(RED);
                                                      break;
                                                  case BLOCKMAGENTA:            \/\/ \u6df1\u7ea2\u8272
                                                      setfillcolor(MAGENTA);
                                                      break;
                                                  case BLOCKBROWN:            \/\/ \u7070\u8272
                                                      setfillcolor(BROWN);
                                                      break;
                                                  case BLOCKYELLOW:
                                                      setfillcolor(YELLOW);
                                                      break;
                                              }
                                              \/\/ \u586b\u5145\u76f8\u5e94\u533a\u57df
                                              fillrectangle(GAMEMAP5 + (i%5) * SIDELENGTH ,GAMEMAP6 + (i\/5) * SIDELENGTH ,GAMEMAP5 + ((i%5)+1)*SIDELENGTH ,GAMEMAP6 + ((i\/5)+1) * SIDELENGTH );        
                                          }<\/p>\n<\/blockquote>\n

                                      3.\u7ed8\u5236\u597d\u9884\u751f\u6210\u65b9\u5757\u533a\u57df\u540e\uff0cpreBlock.tetrisPreBlock[i]\u662f\u4e00\u4e2a\u5305\u542b20\u4e2a\u6210\u5458\u7684\u6570\u7ec4\uff0c\u91cc\u9762\u670916\u4e2a\u7a7a\u6210\u5458\uff0c\u4e0d\u7528\u7ba1\uff1b\u8fd8\u67094\u4e2a\u6210\u5458\u5c31\u662f\u8981\u7ed8\u5236\u7684\u65b9\u5757\u3002\u7528switch\u9009\u62e9\u76f8\u5e94\u7684\u586b\u5145\u989c\u8272setfillcolor()\uff0c\u7136\u540e\u518d\u6267\u884c fillrectangle()\u51fd\u6570\uff0c\u5728\u76f8\u5e94\u5750\u6807\u586b\u5145\u65b9\u5757\uff1b<\/p>\n

                                      \u6700\u540e\u7684\u586b\u5145\u51fd\u6570\uff0c\u53ef\u80fd\u4f1a\u6709\u70b9\u590d\u6742\uff0c\u8fd9\u91cc\u89e3\u91ca\u4e00\u4e0b\uff1a<\/p>\n

                                      \u9884\u751f\u6210\u65b9\u5757\u533a\u57df\u662f\u4e00\u4e2a100X80\u50cf\u7d20\u5927\u5c0f\u7684\u77e9\u5f62\uff0c\u6bcf\u4e2a\u65b9\u5757\u90fd\u662f20X20\u50cf\u7d20\u5927\u5c0f\uff0c\u6240\u4ee5\u77e9\u5f62\u630920X20\u50cf\u7d20\u5207\u5272\uff0c\u5f97\u5230\u4e00\u4e2a5X4\u7684\u5750\u6807\u8f74\uff0c\u5305\u542b20\u4e2a\u65b9\u5757\uff0c\u521a\u597d\u548c\u6240\u6709\u65b9\u5757\u6570\u636e\u5e93\u91cc\u7684\u65b9\u5757\u5bf9\u5e94\u3002<\/p>\n

                                      \u5982\u4e0b\u56fe\u6240\u793a\uff0c\u53ea\u9700\u8981\u628a\u6570\u636e\u5e93\u91cc20\u4e2a\u6570\u636e\u4e2d\uff0c\u5305\u542b\u65b9\u5757\u7684\u56db\u4e2a\u6570\u636e\u9009\u51fa\u6765\u586b\u5165\uff0c\u5c31\u80fd\u5f97\u5230\u4e00\u4e2a\u5b8c\u6574\u7684\u65b9\u5757\u4e86\u3002<\/p>\n

                                      \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n<\/p>\n

                                      \u73b0\u5728\uff0c\u6211\u60f3\u8981\u7ed8\u5236\u4e00\u4e2a '----' \u578b\u65b9\u5757\uff0c\u53ea\u9700\u8981\u586b\u51452,3,4,5\u8fd94\u4e2a\u5750\u6807\uff0c\u5c31\u80fd\u5f97\u5230\u65b9\u5757\uff1b<\/p>\n

                                      \u90a3\u4e48\u5b83\u5728preBlock.tetrisPreBlock[]\u6570\u7ec4\u4e2d\u5bf9\u5e94\u7684\u6570\u636e\u5c31\u662f<\/p>\n

                                      {0,1,1,1,1, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0};\u5f97\u5230\u7684\u6700\u7ec8\u56fe\u50cf\u5c31\u662f\u5982\u4e0b\u6240\u793a<\/p>\n<\/p>\n

                                      \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n<\/p>\n

                                      \u5f53preBlock.tetrisPreBlock[i]\u4e3a1\u65f6\uff0c\u5c31\u4f1a\u6267\u884cfillrectangle()\u51fd\u6570\uff0c\u6839\u636ei\u7684\u503c\uff0c\u83b7\u5f97\u56db\u4e2a\u5750\u6807\u503c\uff0c\u586b\u5145\u8fd9\u4e2a\u65b9\u5757\uff1b<\/p>\n

                                      \u7b2c\u4e00\u4e2a\u65b9\u5757\uff1ai = 1,  fillrectangle(GAMEMAP5 + 1 * 20,GAMEMAP6,GAMEMAP5 + 2*20,GAMEMAP6 + 1 * 20); <\/p>\n

                                      GAMEMAP5\u548cGAMEMAP6\u5c31\u662f\u9884\u751f\u6210\u65b9\u5757\u533a\u57df\u7684\u5750\u4e0a\u89d2\u5750\u6807\uff0c\u5c06\u5b83\u89c6\u4e3a\u8d77\u70b9\u5750\u6807\uff0c\u5ffd\u7565\u6389\uff0c<\/p>\n

                                      \u4e0a\u9762\u7684fillrectangle() \u5c31\u76f8\u5f53\u4e8efillrectangle( 20,0, 40,20)\uff0c\u7ed8\u5236\u51fa\u6765\u5c31\u662f\u5982\u4e0b\u56fe<\/p>\n<\/p>\n

                                      \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n

                                       \u7b2c\u4e8c\u4e2a\u65b9\u5757\uff1ai = 2\uff0cfillrectangle(GAMEMAP5 + 2 * 20,GAMEMAP6  ,GAMEMAP5 + 3*20,GAMEMAP6 + 1 * 20);  <\/p>\n

                                      \u5ffd\u7565\u8d77\u70b9\u5750\u6807\uff0c\u5f97\u5230fillrectangle( 40,0,60,20),\u7ed8\u5236\u51fa\u6765\u5982\u4e0b\u56fe<\/p>\n

                                      \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n

                                       \u4f9d\u6b21\u753b\u51fa\u7b2c\u4e09\u4e2a\u65b9\u5757\uff0c\u7b2c\u56db\u4e2a\u65b9\u5757\uff0c\u5c31\u80fd\u5f97\u5230\u6700\u7ec8\u7684\u56fe\u50cf\u4e86<\/p>\n

                                      \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n<\/p>\n

                                      \n

                                      \/\/ \u7ed8\u5236\u6e38\u620f\u5730\u56fe\u80cc\u666f\u677f
                                          setfillcolor(BLACK);
                                          solidrectangle(GAMEMAP1,GAMEMAP2,GAMEMAP3,GAMEMAP4);<\/p>\n<\/blockquote>\n

                                      4.\u548c2\u7c7b\u4f3c\uff0c\u7ed8\u5236\u4e00\u4e2a\u767d\u8272\u8fb9\u6846\u7684\u7eaf\u9ed1\u77e9\u5f62<\/p>\n<\/p>\n

                                      \n

                                      \/\/ \u7ed8\u5236\u5f53\u524d\u63a7\u5236\u65b9\u5757\u76844\u4e2a\u65b9\u5757\u683c
                                          for(i = 0; i < 4; i++)
                                          {
                                      \n
                                              x = moveBlock.blockSite[i][0];
                                              y = moveBlock.blockSite[i][1];
                                              switch(moveBlock.blockColor)
                                              {
                                      \n
                                                  case BLOCKNONE:
                                                      continue;
                                                      break;
                                                  case BLOCKBLUE:
                                                      setfillcolor(BLUE);
                                                      break;
                                                  case BLOCKGREEN:
                                                      setfillcolor(GREEN);
                                                      break;
                                                  case BLOCKCYAN:
                                                      setfillcolor(CYAN);
                                                      break;
                                                  case BLOCKRED:
                                                      setfillcolor(RED);
                                                      break;
                                                  case BLOCKMAGENTA:
                                                      setfillcolor(MAGENTA);
                                                      break;
                                                  case BLOCKBROWN:
                                                      setfillcolor(BROWN);
                                                      break;
                                                  case BLOCKYELLOW:
                                                      setfillcolor(YELLOW);
                                                      break;
                                              }
                                              \/\/ \u586b\u5145\u76f8\u5e94\u533a\u57df
                                              fillrectangle(GAMEMAP1 + y * SIDELENGTH ,GAMEMAP2 + x * SIDELENGTH ,GAMEMAP1 + (y+1)*SIDELENGTH ,GAMEMAP2 + (x+1) * SIDELENGTH );        
                                          }<\/p>\n<\/blockquote>\n

                                      5.\u548c3\u7c7b\u4f3c\uff0c\u53d8\u91cfmoveBlock.blockSite[]\u4fdd\u5b58\u4e86\u5f53\u524d\u65b9\u5757\u7684\u56db\u4e2a\u65b9\u5757\u683c\u5750\u6807\uff0c\u6839\u636e\u65b9\u5757\u989c\u8272moveBlock.blockColor\uff0c\u901a\u8fc7switch\u9009\u62e9\u76f8\u5e94\u7684\u989c\u8272\uff0c\u7136\u540efillrectangle\u586b\u5145\uff0c\u5f97\u5230\u5f53\u524d\u65b9\u5757\u3002<\/p>\n<\/p>\n

                                      \n

                                      \/\/ \u7ed8\u5236\u6e38\u620f\u5b9e\u65f6\u753b\u9762
                                          for(i = 0; i < TETRISHEIGHT; i++)
                                          {
                                      \n
                                              for(j = 0; j < TETRISWIDTH; j++)
                                              {    
                                                  switch(tetrisMap[i][j])
                                                  {
                                      \n
                                                      case BLOCKNONE:
                                                          continue;
                                                          break;
                                                      case BLOCKBLUE:
                                                          setfillcolor(BLUE);
                                                          break;
                                                      case BLOCKGREEN:
                                                          setfillcolor(GREEN);
                                                          break;
                                                      case BLOCKCYAN:
                                                          setfillcolor(CYAN);
                                                          break;
                                                      case BLOCKRED:
                                                          setfillcolor(RED);
                                                          break;
                                                      case BLOCKMAGENTA:
                                                          setfillcolor(MAGENTA);
                                                          break;
                                                      case BLOCKBROWN:
                                                          setfillcolor(BROWN);
                                                          break;
                                                      case BLOCKYELLOW:
                                                          setfillcolor(YELLOW);
                                                          break;
                                                  }
                                                  \/\/ \u586b\u5145\u76f8\u5e94\u533a\u57df
                                                  fillrectangle(GAMEMAP1 + j * SIDELENGTH ,GAMEMAP2 + i * SIDELENGTH ,GAMEMAP1 + (j+1)*SIDELENGTH ,GAMEMAP2 + (i+1) * SIDELENGTH );        
                                              }
                                          }<\/p>\n<\/blockquote>\n

                                      6.\u548c3\u30015\u7c7b\u4f3c\uff0ctetrisMap[]\u6570\u7ec4\u4fdd\u5b58\u4e86\u6e38\u620f\u5730\u56fe\u4e2d\u5df2\u7ecf\u56fa\u5b9a\u4e0b\u6765\u7684\u65b9\u5757\u548c\u989c\u8272\uff0c\u901a\u8fc7switch\u9009\u62e9\u989c\u8272\uff0c\u7136\u540e\u4f7f\u7528fillrectangle()\u51fd\u6570\uff0c\u7ed8\u5236\u6240\u6709\u56fa\u5b9a\u65b9\u5757\u3002<\/p>\n<\/p>\n

                                        \n
                                      • \n

                                        3.tetrisNewBlock() \u51fd\u6570<\/h4>\n<\/li>\n<\/ul>\n

                                        \u5f53\u65b0\u65b9\u5757\u6807\u8bc6player.newBlockFlag\u4e3a1\u65f6\uff0c\u4f1a\u6267\u884c\u672c\u51fd\u6570\uff0c\u628a\u9884\u751f\u6210\u65b9\u5757\u52a0\u8f7d\u8fdb\u6e38\u620f\uff0c\u6210\u4e3a\u5f53\u524d\u63a7\u5236\u65b9\u5757\uff1b\u4e4b\u540e\u518d\u83b7\u53d6\u968f\u673a\u6570\uff0c\u751f\u6210\u65b0\u7684\u9884\u751f\u6210\u65b9\u5757\u3002<\/p>\n

                                        void tetrisNewBlock(void) { int i,j,k; \/\/ \u628a\u4e0a\u4e00\u4e2a\u968f\u673a\u65b9\u5757\u52a0\u8f7d\u8fdb\u5f53\u524d\u65b9\u5757\u6570\u7ec4 k = 0; for(i = 0; i < BLOCKSPACE; i++) { if(preBlock.tetrisPreBlock[i]) { moveBlock.blockColor = preBlock.tetrisPreBlock[i]; \/\/ \u8bb0\u5f55\u65b9\u5757\u989c\u8272 moveBlock.blockSite[k][0] = i\/5; \/\/ \u8bb0\u5f55\u65b9\u5757\u683c\u7684X\u5750\u6807 moveBlock.blockSite[k][1] = 5 + i%5; \/\/ \u8bb0\u5f55\u65b9\u5757\u683c\u7684Y\u5750\u6807 k++; } } player.blockType = preBlock.blockType; \/\/ \u8bb0\u5f55\u65b9\u5757\u7684\u7c7b\u578b player.blockStyle = preBlock.blockStyle; \/\/ \u8bb0\u5f55\u65b9\u5757\u7684\u5f62\u72b6(\u671d\u5411) \/\/ \u83b7\u53d6\u968f\u673a\u6570\uff0c\u751f\u6210\u65b0\u7684\u968f\u673a\u65b9\u5757 srand((unsigned)time(NULL)); i = rand() % BLOCKTYPE; j = rand() % BLOCKSTYLE; for(k = 0; k < BLOCKSPACE;k++) { preBlock.tetrisPreBlock[k] = block[i][j][k]; } preBlock.blockType = i; preBlock.blockStyle = j; }<\/code><\/pre>\n<\/p>\n
                                        \n

                                        \/\/ \u628a\u4e0a\u4e00\u4e2a\u968f\u673a\u65b9\u5757\u52a0\u8f7d\u8fdb\u5f53\u524d\u65b9\u5757\u6570\u7ec4
                                            k = 0;
                                            for(i = 0; i < BLOCKSPACE; i++)
                                            {
                                        \n
                                                if(preBlock.tetrisPreBlock[i])
                                                {
                                        \n
                                                    moveBlock.blockColor = preBlock.tetrisPreBlock[i];    \/\/ \u8bb0\u5f55\u65b9\u5757\u989c\u8272
                                                    moveBlock.blockSite[k][0] = i\/5;                    \/\/ \u8bb0\u5f55\u65b9\u5757\u683c\u7684X\u5750\u6807
                                                    moveBlock.blockSite[k][1] = 5 + i%5;                \/\/ \u8bb0\u5f55\u65b9\u5757\u683c\u7684Y\u5750\u6807
                                                    k++;
                                                }
                                            }
                                            player.blockType = preBlock.blockType;        \/\/ \u8bb0\u5f55\u65b9\u5757\u7684\u7c7b\u578b
                                            player.blockStyle = preBlock.blockStyle;    \/\/ \u8bb0\u5f55\u65b9\u5757\u7684\u5f62\u72b6(\u671d\u5411)<\/p>\n<\/blockquote>\n

                                        1.preBlock.tetrisPreBlock[i]\u6570\u7ec4\u670916\u4e2a\u6210\u5458\u4e3a0\uff0c\u8fd8\u67094\u4e2a\u975e0\u6210\u5458\uff08\u65b9\u5757\u683c\uff09\uff0c\u68c0\u6d4b\u5230\u975e0\u6210\u5458\uff08\u65b9\u5757\u683c\uff09\u65f6\uff0c\u5c31\u4f1a\u8bb0\u5f55\u65b9\u5757\u989c\u8272\u3001\u5750\u6807\u3001\u7c7b\u578b\u3001\u5f62\u72b6\uff08\u671d\u5411\uff09\uff0c\u4fdd\u5b58\u5230\u5f53\u524d\u65b9\u5757\u53d8\u91cfmoveBlock\u3002<\/p>\n<\/p>\n

                                        \n

                                        \/\/ \u83b7\u53d6\u968f\u673a\u6570\uff0c\u751f\u6210\u65b0\u7684\u968f\u673a\u65b9\u5757
                                            srand((unsigned)time(NULL));        
                                            i = rand() % BLOCKTYPE;
                                            j = rand() % BLOCKSTYLE;
                                            for(k = 0; k < BLOCKSPACE;k++)
                                            {
                                        \n
                                                preBlock.tetrisPreBlock[k] = block[i][j][k];
                                            }
                                            preBlock.blockType = i;
                                            preBlock.blockStyle = j;<\/p>\n<\/blockquote>\n

                                        2.\u751f\u6210\u968f\u673a\u6570\uff0c\u7136\u540e\u5f97\u5230\u65b9\u5757\u7c7b\u578b\u548c\u5f62\u72b6\uff08\u671d\u5411\uff09\uff0c\u518d\u628a\u65b9\u5757\u6570\u636e\u5e93\u4e2d\u5bf9\u5e94\u768420\u4e2a\u6210\u5458\u503c\u590d\u5236\u5230preBlock.tetrisPreBlock\u6570\u7ec4\u4e2d\uff0c\u5c31\u6210\u4e3a\u4e86\u4e00\u4e2a\u65b0\u7684\u968f\u673a\u65b9\u5757\u3002<\/p>\n<\/p>\n

                                        4.tetrisMoveUp() \u51fd\u6570<\/h4>\n

                                        \u5f53\u73a9\u5bb6\u6309\u4e0bW\u952e\u540e\uff0c\u4f1a\u6267\u884c\u6b64\u51fd\u6570\uff0c\u5982\u679c\u5f53\u524d\u65b9\u5757\u53ef\u6539\u53d8\u5f62\u72b6\uff08\u671d\u5411\uff09\uff0c\u5219\u6539\u53d8\u5f62\u72b6\uff08\u671d\u5411\uff09\u3002<\/p>\n

                                        void tetrisMoveUp(void) { int i,k; int bStyle; int ux,uy; \/\/ \u6539\u53d8\u65b9\u5757\u671d\u5411\u524d\u540e\uff0c\u65b9\u5757\u683c\u7684\u4f4d\u79fb\u77e2\u91cf int blocksite2[4][2]; \/\/ \u8bb0\u5f55\u6539\u53d8\u671d\u5411\u524d\uff0c4\u4e2a\u65b9\u5757\u7684\u65b9\u5757\u5e93\u5750\u6807 int blocksite3[4][2]; \/\/ \u8bb0\u5f55\u6539\u53d8\u671d\u5411\u540e\uff0c4\u4e2a\u65b9\u5757\u7684\u65b9\u5757\u5e93\u5750\u6807 int blocksite4[4][2]; \/\/ \u8bb0\u5f55\u6539\u53d8\u671d\u5411\u540e\uff0c4\u4e2a\u65b9\u5757\u7684\u6e38\u620f\u5730\u56fe\u5750\u6807 \/\/ \u627e\u52304\u4e2a\u65b9\u5757\u683c\u7684\u65b9\u5757\u5e93\u5750\u6807 k = 0; for(i = 0; i < BLOCKSPACE; i++) { \/\/ \u5f97\u52304\u4e2a\u65b9\u5757\u5750\u6807\u540e\uff0c\u9000\u51fa\u5faa\u73af if(k > 3) { break; } if(block[player.blockType][player.blockStyle][i]) { blocksite2[k][0] = i \/ 5; blocksite2[k][1] = i % 5; k++; } } \/\/ \u627e\u5230\u6539\u53d8\u671d\u5411\u540e\uff0c4\u4e2a\u65b9\u5757\u683c\u7684\u65b9\u5757\u5e93\u5750\u6807 k = 0; bStyle = (player.blockStyle + 1)%BLOCKSTYLE; \/\/ \u83b7\u53d6\u6539\u53d8\u671d\u5411\u540e\u7684\u65b9\u5757\u5f62\u72b6 for(i = 0; i < BLOCKSPACE; i++) { \/\/ \u5f97\u52304\u4e2a\u65b9\u5757\u5750\u6807\u540e\uff0c\u9000\u51fa\u5faa\u73af if(k > 3) { break; } if(block[player.blockType][bStyle][i]) { blocksite3[k][0] = i \/ 5; blocksite3[k][1] = i % 5; k++; } } \/\/ \u6839\u636e\u6539\u53d8\u524d\u540e\u65b9\u5757\u5750\u6807\u7684\u4f4d\u79fb\u77e2\u91cf\uff0c\u5f97\u5230\u6539\u53d8\u671d\u5411\u540e\u7684\u5f53\u524d\u63a7\u5236\u65b9\u5757\u7684\u65b0\u5750\u6807 for(i = 0; i < 4; i++) { ux = blocksite3[i][0] - blocksite2[i][0]; \/\/ \u83b7\u53d6\u65b9\u683c\u7684X\u4f4d\u79fb\u77e2\u91cf uy = blocksite3[i][1] - blocksite2[i][1]; \/\/ \u83b7\u53d6\u65b9\u683c\u7684Y\u4f4d\u79fb\u77e2\u91cf blocksite4[i][0] = moveBlock.blockSite[i][0] + ux; \/\/ \u5f97\u5230\u6539\u53d8\u671d\u5411\u540e\u7684\uff0c\u5f53\u524d\u63a7\u5236\u65b9\u5757\u683c\uff0c\u4f4d\u4e8e\u6e38\u620f\u5730\u56fe\u7684\u65b0X\u5750\u6807 blocksite4[i][1] = moveBlock.blockSite[i][1] + uy; \/\/ \u5f97\u5230\u6539\u53d8\u671d\u5411\u540e\u7684\uff0c\u5f53\u524d\u63a7\u5236\u65b9\u5757\u683c\uff0c\u4f4d\u4e8e\u6e38\u620f\u5730\u56fe\u7684\u65b0Y\u5750\u6807 if( (blocksite4[i][0] < 0) \/\/ \u5224\u65ad\u65b0\u5750\u6807\u662f\u5426\u8d85\u51fa\u6e38\u620f\u5730\u56fe\uff0c\u8d85\u51fa\u5219\u7ec8\u6b62\u6539\u53d8\u65b9\u5757\u671d\u5411 || (blocksite4[i][1] < 0) || (blocksite4[i][0] > TETRISHEIGHT - 1) || (blocksite4[i][1] > TETRISWIDTH - 1) || ( tetrisMap[blocksite4[i][0]][blocksite4[i][1]] ) ) \/\/ \u5982\u679c\u65b0\u5750\u6807\u5728\u6e38\u620f\u5730\u56fe\u4e2d\u5df2\u5b58\u5728\u65b9\u5757\u683c\uff0c\u5219\u7ec8\u6b62\u6539\u53d8\u65b9\u5757\u671d\u5411 { return; } } \/\/ \u6539\u53d8\u65b9\u5757\u671d\u5411\u6ca1\u6709\u95ee\u9898\uff0c\u5219\u66f4\u65b0\u65b0\u65b9\u5757\u7684\u5750\u6807 for(i = 0;i < 4; i++) { moveBlock.blockSite[i][0] = blocksite4[i][0]; moveBlock.blockSite[i][1] = blocksite4[i][1]; } player.blockStyle = bStyle; \/\/ \u66f4\u65b0\u65b9\u5757\u683c\u5f62\u72b6 }<\/code><\/pre>\n<\/p>\n
                                        \n

                                        \/\/ \u627e\u52304\u4e2a\u65b9\u5757\u683c\u7684\u65b9\u5757\u5e93\u5750\u6807
                                            k = 0;
                                            for(i = 0; i < BLOCKSPACE; i++)
                                            {
                                        \n
                                                \/\/ \u5f97\u52304\u4e2a\u65b9\u5757\u5750\u6807\u540e\uff0c\u9000\u51fa\u5faa\u73af
                                                if(k > 3)
                                                {    
                                                    break;
                                                }
                                                if(block[player.blockType][player.blockStyle][i])
                                                {
                                        \n
                                                    blocksite2[k][0] = i \/ 5;
                                                    blocksite2[k][1] = i % 5;
                                                    k++;
                                                }
                                            }<\/p>\n<\/blockquote>\n

                                        1.\u6839\u636e\u5f53\u524d\u63a7\u5236\u65b9\u5757\u7684\u5f62\u72b6\uff08\u671d\u5411\uff09\uff0c\u5728\u65b9\u5757\u6570\u636e\u5e93\u4e2d\u627e\u5230\u5bf9\u5e94\u7684\u5750\u6807\uff0c\u5e76\u653e\u5165\u6570\u7ec4blocksite2\u4e2d\u3002<\/p>\n<\/p>\n

                                        \n

                                        \/\/ \u627e\u5230\u6539\u53d8\u671d\u5411\u540e\uff0c4\u4e2a\u65b9\u5757\u683c\u7684\u65b9\u5757\u5e93\u5750\u6807
                                            k = 0;
                                            bStyle = (player.blockStyle + 1)%BLOCKSTYLE;    \/\/ \u83b7\u53d6\u6539\u53d8\u671d\u5411\u540e\u7684\u65b9\u5757\u5f62\u72b6
                                            for(i = 0; i < BLOCKSPACE; i++)
                                            {
                                        \n
                                                \/\/ \u5f97\u52304\u4e2a\u65b9\u5757\u5750\u6807\u540e\uff0c\u9000\u51fa\u5faa\u73af
                                                if(k > 3)
                                                {    
                                                    break;
                                                }
                                                if(block[player.blockType][bStyle][i])
                                                {
                                        \n
                                                    blocksite3[k][0] = i \/ 5;
                                                    blocksite3[k][1] = i % 5;
                                                    k++;
                                                }
                                            }<\/p>\n<\/blockquote>\n

                                        2. player.blockStyle\u662f\u5f53\u524d\u65b9\u5757\u7684\u5f62\u72b6\uff08\u671d\u5411\uff09\uff0c\u53ea\u8981\u628a\u8fd9\u4e2a\u53d8\u91cf\u52a01\uff0c\u518d\u53d6\u4f59\u65b9\u5757\u5f62\u72b6\u6570\uff0c\u5c31\u53ef\u4ee5\u5f97\u5230\u65b0\u7684\u65b9\u5757\u5f62\u72b6\uff08\u671d\u5411\uff09bStyle\uff1b\u6839\u636e\u65b9\u5757\u7c7b\u578b\uff0c\u8fd8\u6709\u65b0\u7684\u671d\u5411bStyle\uff0c\u5c31\u53ef\u4ee5\u4ece\u65b9\u5757\u6570\u636e\u5e93\u4e2d\u5f97\u5230\u65b0\u65b9\u5757\u7684\u5750\u6807\uff0c\u628a\u65b0\u65b9\u5757\u7684\u5750\u6807\u653e\u5165blocksite3[]\u6570\u7ec4\u3002<\/p>\n<\/p>\n

                                        \n

                                        \/\/ \u6839\u636e\u6539\u53d8\u524d\u540e\u65b9\u5757\u5750\u6807\u7684\u4f4d\u79fb\u77e2\u91cf\uff0c\u5f97\u5230\u6539\u53d8\u671d\u5411\u540e\u7684\u5f53\u524d\u63a7\u5236\u65b9\u5757\u7684\u65b0\u5750\u6807
                                            for(i = 0; i < 4; i++)
                                            {
                                        \n
                                                ux = blocksite3[i][0] - blocksite2[i][0];    \/\/ \u83b7\u53d6\u65b9\u683c\u7684X\u4f4d\u79fb\u77e2\u91cf
                                                uy = blocksite3[i][1] - blocksite2[i][1];    \/\/ \u83b7\u53d6\u65b9\u683c\u7684Y\u4f4d\u79fb\u77e2\u91cf<\/p>\n

                                                blocksite4[i][0] = moveBlock.blockSite[i][0] + ux;    \/\/ \u5f97\u5230\u6539\u53d8\u671d\u5411\u540e\u7684\uff0c\u5f53\u524d\u63a7\u5236\u65b9\u5757\u683c\uff0c\u4f4d\u4e8e\u6e38\u620f\u5730\u56fe\u7684\u65b0X\u5750\u6807
                                                blocksite4[i][1] = moveBlock.blockSite[i][1] + uy;    \/\/ \u5f97\u5230\u6539\u53d8\u671d\u5411\u540e\u7684\uff0c\u5f53\u524d\u63a7\u5236\u65b9\u5757\u683c\uff0c\u4f4d\u4e8e\u6e38\u620f\u5730\u56fe\u7684\u65b0Y\u5750\u6807
                                                
                                                if( (blocksite4[i][0] < 0)                    \/\/ \u5224\u65ad\u65b0\u5750\u6807\u662f\u5426\u8d85\u51fa\u6e38\u620f\u5730\u56fe\uff0c\u8d85\u51fa\u5219\u7ec8\u6b62\u6539\u53d8\u65b9\u5757\u671d\u5411
                                                    || (blocksite4[i][1] < 0)
                                                    || (blocksite4[i][0] > TETRISHEIGHT - 1)
                                                    || (blocksite4[i][1] > TETRISWIDTH - 1)
                                                    || ( tetrisMap[blocksite4[i][0]][blocksite4[i][1]] ) )    \/\/ \u5982\u679c\u65b0\u5750\u6807\u5728\u6e38\u620f\u5730\u56fe\u4e2d\u5df2\u5b58\u5728\u65b9\u5757\u683c\uff0c\u5219\u7ec8\u6b62\u6539\u53d8\u65b9\u5757\u671d\u5411
                                                {
                                        \n
                                                    return;
                                                }
                                            }<\/p>\n<\/blockquote>\n

                                        3.\u65e2\u7136\u901a\u8fc71\u30012\u6b65\u9aa4\uff0c\u5f97\u5230\u4e86\u65b9\u5757\u6539\u53d8\u5f62\u72b6\u524d\u540e\uff0c\u4f4d\u4e8e\u65b9\u5757\u6570\u636e\u5e93\u4e2d\u7684\u5750\u6807\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u901a\u8fc7\u628a\u65b0\u65e7\u5750\u6807\u76f8\u51cf\uff0c\u5f97\u5230\u65e7\u5750\u6807\u7684\u4f4d\u79fb\u77e2\u91cfux\uff0cuy\uff1b<\/p>\n

                                        \u901a\u8fc7\u4f4d\u79fb\u77e2\u91cfux\uff0cuy\uff0c\u8fd8\u6709\u5f53\u524d\u65b9\u5757\u7684\u56db\u4e2a\u65b9\u5757\u683c\u5750\u6807moveBlock.blockSite\uff0c\u5c31\u53ef\u4ee5\u5f97\u5230\u6539\u53d8\u5f62\u72b6\uff08\u671d\u5411\uff09\u540e\uff0c\u5f53\u524d\u65b9\u5757\u7684\u65b0\u5750\u6807\uff0c\u5e76\u628a\u65b0\u5750\u6807\u653e\u5165blocksite4[][]\u6570\u7ec4\u4e2d\uff1b<\/p>\n

                                        \u6709\u4e86\u65b0\u5750\u6807blocksite4\uff0c\u5c31\u53ef\u4ee5\u5224\u65ad\u5f53\u524d\u65b9\u5757\u662f\u5426\u53ef\u4ee5\u6539\u53d8\u5f62\u72b6\uff08\u671d\u5411\uff09\uff0c\u9996\u5148\u5224\u65ad\u65b0\u5750\u6807\u662f\u5426\u8d85\u8fc7\u6e38\u620f\u5730\u56fe\u8303\u56f4\uff0c\u518d\u5224\u65ad\u65b0\u5750\u6807\u4f4d\u7f6e\uff0c\u662f\u5426\u5df2\u7ecf\u5b58\u5728\u65b9\u5757\uff1b\u53ea\u8981\u6709\u4e00\u4e2a\u4e0d\u7b26\u5408\uff0c\u90a3\u4e48\u672c\u6b21\u64cd\u4f5c\u65e0\u6548\uff0c\u9000\u51fa\u51fd\u6570\u3002<\/p>\n<\/p>\n

                                        \n

                                        \/\/ \u6539\u53d8\u65b9\u5757\u671d\u5411\u6ca1\u6709\u95ee\u9898\uff0c\u5219\u66f4\u65b0\u65b0\u65b9\u5757\u7684\u5750\u6807
                                            for(i = 0;i < 4; i++)
                                            {
                                        \n
                                                moveBlock.blockSite[i][0] = blocksite4[i][0];
                                                moveBlock.blockSite[i][1] = blocksite4[i][1];
                                            }
                                            player.blockStyle = bStyle;    \/\/ \u66f4\u65b0\u65b9\u5757\u683c\u5f62\u72b6<\/p>\n<\/blockquote>\n

                                        4.\u5982\u679c\u65b9\u5757\u53ef\u4ee5\u6539\u53d8\u5f62\u72b6\uff08\u671d\u5411\uff09\uff0c\u90a3\u4e48\u5c31\u628a\u65b9\u5757\u7684\u65b0\u5750\u6807blocksite4\uff0c\u8d4b\u503c\u7ed9\u5f53\u524d\u65b9\u5757\u5750\u6807moveBlock.blockSite\uff1b\u518d\u628a\u65b0\u7684\u65b9\u5757\u5f62\u72b6\uff08\u671d\u5411\uff09bStyle\uff0c\u8d4b\u503c\u7ed9\u5f53\u524d\u65b9\u5757\u5f62\u72b6player.blockStyle<\/p>\n<\/p>\n

                                        5.tetrisMoveDown() \u51fd\u6570<\/h4>\n

                                        \u5f53\u65b9\u5757\u4e0b\u79fb\u6807\u8bc6player.moveFlag\u4e3a1\u65f6\uff0c\u4f1a\u6267\u884c\u672c\u51fd\u6570\uff0c\u63a7\u5236\u5f53\u524d\u65b9\u5757\u4e0b\u79fb\u3002<\/p>\n

                                        player.moveFlag\u4e3a1\u6709\u4e24\u79cd\u6761\u4ef6<\/p>\n

                                        1\uff1a\u6bcf\u4e2a\u5468\u671f\uff08\u9ed8\u8ba4500ms\uff09\u4f1a\u8d4b\u503c\u4e3a1\u3002<\/p>\n

                                        2\uff1a\u7528\u6237\u6309\u4e0bS\u952e\uff0c\u4f1a\u8d4b\u503c\u4e3a1\u3002<\/p>\n

                                        void tetrisMoveDown(void) { int i; int x,y; \/\/ \u5224\u65ad\u5f53\u524d\u65b9\u5757\u662f\u5426\u5230\u8fbe\u5730\u56fe\u5e95\u90e8 for(i = 0; i < 4; i++) { if(moveBlock.blockSite[i][0] > TETRISHEIGHT - 2) { \/\/ \u5982\u679c\u5230\u8fbe\u5730\u56fe\u5e95\u90e8\uff0c\u628a\u751f\u6210\u65b0\u65b9\u5757\u6807\u8bc6\u7f6e1 player.newBlockFlag = TRUE; return; } } \/\/ \u5224\u65ad\u5f53\u524d\u65b9\u5757\u80fd\u5426\u4e0b\u79fb,\u662f\u5426\u4f1a\u548c\u6e38\u620f\u5730\u56fe\u5df2\u5b58\u5728\u7684\u65b9\u5757\u4ea7\u751f\u51b2\u7a81 for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0] + 1; \/\/ \u83b7\u53d6\u65b9\u5757\u4e0b\u79fb\u540e\u7684\u65b0X\u5750\u6807 y = moveBlock.blockSite[i][1]; \/\/ \u83b7\u53d6\u65b9\u5757\u4e0b\u79fb\u540e\u7684\u65b0Y\u5750\u6807 \/\/ \u5982\u679c\u65b0\u5750\u6807\u5728\u6e38\u620f\u5730\u56fe\u4e2d\uff0c\u5df2\u7ecf\u5b58\u5728\u65b9\u5757\u683c\uff0c\u5219\u65b9\u5757\u505c\u6b62\u79fb\u52a8 if(tetrisMap[x][y]) { player.newBlockFlag = TRUE; return; } } \/\/ \u5f53\u524d\u65b9\u5757\u4e0b\u79fb for(i = 0; i < 4; i++) { moveBlock.blockSite[i][0]++; } }<\/code><\/pre>\n<\/p>\n
                                        \n

                                        \/\/ \u5224\u65ad\u5f53\u524d\u65b9\u5757\u662f\u5426\u5230\u8fbe\u5730\u56fe\u5e95\u90e8
                                            for(i = 0; i < 4; i++)
                                            {
                                        \n
                                                if(moveBlock.blockSite[i][0] > TETRISHEIGHT - 2)
                                                {
                                        \n
                                                    \/\/ \u5982\u679c\u5230\u8fbe\u5730\u56fe\u5e95\u90e8\uff0c\u628a\u751f\u6210\u65b0\u65b9\u5757\u6807\u8bc6\u7f6e1
                                                    player.newBlockFlag = TRUE;
                                                    return;
                                                }
                                            }<\/p>\n<\/blockquote>\n

                                        1.\u6bcf\u6b21\u65b9\u5757\u4e0b\u79fb\u65f6\uff0c\u90fd\u4f1a\u5148\u5224\u65ad\u65b9\u5757\u662f\u5426\u5230\u8fbe\u6e38\u620f\u5730\u56fe\u5e95\u90e8\uff0c\u5982\u679c\u5230\u8fbe\u5e95\u90e8\uff0c\u4f1a\u7ed9\u65b0\u65b9\u5757\u6807\u8bc6player.newBlockFlag\u8d4b1\uff0c\u7136\u540e\u9000\u51fa\u672c\u51fd\u6570\uff0c\u5f53\u524d\u65b9\u5757\u4e0d\u518d\u79fb\u52a8\u3002<\/p>\n<\/p>\n

                                        \n

                                        \/\/ \u5224\u65ad\u5f53\u524d\u65b9\u5757\u80fd\u5426\u4e0b\u79fb,\u662f\u5426\u4f1a\u548c\u6e38\u620f\u5730\u56fe\u5df2\u5b58\u5728\u7684\u65b9\u5757\u4ea7\u751f\u51b2\u7a81
                                            for(i = 0; i < 4; i++)
                                            {
                                        \n
                                                x = moveBlock.blockSite[i][0] + 1;    \/\/ \u83b7\u53d6\u65b9\u5757\u4e0b\u79fb\u540e\u7684\u65b0X\u5750\u6807
                                                y = moveBlock.blockSite[i][1];        \/\/ \u83b7\u53d6\u65b9\u5757\u4e0b\u79fb\u540e\u7684\u65b0Y\u5750\u6807
                                                \/\/ \u5982\u679c\u65b0\u5750\u6807\u5728\u6e38\u620f\u5730\u56fe\u4e2d\uff0c\u5df2\u7ecf\u5b58\u5728\u65b9\u5757\u683c\uff0c\u5219\u65b9\u5757\u505c\u6b62\u79fb\u52a8
                                                if(tetrisMap[x][y])
                                                {
                                        \n
                                                    player.newBlockFlag = TRUE;
                                                    return;
                                                }
                                            }<\/p>\n<\/blockquote>\n

                                        2.\u65b9\u5757\u4e0b\u79fb\u4f1a\u6539\u53d8moveBlock.blockSite[][]\u6570\u7ec4\u7684X\u5750\u6807\uff0c\u52a0\u4e00\uff1b<\/p>\n

                                        \u5224\u65ad\u6e38\u620f\u5730\u56fe\u4e2d\u65b0\u5750\u6807\u4f4d\u7f6e\u662f\u5426\u5df2\u5b58\u5728\u65b9\u5757\uff0c\u5982\u679c\u5b58\u5728\u65b9\u5757\uff0c\u4f1a\u7ed9\u65b0\u65b9\u5757\u6807\u8bc6player.newBlockFlag\u8d4b1\uff0c\u7136\u540e\u9000\u51fa\u672c\u51fd\u6570\uff0c\u5f53\u524d\u65b9\u5757\u4e0d\u518d\u79fb\u52a8\u3002<\/p>\n<\/p>\n

                                        \n

                                        \/\/ \u5f53\u524d\u65b9\u5757\u4e0b\u79fb
                                            for(i = 0; i < 4; i++)
                                            {
                                        \n
                                                moveBlock.blockSite[i][0]++;
                                            }<\/p>\n<\/blockquote>\n

                                        3.\u65b9\u5757\u53ef\u4ee5\u4e0b\u79fb\uff0c\u5219\u5c06\u5f53\u524d\u65b9\u5757\u76844\u4e2a\u65b9\u5757\u683c\u7684X\u5750\u6807\u90fd\u52a0\u4e00\u3002<\/p>\n<\/p>\n

                                        6.tetrisMoveLeft() \u51fd\u6570<\/h4>\n

                                        \u6bcf\u5f53\u7528\u6237\u6309\u4e0bA\u952e\uff0c\u4f1a\u6267\u884c\u672c\u51fd\u6570\uff0c\u63a7\u5236\u5f53\u524d\u65b9\u5757\u5de6\u79fb\u3002<\/p>\n

                                        void tetrisMoveLeft(void) { int i; int x,y; \/\/ \u5148\u5224\u65ad\u662f\u5426\u80fd\u5de6\u79fb for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0]; y = moveBlock.blockSite[i][1]; \/\/ \u5c06Y\u5750\u6807\u51cf\u4e00\uff0c\u518d\u5224\u65ad\u662f\u5426\u8d85\u51fa\u5730\u56fe\u8303\u56f4\u6216\u5f15\u8d77\u51b2\u7a81 if( (y - 1) < 0 \/\/ 1.\u8d85\u51fa\u5730\u56fe\u8303\u56f4 || tetrisMap[x][y - 1]) \/\/ 2.\u65b9\u5757\u5c06\u8981\u79fb\u52a8\u7684\u5730\u65b9\u5df2\u5b58\u5728\u65b9\u5757\u683c { return; \/\/ \u8d85\u51fa\u5730\u56fe\u8303\u56f4\u6216\u51b2\u7a81\uff0c\u65e0\u6cd5\u5de6\u79fb } } \/\/ \u5de6\u79fb for(i = 0; i < 4; i++) { moveBlock.blockSite[i][1]--; } }<\/code><\/pre>\n<\/p>\n
                                        \n

                                        \/\/ \u5148\u5224\u65ad\u662f\u5426\u80fd\u5de6\u79fb
                                            for(i = 0; i < 4; i++)
                                            {
                                        \n
                                                x = moveBlock.blockSite[i][0];
                                                y = moveBlock.blockSite[i][1];
                                                \/\/ \u5c06Y\u5750\u6807\u51cf\u4e00\uff0c\u518d\u5224\u65ad\u662f\u5426\u8d85\u51fa\u5730\u56fe\u8303\u56f4\u6216\u5f15\u8d77\u51b2\u7a81
                                                if( (y - 1) < 0                \/\/ 1.\u8d85\u51fa\u5730\u56fe\u8303\u56f4
                                                    || tetrisMap[x][y - 1])    \/\/ 2.\u65b9\u5757\u5c06\u8981\u79fb\u52a8\u7684\u5730\u65b9\u5df2\u5b58\u5728\u65b9\u5757\u683c
                                                {
                                        \n
                                                    return;    \/\/ \u8d85\u51fa\u5730\u56fe\u8303\u56f4\u6216\u51b2\u7a81\uff0c\u65e0\u6cd5\u5de6\u79fb
                                                }
                                            }<\/p>\n<\/blockquote>\n

                                        1.\u65b9\u5757\u5de6\u79fb\uff0c\u5c31\u662f\u628a\u65b9\u5757\u7684Y\u5750\u6807\u51cf\u4e00\uff0c\u7136\u540e\u5224\u65ad\u65b0\u7684\u5750\u6807\u662f\u5426\u8d85\u8fc7\u6e38\u620f\u5730\u56fe\u8303\u56f4\u3001\u65b0\u7684\u5750\u6807\u662f\u5426\u5df2\u7ecf\u5b58\u5728\u65b9\u5757\uff1b\u53ea\u8981\u6709\u4e00\u4e2a\u6761\u4ef6\u4e0d\u6ee1\u8db3\uff0c\u5c31\u4f1a\u9000\u51fa\u672c\u51fd\u6570\uff0c\u65e0\u6cd5\u5de6\u79fb\u3002<\/p>\n<\/p>\n

                                        \n

                                        \/\/ \u5de6\u79fb
                                            for(i = 0; i < 4; i++)
                                            {
                                        \n
                                                moveBlock.blockSite[i][1]--;
                                            }<\/p>\n<\/blockquote>\n

                                         2.\u53ef\u4ee5\u5de6\u79fb\uff0c\u5219\u5c06\u5f53\u524d\u65b9\u5757\u7684\u56db\u4e2a\u65b9\u5757\u683c\u7684Y\u5750\u6807\u90fd\u51cf\u4e00\u3002<\/p>\n<\/p>\n

                                        7.tetrisMoveRight() \u51fd\u6570<\/h4>\n

                                        \u6bcf\u5f53\u7528\u6237\u6309\u4e0bD\u952e\uff0c\u4f1a\u6267\u884c\u672c\u51fd\u6570\uff0c\u63a7\u5236\u5f53\u524d\u65b9\u5757\u53f3\u79fb\u3002<\/p>\n

                                        \u548c\u5de6\u79fb\u51fd\u6570\u57fa\u672c\u76f8\u540c\uff0c\u5c31\u662fY\u5750\u6807\u53d8\u4e3a\u52a01\uff0c\u56e0\u6b64\u4e0d\u518d\u8fc7\u591a\u8bf4\u660e\u3002<\/p>\n

                                        void tetrisMoveRight(void) { int i; int x,y; \/\/k = 0; \/\/ \u5148\u5224\u65ad\u662f\u5426\u80fd\u53f3\u79fb for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0]; y = moveBlock.blockSite[i][1]; \/\/ \u5c06Y\u5750\u6807\u52a01\uff0c\u518d\u5224\u65ad\u662f\u5426\u8d85\u51fa\u5730\u56fe\u8303\u56f4\u6216\u51b2\u7a81 if( ((y + 1) >= TETRISWIDTH) \/\/ 1.\u8d85\u51fa\u5730\u56fe\u8303\u56f4 || (tetrisMap[x][y + 1]) ) \/\/ 2.\u65b9\u5757\u5c06\u8981\u79fb\u52a8\u7684\u5730\u65b9\u5df2\u5b58\u5728\u65b9\u5757\u683c { return; \/\/ \u8d85\u51fa\u5730\u56fe\u8303\u56f4\u6216\u51b2\u7a81\uff0c\u65e0\u6cd5\u5de6\u79fb } } \/\/ \u53f3\u79fb for(i = 0; i < 4; i++) { moveBlock.blockSite[i][1]++; } }<\/code><\/pre>\n<\/p>\n

                                        8.tetrisLoadBlock() \u51fd\u6570<\/h4>\n

                                        \u6bcf\u5f53\u65b0\u65b9\u5757\u6807\u8bc6player.newBlockFlag\u4e3a1\u65f6\uff0c\u6267\u884c\u672c\u51fd\u6570\uff0c\u5c06\u5f53\u524d\u63a7\u5236\u65b9\u5757\u56fa\u5b9a\u5728\u6e38\u620f\u5730\u56fe\u3002<\/p>\n

                                        void tetrisLoadBlock(void) { int i; int x,y; \/\/ \u5c06\u5f53\u524d\u65b9\u5757\u8f7d\u5165\u6e38\u620f\u5730\u56fe for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0]; y = moveBlock.blockSite[i][1]; \/\/ \u53ea\u6709\u6e38\u620f\u5730\u56fe\u5750\u6807\u4e0d\u4e3a\u7a7a\uff0c\u624d\u4f1a\u6539\u53d8\u6e38\u620f\u5730\u56fe if(!tetrisMap[x][y]) { tetrisMap[x][y] = moveBlock.blockColor; } } }<\/code><\/pre>\n<\/p>\n

                                        9.tetrisIsOver() \u51fd\u6570<\/h4>\n

                                        \u6bcf\u5f53\u65b0\u65b9\u5757\u6807\u8bc6player.newBlockFlag\u4e3a1\u65f6\uff0c\u6267\u884c\u672c\u51fd\u6570\uff0c\u5224\u65ad\u6e38\u620f\u662f\u5426\u7ed3\u675f<\/p>\n

                                        void tetrisIsOver(void) { int i; int x,y; \/\/ \u5c06\u65b0\u7684\u79fb\u52a8\u65b9\u5757\u4e0e\u6e38\u620f\u5730\u56fe\u6bd4\u8f83\uff0c\u5982\u679c\u6709\u51b2\u7a81\u683c\uff0c\u5219\u6e38\u620f\u7ed3\u675f for(i = 0; i < 4; i++) { x = moveBlock.blockSite[i][0]; y = moveBlock.blockSite[i][1]; \/\/ \u5982\u679c\u79fb\u52a8\u65b9\u5757\u548c\u6e38\u620f\u5730\u56fe\u5728\u540c\u4e00\u5750\u6807\u90fd\u5b58\u5728\u65b9\u5757\uff0c\u5219\u6e38\u620f\u7ed3\u675f if(tetrisMap[x][y]) { player.gameOverFlag = TRUE; tetrisDraw(); tetrisQuit(); return; } } }<\/code><\/pre>\n

                                        \u5c06\u9884\u751f\u6210\u65b9\u5757\u8f7d\u5165\u6e38\u620f\u5730\u56fe\u65f6\uff0c\u548c\u6e38\u620f\u5730\u56fe\u6bd4\u8f83\uff1b\u9884\u751f\u6210\u65b9\u5757\u548c\u6e38\u620f\u5730\u56fe\u5df2\u5b58\u5728\u7684\u65b9\u5757\u91cd\u53e0\uff0c\u5219\u9884\u751f\u6210\u65b9\u5757\u65e0\u6cd5\u8f7d\u5165\u6e38\u620f\u5730\u56fe\uff0c\u6e38\u620f\u65e0\u6cd5\u7ee7\u7eed\uff0c\u5224\u65ad\u6e38\u620f\u7ed3\u675f\u3002<\/p>\n

                                        \u5c06\u6e38\u620f\u7ed3\u675f\u6807\u8bc6player.gameOverFlag\u8d4b1\uff0c\u63a5\u7740\u6267\u884ctetrisDraw()\u51fd\u6570\uff0c\u7ed8\u5236\u91cd\u53e0\u65b9\u5757\uff1b\u518d\u6267\u884ctetrisQuit()\u51fd\u6570\uff0c\u7531\u7528\u6237\u9009\u62e9\u662f\u9000\u51fa\u6e38\u620f\u8fd8\u662f\u91cd\u65b0\u5f00\u59cb\u6e38\u620f\u3002<\/p>\n<\/p>\n

                                        10.tetrisQuit() \u51fd\u6570<\/h4>\n

                                        \u672c\u51fd\u6570\u6267\u884c\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u4e00\uff1a\u6e38\u620f\u7ed3\u675f\uff0c\u73a9\u5bb6\u5df2\u65e0\u6cd5\u518d\u7ee7\u7eed\u6e38\u620f\u3002<\/p>\n

                                        \u4e8c\uff1a\u73a9\u5bb6\u6309\u4e0b\u4e86ESC\u952e\uff0c\u60f3\u8981\u4e3b\u52a8\u9000\u51fa\u6e38\u620f\u3002<\/p>\n

                                        void tetrisQuit(void) { int key,flag; flag = player.gameOverFlag; \/\/ \u8ba9\u7528\u6237\u9009\u62e9\u662f\u5426\u9000\u51fa key = MessageBox(NULL,\"\u662f\u5426\u9000\u51fa\u6e38\u620f\uff1f\",\"\u63d0\u793a\",MB_YESNO| MB_SYSTEMMODAL); switch(key) { case IDYES: player.gameOverFlag = TRUE; break; case IDNO: player.gameOverFlag = FALSE; break; default: break; } \/\/ \u5982\u679c\u6e38\u620f\u5df2\u65e0\u6cd5\u7ee7\u7eed\uff0c\u4e14\u7528\u6237\u4e0d\u9000\u51fa\u6e38\u620f\uff0c\u5219\u5f3a\u5236\u7528\u6237\u9009\u62e9\u7ed3\u675f\u6e38\u620f\uff0c\u6216\u91cd\u65b0\u5f00\u59cb\u6e38\u620f while(flag && !player.gameOverFlag) { key = MessageBox(NULL,\"\u68c0\u6d4b\u5230\u6e38\u620f\u5df2\u65e0\u6cd5\u7ee7\u7eed\uff0c\\n\u8bf7\u9009\u62e9\\\"\u662f\\\": \u9000\u51fa\u6e38\u620f\uff1b\\n\u6216\u8005\u9009\u62e9\\\"\u5426\\\": \u91cd\u542f\u6e38\u620f\uff1b\",\"\u63d0\u793a\",MB_YESNO| MB_SYSTEMMODAL); switch(key) { case IDYES: player.gameOverFlag = TRUE; break; case IDNO: tetrisInit(); player.gameOverFlag = FALSE; return; default: break; } } CLEARKEY(); }<\/code><\/pre>\n<\/p>\n
                                        \n

                                        1.flag = player.gameOverFlag;
                                            \/\/ \u8ba9\u7528\u6237\u9009\u62e9\u662f\u5426\u9000\u51fa
                                            key = MessageBox(NULL,\"\u662f\u5426\u9000\u51fa\u6e38\u620f\uff1f\",\"\u63d0\u793a\",MB_YESNO| MB_SYSTEMMODAL);
                                            switch(key)
                                            {
                                        \n
                                                case IDYES:
                                                    player.gameOverFlag = TRUE;
                                                    break;
                                                case IDNO:
                                                    player.gameOverFlag = FALSE;
                                                    break;
                                                default:
                                                    break;
                                            }<\/p>\n<\/blockquote>\n

                                        1.flag\u6807\u8bc6\u7528\u4e8e\u533a\u5206\u662f\u6e38\u620f\u7ed3\u675f\uff0c\u8fd8\u662f\u73a9\u5bb6\u4e3b\u52a8\u7ed3\u675f\u6e38\u620f\uff0c\u4e0d\u540c\u65b9\u5f0f\u6709\u4e0d\u540c\u5904\u7406\u3002<\/p>\n

                                        \u751f\u6210\u4e00\u4e2a\u6d88\u606f\u5f39\u7a97\uff0cMB_SYSTEMMODAL\u662f\u5f3a\u5236\u5f39\u7a97\u7f6e\u9876\uff0c\u529f\u80fd\u7c7b\u4f3c\u4e8e\u5fae\u4fe1\u7f6e\u9876\u529f\u80fd\u3002<\/p>\n

                                        \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n<\/p>\n

                                        key\u662f\u7528\u4e8e\u5f97\u5230\u7528\u6237\u9009\u62e9\u201c\u662f\u201d\u8fd8\u662f\u201c\u5426\u201d\uff0c\u5982\u679c\u73a9\u5bb6\u9009\u62e9\u9000\u51fa\u6e38\u620f\uff0c \u5c06\u6e38\u620f\u7ed3\u675f\u6807\u8bc6player.gameOverFlag\u7f6e1\uff1b\u53cd\u4e4b\u7f6e0\u3002<\/p>\n<\/p>\n

                                        \n

                                        \/\/ \u5982\u679c\u6e38\u620f\u5df2\u65e0\u6cd5\u7ee7\u7eed\uff0c\u4e14\u7528\u6237\u4e0d\u9000\u51fa\u6e38\u620f\uff0c\u5219\u5f3a\u5236\u7528\u6237\u9009\u62e9\u7ed3\u675f\u6e38\u620f\uff0c\u6216\u91cd\u65b0\u5f00\u59cb\u6e38\u620f
                                            while(flag
                                                && !player.gameOverFlag)
                                            {
                                        \n
                                                key = MessageBox(NULL,\"\u68c0\u6d4b\u5230\u6e38\u620f\u5df2\u65e0\u6cd5\u7ee7\u7eed\uff0c\\n\u8bf7\u9009\u62e9\\\"\u662f\\\": \u9000\u51fa\u6e38\u620f\uff1b\\n\u6216\u8005\u9009\u62e9\\\"\u5426\\\": \u91cd\u542f\u6e38\u620f\uff1b\",\"\u63d0\u793a\",MB_YESNO| MB_SYSTEMMODAL);
                                                switch(key)
                                                {
                                        \n
                                                    case IDYES:
                                                        player.gameOverFlag = TRUE;
                                                        break;
                                                    case IDNO:
                                                        tetrisInit();
                                                        player.gameOverFlag = FALSE;
                                                        return;
                                                    default:
                                                        break;
                                                }
                                            }
                                            CLEARKEY();<\/p>\n<\/blockquote>\n

                                        2.\u5982\u679c\u662f\u7528\u6237\u4e3b\u52a8\u7ed3\u675f\u6e38\u620f\uff0c\u90a3\u4e48flag\u4e3a0\uff0c\u4e0d\u4f1a\u8fdb\u5165\u5faa\u73af\uff1b<\/p>\n

                                        \u5982\u679c\u662f\u6e38\u620f\u5df2\u65e0\u6cd5\u7ee7\u7eed\u8fdb\u884c\uff0c\u90a3\u4e48flag\u4e3a1\uff0c\u4f1a\u8fdb\u5165\u5faa\u73af\u3002<\/p>\n

                                        \u5982\u679c\u8fdb\u5165\u5faa\u73af\uff0c\u4f1a\u751f\u6210\u4e00\u4e2a\u6d88\u606f\u5f39\u7a97\uff0c\u63d0\u793a\u7528\u6237\u662f\u9000\u51fa\u6e38\u620f\uff0c\u8fd8\u662f\u91cd\u65b0\u5f00\u59cb\u6e38\u620f\u5e76\u83b7\u53d6\u7528\u6237\u9009\u62e9\u7ed3\u679c\u3002<\/p>\n

                                        \"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801<\/p>\n

                                        \u901a\u8fc7key\u83b7\u53d6\u7528\u6237\u9009\u62e9\uff0c \u5982\u679c\u7528\u6237\u9009\u62e9\u201c\u662f\u201d\uff0c\u90a3\u4e48\u518d\u6b21\u8d4b\u503cplayer.gameOverFlag = TRUE\uff0c\u63a5\u7740\u9000\u51fa\u6b64\u51fd\u6570\u3002<\/p>\n

                                        \u5982\u679c\u7528\u6237\u9009\u62e9\u201c\u5426\u201d\uff0c\u90a3\u4e48\u4f1a\u6267\u884c\u521d\u59cb\u5316\u51fd\u6570tetrisInit()\uff0c\u5e76\u8d4b\u503cplayer.gameOverFlag = FALSE;<\/p>\n

                                        \u91cd\u65b0\u5f00\u59cb\u6e38\u620f\u3002<\/p>\n

                                        CLEARKEY();\u662f\u4e00\u4e2a\u5b8f\u5b9a\u4e49\uff0c\u7528\u4e8e\u6e05\u9664\u6309\u952e\u8f93\u5165\u7f13\u51b2\u533a\u3002<\/p>\n

                                        11.tetrisKeyHandle() \u51fd\u6570<\/h4>\n

                                        \u7528\u6237\u6309\u952e\u5904\u7406\u51fd\u6570\uff0c\u6bcf\u6b21\u7528\u6237\u6309\u4e0b\u76f8\u5e94\u6309\u952e\u540e\uff0c\u90fd\u4f1a\u6267\u884c\u672c\u51fd\u6570\u3002<\/p>\n

                                        \u5176\u4e2d\u7684W\u952e\u6539\u53d8\u65b9\u5757\u5f62\u72b6\uff08\u671d\u5411\uff09\u3001A\u952e\u5de6\u79fb\u3001S\u952e\u4e0b\u79fb\u3001D\u952e\u53f3\u79fb\u3001ESC\u9000\u51fa\u952e\u90fd\u5df2\u7ecf\u5728\u4e0a\u9762\u7684\u51fd\u6570\u8bf4\u660e\u4e86\uff0c\u8fd9\u91cc\u5c31\u4e0d\u518d\u590d\u8ff0\u3002<\/p>\n

                                        void tetrisKeyHandle(void) { switch(player.key) { case 'w': case 'W': \/\/ W\u952e\uff0c\u6539\u53d8\u5f53\u524d\u65b9\u5757\u7684\u671d\u5411 tetrisMoveUp(); break; case 'a': case 'A': \/\/ A\u952e\uff0c\u5f53\u524d\u65b9\u5757\u60f3\u5de6\u79fb\u52a8 tetrisMoveLeft(); break; case 's': case 'S': \/\/ S\u952e\uff0c\u5f53\u524d\u65b9\u5757\u5411\u4e0b\u79fb\u52a8 player.moveFlag = TRUE; player.ttime = GetTickCount(); return; case 'd': case 'D': \/\/ D\u952e\uff0c\u5f53\u524d\u65b9\u5757\u5411\u53f3\u79fb\u52a8 tetrisMoveRight(); break; case ESC: \/\/ \u9000\u51fa\u952e\uff0c\u9000\u51fa\u6e38\u620f tetrisQuit(); break; case 'r': case 'R': \/\/ R\u952e\uff0c\u91cd\u7f6e\u6e38\u620f\u8fdb\u5ea6 tetrisReset(); break; default: break; } \/\/ \u6309\u952e\u4e4b\u540e\uff0c\u5237\u65b0\u5730\u56fe tetrisDraw(); }<\/code><\/pre>\n

                                        1.\u5c31\u5269\u4e00\u4e2aR\u952e\u91cd\u65b0\u5f00\u59cb\u6e38\u620f\u4e86\uff1b<\/p>\n

                                        \u6309\u4e0bR\u952e\u540e\uff0c\u4f1a\u6267\u884ctetrisReset()\u51fd\u6570\uff0c\u8fdb\u884c\u6e38\u620f\u91cd\u7f6e\uff0c\u51fd\u6570\u8be6\u60c5\u4f1a\u5728\u4e0b\u4e00\u4e2a\u51fd\u6570\u8bf4\u660e\u3002<\/p>\n<\/p>\n

                                        12.tetrisReset() \u51fd\u6570<\/h4>\n

                                        \u91cd\u7f6e\u6e38\u620f\u51fd\u6570\uff0c\u73a9\u5bb6\u6309\u4e0bR\u952e\u540e\uff0c\u53ef\u4ee5\u9009\u62e9\u662f\u5426\u91cd\u65b0\u5f00\u59cb\u6e38\u620f\u3002<\/p>\n

                                        void tetrisReset(void) { int key; key = MessageBox(NULL, \"\u662f\u5426\u91cd\u65b0\u5f00\u59cb\u6e38\u620f\uff1f\", \"\u63d0\u793a\", MB_YESNO | MB_SYSTEMMODAL); CLEARKEY(); switch (key) { case IDYES: tetrisInit(); break; case IDNO: break; default: break; } }<\/code><\/pre>\n

                                        \u751f\u6210\u4e00\u4e2a\u7f6e\u9876\u5f39\u7a97\uff0c\u7528\u53d8\u91cfkey\u83b7\u53d6\u7528\u6237\u70b9\u51fb\u7684\u6309\u94ae\uff08\u201c\u662f\u201d\u201c\u5426\u201d\uff09\uff1b<\/p>\n

                                        \u5982\u679c\u7528\u6237\u70b9\u51fb\u7684\u662f\u201c\u662f\u201d\uff0c\u5219\u6267\u884ctetrisInit()\u51fd\u6570\uff0c\u521d\u59cb\u5316\u6240\u6709\u6e38\u620f\u6570\u636e\uff0c\u91cd\u65b0\u5f00\u59cb\u6e38\u620f\u3002<\/p>\n

                                        \u5982\u679c\u7528\u6237\u70b9\u51fb\u7684\u662f\u201c\u5426\u201d\uff0c\u5219\u53d6\u6d88\u91cd\u7f6e\u6e38\u620f\uff0c\u672c\u6b21\u6309\u952e\u65e0\u6548\u3002<\/p>\n

                                        13.tetrisRemove() \u51fd\u6570<\/h4>\n

                                        \u6700\u540e\u4e00\u4e2a\u51fd\u6570\uff0c\u6d88\u9664\u6ee1\u884c\u51fd\u6570\uff0c\u6bcf\u6b21\u751f\u6210\u65b0\u65b9\u5757\u6807\u8bc6player.newBlockFlag\u7f6e1\u65f6\uff0c\u4f1a\u6267\u884c\u672c\u51fd\u6570\u3002<\/p>\n

                                        void tetrisRemove(void) { int i, j, m, n; int flag, bnum; bnum = 0; \/\/ \u4ece\u6700\u4e0b\u9762\u4e00\u884c\u5f00\u59cb\uff0c\u68c0\u6d4b\u5e76\u6d88\u9664\u6ee1\u884c\u65b9\u5757 for (i = TETRISHEIGHT - 1; i >= 0; i--) { flag = 0; for (j = 0; j < TETRISWIDTH; j++) { \/\/ \u53ea\u8981\u68c0\u6d4b\u5230\u7a7a\u683c\uff0c\u5c31\u4e0d\u518d\u68c0\u6d4b\u672c\u884c if (!tetrisMap[i][j]) { flag = 1; break; } } if (flag) { continue; } \/\/ \u6ee1\u884c\uff0c\u6d88\u9664\u884c\u6570\u52a01 bnum++; \/\/ \u68c0\u6d4b\u5230\u6ee1\u884c\uff0c\u6d88\u9664\u5f53\u524d\u884c for (j = 0; j < TETRISWIDTH; j++) { tetrisMap[i][j] = BLOCKNONE; } \/\/ \u6d88\u9664\u884c\u4e0a\u9762\u7684\u6240\u6709\u65b9\u5757\u4e0b\u79fb\u4e00\u884c for (m = i; m > 0; m--) { for (n = 0; n < TETRISWIDTH; n++) { tetrisMap[m][n] = tetrisMap[m - 1][n]; } } i++; \/\/ \u7531\u4e8e\u6d88\u9664\u884c\u4e0a\u9762\u7684\u65b9\u5757\u4e0b\u79fb\u4e86\uff0c\u6240\u4ee5\u518d\u4ece\u5f53\u524d\u884c\u68c0\u6d4b } \/\/ \u6d88\u9664\u884c\u6570\u4e3a0\uff0c\u9000\u51fa if (!bnum) { return; } \/\/ \u6839\u636e\u6d88\u9664\u7684\u884c\u6570\uff0c\u589e\u52a0RANK\u5206\u6570 switch (bnum) { case 0: break; case 1: player.rank += 10; break; case 2: player.rank += 20; break; case 3: player.rank += 40; break; case 4: player.rank += 80; break; default: break; } \/\/ \u6839\u636erank\u5206\u6570\u6362\u7b97\u6210level player.level = player.rank \/ 100; if (player.level > 10) { player.level = 10; } }<\/code><\/pre>\n<\/p>\n
                                        \n

                                        \/\/ \u4ece\u6700\u4e0b\u9762\u4e00\u884c\u5f00\u59cb\uff0c\u68c0\u6d4b\u5e76\u6d88\u9664\u6ee1\u884c\u65b9\u5757
                                            for (i = TETRISHEIGHT - 1; i >= 0; i--)
                                            {
                                        \n
                                                flag = 0;
                                                for (j = 0; j < TETRISWIDTH; j++)
                                                {
                                        \n
                                                    \/\/ \u53ea\u8981\u68c0\u6d4b\u5230\u7a7a\u683c\uff0c\u5c31\u4e0d\u518d\u68c0\u6d4b\u672c\u884c
                                                    if (!tetrisMap[i][j])
                                                    {
                                        \n
                                                        flag = 1;
                                                        break;
                                                    }
                                                }
                                                if (flag)
                                                {
                                        \n
                                                    continue;
                                                }
                                                \/\/ \u6ee1\u884c\uff0c\u6d88\u9664\u884c\u6570\u52a01
                                                bnum++;
                                                \/\/ \u68c0\u6d4b\u5230\u6ee1\u884c\uff0c\u6d88\u9664\u5f53\u524d\u884c
                                                for (j = 0; j < TETRISWIDTH; j++)
                                                {
                                        \n
                                                    tetrisMap[i][j] = BLOCKNONE;
                                                }
                                                \/\/ \u6d88\u9664\u884c\u4e0a\u9762\u7684\u6240\u6709\u65b9\u5757\u4e0b\u79fb\u4e00\u884c
                                                for (m = i; m > 0; m--)
                                                {
                                        \n
                                                    for (n = 0; n < TETRISWIDTH; n++)
                                                    {
                                        \n
                                                        tetrisMap[m][n] = tetrisMap[m - 1][n];
                                                    }
                                                }
                                                i++;        \/\/ \u7531\u4e8e\u6d88\u9664\u884c\u4e0a\u9762\u7684\u65b9\u5757\u4e0b\u79fb\u4e86\uff0c\u6240\u4ee5\u518d\u4ece\u5f53\u524d\u884c\u68c0\u6d4b
                                            }<\/p>\n<\/blockquote>\n

                                        1.\u4ece\u6e38\u620f\u5730\u56fe\u6700\u4e0b\u9762\u4e00\u884c\u5f00\u59cb\u68c0\u6d4b\uff0c\u4f9d\u6b21\u68c0\u6d4b\u5230\u6700\u4e0a\u9762\u4e00\u884c\uff1b\u53ea\u8981\u68c0\u6d4b\u5230\u4e00\u4e2a\u7a7a\u767d\u683c\uff0c\u5219\u653e\u5f03\u68c0\u6d4b\u672c\u884c\uff0c\u68c0\u6d4b\u4e0a\u4e00\u884c\u3002<\/p>\n

                                        \u5982\u679c\u5f53\u524d\u884c\u662f\u6ee1\u884c\uff0c\u5219\u6d88\u9664\u884c\u6570bnum\u52a0\u4e00\uff1b\u7136\u540e\u628a\u5f53\u524d\u884c\u6e05\u96f6\uff1b\u6e05\u96f6\u540e\uff0c\u628a\u5f53\u524d\u884c\u4e0a\u9762\u7684\u6240\u6709\u65b9\u5757\u5168\u90e8\u4e0b\u79fb\u4e00\u884c\uff1bi++\u662f\u56e0\u4e3a\u6240\u6709\u65b9\u5757\u90fd\u4e0b\u79fb\u4e00\u884c\u4e86\uff0c\u9700\u8981\u518d\u6b21\u4ece\u5f53\u524d\u884c\u5f00\u59cb\u68c0\u6d4b\u3002<\/p>\n<\/p>\n

                                        \n

                                        \/\/ \u6d88\u9664\u884c\u6570\u4e3a0\uff0c\u9000\u51fa
                                            if (!bnum)
                                            {
                                        \n
                                                return;
                                            }
                                            \/\/ \u6839\u636e\u6d88\u9664\u7684\u884c\u6570\uff0c\u589e\u52a0RANK\u5206\u6570
                                            switch (bnum)
                                            {
                                        \n
                                            case 0:
                                                break;
                                            case 1:
                                                player.rank += 10;
                                                break;
                                            case 2:
                                                player.rank += 20;
                                                break;
                                            case 3:
                                                player.rank += 40;
                                                break;
                                            case 4:
                                                player.rank += 80;
                                                break;
                                            default:
                                                break;
                                            }
                                            \/\/ \u6839\u636erank\u5206\u6570\u6362\u7b97\u6210level
                                            player.level = player.rank \/ 100;
                                            if (player.level > 10)
                                            {
                                        \n
                                                player.level = 10;
                                            }<\/p>\n<\/blockquote>\n

                                        2.\u5982\u679c\u6ca1\u6709\u68c0\u6d4b\u5230\u53ef\u6d88\u9664\u884c\uff08bnum\u4e3a0\uff09\uff0c\u5219\u9000\u51fa\u672c\u51fd\u6570\u3002<\/p>\n

                                        \u6839\u636e\u6d88\u9664\u884c\u6570bnum\uff0c\u589e\u52a0player.rank\u5206\u6570\uff1a<\/p>\n

                                        1\u884c\u52a010\u5206\uff1b2\u884c\u52a020\u5206\uff1b3\u884c\u52a040\u5206\uff1b4\u884c\u52a080\u3002<\/p>\n

                                        \u6839\u636eplayer.rank\u5206\u6570\uff0c\u6362\u7b97\u6210player.level\u7b49\u7ea7\uff1a<\/p>\n

                                        1000\u5206\u4ee5\u4e0b\uff0c\u7b49\u7ea7\u662f\u5206\u6570\/100\uff1b1000\u5206\u4ee5\u4e0a\uff0c\u7b49\u7ea7\u56fa\u5b9a\u4e3a10\uff08MAX\uff09\u3002<\/p>\n


                                        \n

                                        \u603b\u7ed3<\/h2>\n

                                        \u81f3\u6b64\uff0c\u4ee3\u7801\u90e8\u5206\u5df2\u7ecf\u7ed3\u675f\uff0c\u4ece\u7f16\u5199\u4fc4\u7f57\u65af\u65b9\u5757\u5230\u7ed3\u675f\uff0c\u4ee3\u7801\u6709\u7ecf\u5386\u8fc7\u5404\u79cd\u4f18\u5316\uff0cbug\u4e5f\u57fa\u672c\u90fd\u4fee\u6b63\u4e86\uff0c\u53ef\u4ee5\u8bf4\u662f\u4e00\u4e2a\u6bd4\u8f83\u5b8c\u5584\u7684\u7248\u672c\uff08\u57fa\u672c\u6ca1\u6709BUG\uff09\u3002\u6709\u4efb\u4f55\u7591\u95ee\u90fd\u53ef\u4ee5\u5728\u8bc4\u8bba\u91cc\u63d0\u95ee\uff0c\u8c22\u8c22\u89c2\u770b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"c#\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f_c++\u5c0f\u6e38\u620f\u7f16\u7a0b\u4ee3\u7801\u4f7f\u7528easyX\u5e93\uff0c\u57fa\u4e8ec\/c++\uff0c\u5b9e\u73b0\u4fc4\u7f57\u65af\u65b9\u5757\u5c0f\u6e38\u620f","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7751"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=7751"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7751\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=7751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=7751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=7751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}