`````````学院:数计学院班级:13级数媒班学号:姓名:摘要……………………………………………………………………………………………………..关键字:目录第一部分设计总概........................................................................................................................... 摘要…………………………………………………………………………………………………一、设计目的.............................................................................................................................二、设计要求.............................................................................................................................三、设计内容.............................................................................................................................四、系统分析与设计................................................................................................................. 第二部分数据结构设计................................................................................................................... 第三部分功能实现与程序调试………………………………………………………………….第四部分完成设计...........................................................................................................................一、实习日记.............................................................................................................................二、实习总结.............................................................................................................................三、教师评语.............................................................................................................................四、程序使用说明书………………………………………………………………………….第一部分设计总概一、设计目的二、设计要求三、设计内容四、系统分析与设计第二部分数据结构设计第三部分功能实现与程序调试第四部分完成设计一、实习日记:二、实习总结:………………………三、教师评语:设计成绩:指导老师签名:摘要使用C语言编写一个俄罗斯方块游戏系统,要求程序运行后有一个图形用户界面,实现各种方块的生产,包括形状和颜色等信息,完成左右下旋转的功能,在消行的同时分数加10,在点击暂停或者按下空格的时候暂停或开始游戏,最后结束游戏.关键字:音乐、背景、按键控制、暂停、继续、停止,难度级别第一部分设计总概一、设计目的:本课程设计是一个综合性的实践教学环节,目的在于促进学生复习和巩固计算机软件设计知识,加深对软件设计方法、软件设计技术和设计思想的理解,并能运用所学知识进行开发。
希望通过本课程设计中简单系统的开发,使学生掌握软件设计的基本方法和基本流程,提高自己的综合应用能力。
二、设计要求利用C++编写俄罗斯方块游戏,使俄罗斯游戏能够在Microsoft Visual C++6.0上运行该游戏。
二、设计内容:俄罗斯方块(1)游戏等级:游戏分为难中易三个等级,等级越高,方块下落速度越快;(2)由方向键控制游戏:上键控制方块变形、下键控制方块下移并判断是否有消行、左键控制方块左移、右键控制方块右移;(3)游戏积分:一次性消的行数越多加的分数越多,当达到一定分数自动提高一个游戏等级。
三、系统分析与设计1.程序功能模块:2.程序流程图:第二部分数据结构设计1.游戏需求随机给出不同的形状(长条形、Z字形、反Z形、田字形、7字形、反7形、T字型)下落填充给定的区域,若填满一条便消掉,记分,当达到一定的分数时,过关,每关方块下落的速度不同,若在游戏中各形状填满了给定区域,为输者。
2.游戏界面需求:良好的用户界面,以键盘操作,有关数显示和分数显示。
让方块在一定的区域内运动和变形,并且显示下一个即将出现的方块。
3.游戏形状(方块)需求:良好的方块形状设计,绘制七种常见的基本图形(长条形、Z字形、反Z形、田字形、7字形、反7形、T字型),各个方块要能实现它的变形,可设为顺时针或逆时针变形,一般为逆时针。
第三部分功能实现与程序调试程序:// testBlock.cpp : Defines the entry point for theapplication.//#define CreateWindow CreateWindowA#include "stdafx.h"#include "resource.h"#include<mmsystem.h>//PlaySound函数的头文件#pragma comment(lib, "WINMM.LIB")#include "commctrl.h"#pragma comment(lib, "comctl32.lib")#include <windows.h>#include <commctrl.h>HMENU hMenu; //菜单句柄#define IDM_NEW 40001#define IDM_PAUSE 40002//#define IDM_STOP 40003#define IDM_HELP 40008#define IDM_MUSIC 40010#define IDM_LEFT 1001#define IDM_RIGHT 1002#define IDM_UP 1003#define IDM_DOWN 1004#define IDC_RADIO1 1005#define IDC_RADIO2 1006#define COLOR_BTNFACE 15#define MAX_LOADSTRING 100#define TIMER_DROP_ID 1int c = 0,contin=1;int cnext=0;int ch1=0;int ch2=0;int ch3=1;int music=0;BOOL bMusicOn; //音乐开关int iMusicBG; //背景音乐canRotate( int rank);BOOL CALLBACK MusicDlgProc(HWND,UINT,WPARAM,LPARAM); void TetrisMusic(BOOL);void MusicItem(int);static TBBUTTON tbButtons[] ={{0,IDC_JIXU,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,-1} ,{1,IDC_PAUSE,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,-1 },{2,IDM_STOP,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,-1},{0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0,-1},{3,IDM_MUSIC,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,-1 },{4,IDM_HELP1,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,-1 },{0,0,TBSTATE_ENABLED,TBSTYLE_SEP,0,0,-1},{5,IDM_ABOUT,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0,-1 },}; //工具栏数据结构struct Block{ POINT a; POINT b; POINT c; POINT d; }; //方块模型数据结构static Block Tetris[7][4] ={//□□//□□(1){{{0,0},{0,1},{1,0},{1,1}},{{0,0},{0,1},{1,0},{1,1}},{{0,0},{0,1},{1,0},{1,1}},{{0,0},{0,1},{1,0},{1,1}}},//□□// □□(2){{{0,0},{1,0},{1,1},{2,1}},{{1,0},{1,1},{0,1},{0,2}},{{0,0},{1,0},{1,1},{2,1}},{{1,0},{1,1},{0,1},{0,2}}},// □□//□□ (2){{{1,0},{2,0},{0,1},{1,1}},{{0,0},{0,1},{1,1},{1,2}}, {{1,0},{2,0},{0,1},{1,1}}, {{0,0},{0,1},{1,1},{1,2}} },//□□□□(2){{{0,0},{1,0},{2,0},{3,0}}, {{1,0},{1,1},{1,2},{1,3}}, {{0,0},{1,0},{2,0},{3,0}}, {{1,0},{1,1},{1,2},{1,3}} },// □//□□□(4){{{1,0},{0,1},{1,1},{2,1}}, {{0,0},{0,1},{1,1},{0,2}}, {{0,0},{1,0},{2,0},{1,1}}, {{1,0},{0,1},{1,1},{1,2}} },//□//□□□(4){{{0,0},{0,1},{1,1},{2,1}}, {{0,0},{1,0},{0,1},{0,2}}, {{0,0},{1,0},{2,0},{2,1}}, {{1,0},{1,1},{0,2},{1,2}} },// □//□□□(4){{{2,0},{0,1},{1,1},{2,1}}, {{0,0},{0,1},{0,2},{1,2}}, {{0,0},{1,0},{2,0},{0,1}}, {{0,0},{1,0},{1,1},{1,2}}}}; //七种方块全部变形数据结构int x = 4 ;//以方块为单位int y = -1;int nBlockAreaX=10;//背景窗口int nBlockAreaY=30;int BlockMatrix[19][10];int nBlockKind = 0;int nBlockColor = 0;int nBlockState = 0;int nBlockAreaXnext=220;//显示窗口int nBlockAreaYnext=37;int BlockMatrixnext[8][6];int nBlockKindnext = 0;int nBlockColornext = 0;int nBlockStatenext = 0;int gamescore=0;BOOL BGame=FALSE;BOOL bGOver=FALSE;HWND hWnd;HDC hdc;HDC hMemDC = NULL;HDC hWndDC = NULL;// Global Variables:HINSTANCE hInst; // current instanceTCHAR szTitle[MAX_LOADSTRING];// The title bar textTCHAR szWindowClass[MAX_LOADSTRING];// The title bar textHBITMAP bmp[999] = {0};// Foward declarations of functions included in this code module:ATOM MyRegisterClass(HINSTANCE hInstance);BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);void DrawTetris( HDC hdc, int offsetX/*0*/, int offsetY/*0*/, int rank/*no use*/ );void Tools(HWND hWnd);LoadImage();void GameStart();void DrawNext(HDC hdc);void GameOver();void DrawButton(LPARAM lParam);LPARAM lParam;int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){// TODO: Place code here.MSG msg;HACCEL hAccelTable;// Initialize global stringsLoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);LoadString(hInstance, IDC_TESTBLOCK, szWindowClass, MAX_LOADSTRING);MyRegisterClass(hInstance);FILE *fp=NULL;////////////char ch[50];fp=fopen("test.txt","r");fgets(ch,523,fp);ch1=atoi(ch);fclose(fp);////////// Perform application initialization:if (!InitInstance (hInstance, nCmdShow)){return FALSE;}hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTBLOCK);char fileName[100] = {0};//res\\1.bmpfor (int i = 0; i < 9; i++ ){sprintf(fileName, "res\\%d.bmp", i+1);bmp[i] = (HBITMAP)LoadImage(NULL, fileName,0,0,0,LR_LOADFROMFILE);//LOADIMAGEFROMFILE}for( i=0;i<=18;i++){for(int j=0;j<=9;j++){BlockMatrix[i][j]=-1;}}for(int m=0;m<=5;m++){for(int n=0;n<=5;n++){BlockMatrixnext[m][n]=-1;}}//beijingint a=1000;SetTimer(hWnd,TIMER_DROP_ID,a,NULL);hWndDC = GetDC(hWnd);hMemDC = CreateCompatibleDC(NULL);// Main message loop:Tools(hWnd);while (GetMessage(&msg, NULL, 0, 0)){if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)){TranslateMessage(&msg);DispatchMessage(&msg);}}return msg.wParam;}ATOM MyRegisterClass(HINSTANCE hInstance){WNDCLASSEX wcex;wcex.cbSize = sizeof(WNDCLASSEX);wcex.style = CS_HREDRAW | CS_VREDRAW;wcex.lpfnWndProc = (WNDPROC)WndProc;wcex.cbClsExtra = 0;wcex.cbWndExtra = 0;wcex.hInstance = hInstance;wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_ICON1);wcex.hCursor = LoadCursor(NULL, IDC_ARROW);wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+2);wcex.lpszMenuName =MAKEINTRESOURCE(IDC_TESTBLOCK);wcex.lpszClassName = szWindowClass;wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_ICON1));return RegisterClassEx(&wcex);}BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) {hInst = hInstance; // Store instance handle in our global variablehWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, 200, 350, 485, NULL, NULL, hInstance, NULL);//窗口大小设置if (!hWnd){return FALSE;}ShowWindow(hWnd, nCmdShow);UpdateWindow(hWnd);return TRUE;}LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){int wmId, wmEvent;PAINTSTRUCT ps;HDC hdc;TCHAR szHello[MAX_LOADSTRING];LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);switch (message){case WM_COMMAND:wmId = LOWORD(wParam);wmEvent = HIWORD(wParam);// Parse the menu selections:switch (wmId){case IDM_UP:SendMessage(hWnd,WM_KEYDOWN,VK_UP,0);SetFocus(hWnd);break;case IDM_DOWN:SendMessage(hWnd,WM_KEYDOWN,VK_DOWN,0);SetFocus(hWnd);break;case IDM_RIGHT:SendMessage(hWnd,WM_KEYDOWN,VK_RIGHT,0);SetFocus(hWnd);break;case IDM_LEFT:SendMessage(hWnd,WM_KEYDOWN,VK_LEFT,0);SetFocus(hWnd);break;case IDM_START:{InvalidateRect(hWnd,0,1);GameStart();}break;break;//开始按键case IDC_PAUSE://暂停{BGame=FALSE;MessageBox(NULL, "你好,游戏暂停", "暂停", MB_OK);}break;case IDC_JIXU://继续{if(contin!=0)BGame=TRUE;}break;case IDM_STOP://停止BGame=FALSE;GameOver();break;case IDC_easy:InvalidateRect(hWnd,0,0);ch3=1;MessageBox(NULL, "你好,你选择的难易程度为简单", "简单", MB_OK);SetTimer(hWnd,TIMER_DROP_ID,1000,NULL);break;case IDC_normal:InvalidateRect(hWnd,0,0);ch3=2;MessageBox(NULL, "你好,你选择的难易程度为一般", "一般", MB_OK);SetTimer(hWnd,TIMER_DROP_ID,500,NULL);break;case IDC_difficult:MessageBox(NULL, "你好,你选择的难易程度为困难", "困难", MB_OK);ch3=3;InvalidateRect(hWnd,0,0);SetTimer(hWnd,TIMER_DROP_ID,100,NULL);break;case IDM_beijing:{SelectObject(hMemDC,bmp[8]);BitBlt(hWndDC,0,20,2000,2000,hMemDC,0,0,SRCCOPY);InvalidateRect(hWnd,0,0);//重绘//InvalidateRect(hwnd, NULL, false);重画时不擦除背景}break;case IDM_ABOUT:DialogBox(hInst, MAKEINTRESOURCE(IDD_HELP1), hWnd, (DLGPROC)About);break;case IDM_HELP1:DialogBox(hInst, MAKEINTRESOURCE(IDD_help2), hWnd, (DLGPROC)About);break;case IDM_MUSIC:DialogBox(hInst,MAKEINTRESOURCE(IDD_MUSIC),hWnd,Mu sicDlgProc);break;case IDM_music1:MusicItem(IDM_music1);break;case IDM_music2:MusicItem(IDM_music2);break;case IDM_musicstop:MusicItem(IDM_musicstop);break;case IDM_EXIT:DestroyWindow(hWnd);break;default:return DefWindowProc(hWnd, message,wParam, lParam);}break;{case WM_PAINT:hdc = BeginPaint(hWnd, &ps);RECT rt;GetClientRect(hWnd, &rt);for(int i=0;i<=18;i++){for(int j=0;j<=9;j++){if(BlockMatrix[i][j]==-1){PatBlt(hdc,nBlockAreaX+j*20,nBlockAreaY+i*20,20,20 ,BLACKNESS);}else{SelectObject(hMemDC,bmp[BlockMatrix[i][j]]);BitBlt(hdc,nBlockAreaX+j*20,nBlockAreaY+i*20,20,20 ,hMemDC,0,0,SRCCOPY);}}}//InvalidateRect(hWnd,0,0);for(int m=0;m<=5;m++){for(int n=0;n<=5;n++){if(BlockMatrixnext[m][n]==-1){PatBlt(hdc,nBlockAreaXnext+n*20,nBlockAreaYnext+m* 20,20,20,BLACKNESS);}else{SelectObject(hMemDC,bmp[BlockMatrixnext[m][n]]);BitBlt(hdc,nBlockAreaXnext+n*20,nBlockAreaYnext+m* 20,20,20,hMemDC,0,0,SRCCOPY);}}}DrawTetris(hWndDC, 0, 0, 0);DrawNext( hdc);RECT rtTxt;TCHAR scoreTxt[100];sprintf(scoreTxt, " 得分: %d", gamescore);rtTxt.top = 200;rtTxt.left = 220;rtTxt.right = rtTxt.left+200;rtTxt.bottom = rtTxt.top+50;DrawText(hdc, scoreTxt, strlen(scoreTxt), &rtTxt, DT_LEFT);RECT rtTxt1;TCHARmaxscore[100];///////////////////////////////////// ////sprintf(maxscore, " 最高分: %d", ch1);rtTxt1.top=240;rtTxt1.left=220;rtTxt1.right=rtTxt1.left+300;rtTxt1.bottom=rtTxt1.top+100;DrawText(hdc, maxscore, strlen(maxscore), &rtTxt1, DT_LEFT);RECT rtTxt2;TCHAR eaayORdifficult[100];sprintf(eaayORdifficult, "难易级别: %d", ch3);rtTxt2.top = 280;rtTxt2.left = 220;rtTxt2.right = rtTxt2.left+200;rtTxt2.bottom = rtTxt2.top+50;DrawText(hdc, eaayORdifficult, strlen(eaayORdifficult), &rtTxt2, DT_LEFT);EndPaint(hWnd, &ps);}break;//计算分数case WM_DRAWITEM:DrawButton(lParam); //绘制方向按钮return TRUE;case WM_LBUTTONDOWN:{}break;case WM_TIMER:{DrawTetris(hWndDC, 0, 1, 0);}break;case WM_KEYDOWN:{int virtual_code=(int)wParam;int key_state=(int)lParam;switch(virtual_code){case VK_RIGHT:{DrawTetris(hWndDC, 1, 0, 0);}break;case VK_LEFT:{DrawTetris(hWndDC, -1, 0, 0);}break;case VK_UP:if(canRotate(1)){DrawTetris( hWndDC,0,0,1);}break;case VK_DOWN:{DrawTetris(hWndDC, 0, 1, 0);}break;default: break;}}break;case WM_DESTROY:PostQuitMessage(0);break;default:return DefWindowProc(hWnd, message, wParam, lParam);}return 0;}// Mesage handler for about box.LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){switch (message){case WM_INITDIALOG:return TRUE;case WM_COMMAND:if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL){EndDialog(hDlg, LOWORD(wParam));return TRUE;}break;}return FALSE;}BOOL CALLBACK MusicDlgProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam){switch ( message ){case WM_INITDIALOG:if( iMusicBG == IDR_WAVE1 ) CheckRadioButton(hDlg,IDC_RADIO1,IDC_RADIO3,IDC_RAD IO1);if( iMusicBG == IDR_WAVE2 ) CheckRadioButton(hDlg,IDC_RADIO1,IDC_RADIO3,IDC_RAD IO2);if( !bMusicOn ) CheckRadioButton(hDlg,IDC_RADIO1,IDC_RADIO3,IDC_RAD IO3);return TRUE;case WM_COMMAND :switch ( LOWORD(wParam) ){case IDC_RADIO1:CheckRadioButton(hDlg,IDC_RADIO1,IDC_RADIO3,IDC_RA DIO1);break;case IDC_RADIO2:CheckRadioButton(hDlg,IDC_RADIO1,IDC_RADIO3,IDC_RA DIO2);break;case IDC_RADIO3:CheckRadioButton(hDlg,IDC_RADIO1,IDC_RADIO3,IDC_RA DIO3);break;case IDOK:if ( IsDlgButtonChecked(hDlg,IDC_RADIO1) == BST_CHECKED ){bMusicOn = TRUE;iMusicBG = IDR_WAVE1;MusicItem(IDM_music1);if ( BGame ) TetrisMusic(TRUE);}if ( IsDlgButtonChecked(hDlg,IDC_RADIO2) == BST_CHECKED ){bMusicOn = TRUE;iMusicBG = IDR_WAVE2;MusicItem(IDM_music2);if ( BGame ) TetrisMusic(TRUE);}if ( IsDlgButtonChecked(hDlg,IDC_RADIO3) == BST_CHECKED ){bMusicOn = FALSE;MusicItem(IDM_musicstop);TetrisMusic(FALSE);}EndDialog(hDlg,0);break;case IDCANCEL:EndDialog(hDlg,0);break;}break;}return FALSE;}//音乐菜单处理void MusicItem(int iCheckID){CheckMenuRadioItem(hMenu,IDM_music1,IDM_musicstop, iCheckID,MF_BYCOMMAND);if ( iCheckID == IDM_music1 ){bMusicOn = TRUE;iMusicBG = IDR_WAVE1;if ( BGame ) TetrisMusic(TRUE);}else if ( iCheckID == IDM_music2 ){bMusicOn = TRUE;iMusicBG = IDR_WAVE2;if ( BGame ) TetrisMusic(TRUE);}else{bMusicOn = FALSE;TetrisMusic(FALSE);}return;}//背景音乐void TetrisMusic(BOOL start){if ( start && bMusicOn && !bGOver )PlaySound(MAKEINTRESOURCE(iMusicBG),NULL,SND_RESOU RCE|SND_LOOP|SND_ASYNC);elsePlaySound(NULL,NULL,NULL);return;}BOOL clear( ){int count=0;for(int i=18;i>=0;i--){for(int j=0;j<10;j++){if(BlockMatrix[i][j]==-1)break;}if(j==10){count++;for(int k=i-1;k>=0;k--){for(int m=0;m<10;m++){BlockMatrix[k+1][m]=BlockMatrix[k][m];}}i++;if(gamescore>=ch1)ch1=gamescore;if(gamescore>450){ch3=3;SetTimer(hWnd,TIMER_DROP_ID,100,NULL);}else if(gamescore<=450&&gamescore>300){ch2=2;if(ch2>=ch3){ch3=ch2;SetTimer(hWnd,TIMER_DROP_ID,500,NULL);}}}}if(count==1){gamescore+=10;}if(count==2){gamescore+=30;}if(count==3){gamescore+=50;}if(count==4){gamescore+=80;}InvalidateRect(hWnd,0,0);return true;}void GameStart(){BGame=TRUE;gamescore=0;FILE *fp=NULL;char ch[50];fp=fopen("test.txt","r");fgets(ch,523,fp);ch1=atoi(ch);fclose(fp);contin=1;for(int i=0;i<=18;i++){for(int j=0;j<=9;j++){BlockMatrix[i][j]=-1;}}srand(GetTickCount()); nBlockKind=nBlockKindnext;nBlockState=nBlockStatenext;c=rand()%7;nBlockKindnext=rand()%7;nBlockStatenext=rand()%4;cnext=rand()%7;x = 4;y = -1;}BOOL DownCheckCollideBlock(int offsetX, int offsetY, int rank){if(y==-1){return FALSE;}if((BlockMatrix[offsetY+y+Tetris[nBlockKind][nBloc kState].a.y][x+Tetris[nBlockKind][nBlockState].a.x] !=-1)||(BlockMatrix[offsetY+y+Tetris[nBlockKind][nBlock State].b.y][x+Tetris[nBlockKind][nBlockState].b.x]! =-1)||(BlockMatrix[offsetY+y+Tetris[nBlockKind][nBlock State].c.y][x+Tetris[nBlockKind][nBlockState].c.x]! =-1)||(BlockMatrix[offsetY+y+Tetris[nBlockKind][nBlock State].d.y][x+Tetris[nBlockKind][nBlockState].d.x]! =-1)){return TRUE;}return FALSE;}BOOL LeftOrRightCheckCollideBlock(int offsetX, int offsetY, int rank){if(y==-1){return FALSE;}if((BlockMatrix[y+Tetris[nBlockKind][nBlockState].a.y][offsetX+x+Tetris[nBlockKind][nBlockState].a.x] !=-1)||(BlockMatrix[y+Tetris[nBlockKind][nBlockState].b .y][offsetX+x+Tetris[nBlockKind][nBlockState].b.x]! =-1)||(BlockMatrix[y+Tetris[nBlockKind][nBlockState].c .y][offsetX+x+Tetris[nBlockKind][nBlockState].c.x]! =-1)||(BlockMatrix[y+Tetris[nBlockKind][nBlockState].d .y][offsetX+x+Tetris[nBlockKind][nBlockState].d.x]! =-1)){return TRUE;}return FALSE;}BOOL canRotate( int rank)//旋转{if(rank==0){return FALSE;}int tempState = (nBlockState+1)%4;if((BlockMatrix[y+Tetris[nBlockKind][tempState].a. y][x+Tetris[nBlockKind][tempState].a.x]!=-1) ||(BlockMatrix[y+Tetris[nBlockKind][tempState].b.y][x +Tetris[nBlockKind][tempState].b.x]!=-1)||(BlockMatrix[y+Tetris[nBlockKind][tempState].c.y][x +Tetris[nBlockKind][tempState].c.x]!=-1)||(BlockMatrix[y+Tetris[nBlockKind][tempState].d.y][x +Tetris[nBlockKind][tempState].d.x]!=-1)||(y+Tetris[nBlockKind][tempState].a.y>18 )|| (y+Tetris[nBlockKind][tempState].b.y>18 )||(y+Tetris[nBlockKind][tempState].c.y>18 )||(y+Tetris[nBlockKind][tempState].d.y>18 )||(x+Tetris[nBlockKind][tempState].a.x<0 || x+Tetris[nBlockKind][tempState].a.x>9)||(x+Tetris[nBlockKind][tempState].b.x<0 || x+Tetris[nBlockKind][tempState].b.x>9)||(x+Tetris[nBlockKind][tempState].c.x<0 || x+Tetris[nBlockKind][tempState].c.x>9)||(x+Tetris[nBlockKind][tempState].d.x<0 || x+Tetris[nBlockKind][tempState].d.x>9)){return FALSE;}return TRUE;}void DrawTetris( HDC hdc, int offsetX, int offsetY, int rank ){if(!BGame){return;}int iX=0;int iY=0;if((y+Tetris[nBlockKind][nBlockState].a.y+offsetY>18 )||(y+Tetris[nBlockKind][nBlockState].b.y+offsetY>18 )||(y+Tetris[nBlockKind][nBlockState].c.y+offsetY>1 8 )||(y+Tetris[nBlockKind][nBlockState].d.y+offsetY>1 8 )||DownCheckCollideBlock(offsetX,offsetY,rank)){BlockMatrix[y+Tetris[nBlockKind][nBlockState].a.y] [x+Tetris[nBlockKind][nBlockState].a.x] = c;//c是步骤1定义的变量,表示绘制背景时使用的图片下标。