⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 els1.c

📁 minigui编写的俄罗斯方块! 希望大家喜欢!
💻 C
📖 第 1 页 / 共 2 页
字号:
		Square.Flag[2][0]=1;		Square.Flag[2][1]=1;		Square.Flag[3][1]=1;	}	else if( Num ==13 || Num==32 || Num==51 || Num==70)	{		Square.Flag[2][1]=1;		Square.Flag[2][2]=1;		Square.Flag[3][0]=1;		Square.Flag[3][1]=1;	}	else if( Num ==14 || Num==33 || Num==52 || Num==71)	{		Square.Flag[2][0]=1;		Square.Flag[2][1]=1;		Square.Flag[3][1]=1;		Square.Flag[3][2]=1;	}	else if( Num ==15 || Num==34 || Num==53 || Num==72)	{		Square.Flag[1][1]=1;		Square.Flag[2][0]=1;		Square.Flag[2][1]=1;		Square.Flag[3][0]=1;	}	else if( Num ==16 || Num==35 || Num==54 || Num==73)	{		Square.Flag[0][0]=1;		Square.Flag[1][0]=1;		Square.Flag[2][0]=1;		Square.Flag[3][0]=1;	}	else if( Num ==17 || Num==36 || Num==55 || Num==74)	{		Square.Flag[3][0]=1;		Square.Flag[3][1]=1;		Square.Flag[3][2]=1;		Square.Flag[3][3]=1;	}	else if( Num ==18 || Num==37 || Num==56 || Num==75)	{		Square.Flag[2][0]=1;		Square.Flag[2][1]=1;		Square.Flag[3][0]=1;		Square.Flag[3][1]=1;	}}static void GetBottom(){	int i=0;	int j=0;	int Flag[4][4];	int Out=0;	for( i=0; i<4; i++)	{		for( j=0; j<4; j++)		{			Flag[i][j]=0;		}	}	 for( j=0; j<4; j++)	 {		for( i=0; i<4; i++)		{			Flag[i][j]=Base.Flag[Line+i+1][Row+j];			Flag[i][j] += Square.Flag[i][j];		}	 }	for( j=0; j<4; j++)	{		for( i=0; i<4; i++)		{			if( Flag[i][j] >1 )			{				Out=1;			}		}	 }	if( Out == 1)	{		FinshOne();	}}static void MoveLeft(){	int i=0;	int j=0;	int Flag[4][4];	int Out=0;	for( i=0; i<4; i++)	{		for( j=0; j<4; j++)		{			Flag[i][j]=0;		}	}	 if( Square.PostX > 8 )	 {	 	for( j=0; j<4; j++)	 	{			for( i=0; i<4; i++)			{				Flag[i][j]=Base.Flag[Line+i][Row+j-1];				Flag[i][j] += Square.Flag[i][j];			}	 	}		for( j=0; j<4; j++)		{			for( i=0; i<4; i++)			{				if( Flag[i][j] >1 )				{				Out=1;				}			}	 	}		if( Out == 0)		{			Square.PostX-=MOVE;			Row--;		}	 }}static void MoveRight(){	int i=0;	int j=0;	int Flag[4][4];	int Out=0;	for( i=0; i<4; i++)	{		for( j=0; j<4; j++)		{			Flag[i][j]=0;		}	}	 for( j=0; j<4; j++)	 {		for( i=0; i<4; i++)		{			Flag[i][j]=Base.Flag[Line+i][Row+j+1];			Flag[i][j] += Square.Flag[i][j];		}	 }	for( j=0; j<4; j++)	{		for( i=0; i<4; i++)		{			if( Flag[i][j] >1 )			{				Out=1;			}		}	 }	if( Out == 0)	{		Square.PostX+=MOVE;		Row++;	}}static void ChangeSquare(){	int i=0;	int j=0;	int Flag[4][4];	int Out=0;	int ReNum=Num;	if((Num%19)<4)	{ 		(Num%19)==3?(Num-=3):(Num++);	}	else if((Num%19)<8)	{		(Num%19)==7?(Num-=3):(Num++);	}	else if((Num%19)<12)	{ 		(Num%19)==11?(Num-=3):(Num++);	}	else if((Num%19)<14)	{ 		(Num%19)==13?(Num-=1):(Num++);	}	else if((Num%19)<16)	{ 		(Num%19)==15?(Num-=1):(Num++);	}					else if((Num%19)<18)	{		(Num%19)==17?(Num-=1):(Num++);	}	JudgeSquare();	for( i=0; i<4; i++)	{		for( j=0; j<4; j++)		{			Flag[i][j]=0;		}	}	 for( j=0; j<4; j++)	 {		for( i=0; i<4; i++)		{			Flag[i][j]=Base.Flag[Line+i][Row+j];			Flag[i][j] += Square.Flag[i][j];		}	 }	for( j=0; j<4; j++)	{		for( i=0; i<4; i++)		{			if( Flag[i][j] >1 )			{				Out=1;			}		}	 }	if( Out == 1)	{		Num=ReNum;	}}static void FinshOne(){	int i=0;	int j=0;	int state=0;	JudgeSquare();	GetBase();	Line=0;	Row=3;	Num = NextNum;	NextNum = rand()%76;	Square.PostX=83;	Square.PostY=0;	for( i=0; i<10; i++)	{		if( Base.Flag[3][i]>0 )		{			Start=0;		}	}	if( Count>0 )	{		SetLevel();	}}static int ElsWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){   	HDC hdc;	int prex,prey;	int i=0;	int j=0;	int number=0;	switch (message) {			 case MSG_CREATE:  		{			SetTimer(hWnd, 100 , Level);   		 	break; 		 }		 case MSG_INITDIALOG:		 {			break;		 }  		case MSG_PAINT:    		{     			hdc = BeginPaint(hWnd);			FillBoxWithBitmap(hdc,0,0,400,500,&Back_pic);			FillBoxWithBitmap(hdc,0,0,400,500,&Back_ground);						FillBoxWithBitmap(hdc,280,200,18,19,&Number[LEVEL/10]);			FillBoxWithBitmap(hdc,300,200,18,19,&Number[LEVEL%10]);						number=TIER/1000;			FillBoxWithBitmap(hdc,280,270,18,19,&Number[number]);			number=TIER/100 - number*10;			FillBoxWithBitmap(hdc,300,270,18,19,&Number[number]);			number=TIER/10 -(TIER/100)*10;			FillBoxWithBitmap(hdc,320,270,18,19,&Number[number]);			number=TIER%10;			FillBoxWithBitmap(hdc,340,270,18,19,&Number[number]);			number=SCORE/10000;			FillBoxWithBitmap(hdc,280,340,18,19,&Number[number]);			number=SCORE/1000 -number*10;			FillBoxWithBitmap(hdc,298,340,18,19,&Number[number]);			number=SCORE/100 - (SCORE/1000)*10;			FillBoxWithBitmap(hdc,316,340,18,19,&Number[number]);			number=SCORE/10 - (SCORE/100)*10;			FillBoxWithBitmap(hdc,332,340,18,19,&Number[number]);			number=SCORE%10;			FillBoxWithBitmap(hdc,350,340,18,19,&Number[number]);			number=RECORD/10000;			FillBoxWithBitmap(hdc,280,410,18,19,&Number[number]);			number=RECORD/1000 -number*10;			FillBoxWithBitmap(hdc,298,410,18,19,&Number[number]);			number=RECORD/100 - (RECORD/1000)*10;			FillBoxWithBitmap(hdc,316,410,18,19,&Number[number]);			number=RECORD/10 - (RECORD/100)*10;			FillBoxWithBitmap(hdc,332,410,18,19,&Number[number]);			number=RECORD%10;			FillBoxWithBitmap(hdc,350,410,18,19,&Number[number]);						if( Start== 1)			{				FillBoxWithBitmap(hdc,NEXT_X,NEXT_Y,100,100,&Square.Shape[NextNum]);			}			if( Start== 1)			{				FillBoxWithBitmap(hdc,Square.PostX,Square.PostY,100,100,&Square.Shape[Num]);			}			for( j=0 ; j<10 ; j++)			{				for( i=0 ; i<20 ; i++)				{					if( Base.Flag[i][j] == 1)					{						if( Base.Color == YELLOW )						{							FillBoxWithBitmap(hdc,8+j*25,0+i*25,25,25,&Base.Shape[YELLOW]);						}						else if( Base.Color == GREEN )						{							FillBoxWithBitmap(hdc,8+j*25,0+i*25,25,25,&Base.Shape[GREEN]);						}						else if( Base.Color == BLUE)						{							FillBoxWithBitmap(hdc,8+j*25,0+i*25,25,25,&Base.Shape[BLUE]);						}						else						{							FillBoxWithBitmap(hdc,8+j*25,0+i*25,25,25,&Base.Shape[RED]);						}					}											}			}	     		EndPaint(hWnd,hdc);      			break;  	  	}		case MSG_COMMAND:		{    			int id = LOWORD(wParam);    			int code= HIWORD(wParam);       		switch (id)        		{       			case IDM_START:				{					InitEls();					InvalidateRect (hWnd,NULL,TRUE);					break;       			}				case IDM_LEVEL1:				{					Level=90;					break;				}								case IDM_LEVEL2:				{					Level=80;					break;				}				case IDM_LEVEL3:				{					Level=70;					break;				}				case IDM_LEVEL4:				{					Level=60;					break;				}				case IDM_LEVEL5:				{					Level=50;					break;				}				case IDM_LEVEL6:				{					Level=40;					break;				}				case IDM_LEVEL7:				{					Level=30;					break;				}				case IDM_LEVEL8:				{					Level=20;					break;				}				case IDM_LEVEL9:				{					Level=10;					break;				}								case IDM_EXIT:			           DestroyMainWindow (hWnd);                                PostQuitMessage (hWnd);                                return 0;                   	}                   	break;        	} 		case MSG_KEYDOWN:		{			int scancode = (int)wParam;			if( scancode == 31) //s 			{				while( Square.PostY>MOVE && Start==1 )				{					if( Square.PostY< 400 )					{						JudgeSquare();						GetBottom();						if( Square.PostY<400 )						{							Square.PostY+=MOVE;							Line++;						}					}					else if( Square.PostY== 400 )					{						FinshOne();					}				}				InvalidateRect (hWnd,NULL,TRUE);			}			if( scancode == 30 )//a			{				if( Start==1 )				{						JudgeSquare();					MoveLeft();					InvalidateRect (hWnd,&Rect,TRUE);				}			}			if( scancode == 32 )//d			{				if( Start==1 )				{					JudgeSquare();					MoveRight();					InvalidateRect (hWnd,&Rect,TRUE);				}			}			if( scancode == 17 )//w			{				if( Start==1 )				{					ChangeSquare();					InvalidateRect(hWnd,&Rect,TRUE);				}			}			break;		}		case MSG_TIMER:		{			if (wParam == 100)			{				if( Square.PostY< 400 && Start == 1 )				{					JudgeSquare();					GetBottom();					if( Square.PostY<400 )					{						Square.PostY+=MOVE;						Line++;						InvalidateRect(hWnd, &Rect, TRUE);					}				}				else if( Square.PostY== 400 && Start == 1 )				{					FinshOne();					InvalidateRect(hWnd,NULL,TRUE);				}				ResetTimer( hWnd, 100, Level);			}			break;		}        	case MSG_CLOSE:           	 DestroyMainWindow (hWnd);           	 PostQuitMessage (hWnd);           	 return 0;   	 }   	 return DefaultMainWinProc(hWnd, message, wParam, lParam);}int MiniGUIMain (int argc, const char* argv[]){    MSG Msg;    HWND hMainWnd;    MAINWINCREATE CreateInfo;#ifdef _LITE_VERSION    SetDesktopRect(0, 0, 1024, 768);#endif    CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION;    CreateInfo.dwExStyle = WS_EX_NONE;    CreateInfo.spCaption = "  game ";    CreateInfo.hMenu =createmenu();    CreateInfo.hCursor = GetSystemCursor(0);    CreateInfo.hIcon = 0;    CreateInfo.MainWindowProc = ElsWinProc;    CreateInfo.lx = 0;    CreateInfo.ty = 0;    CreateInfo.rx = 400;    CreateInfo.by = 555;    CreateInfo.iBkColor = COLOR_lightwhite;    CreateInfo.dwAddData = 0;    CreateInfo.hHosting = HWND_DESKTOP;            hMainWnd = CreateMainWindow (&CreateInfo);        if (hMainWnd == HWND_INVALID)        return -1;    LoadPicture();    ShowWindow(hMainWnd, SW_SHOWNORMAL);    while (GetMessage(&Msg, hMainWnd)) {        TranslateMessage(&Msg);        DispatchMessage(&Msg);    }    MainWindowThreadCleanup (hMainWnd);    return 0;}#ifndef _LITE_VERSION#include <minigui/dti.c>#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -