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

📄 els.c

📁 minigui编写的俄罗斯方块! 希望大家喜欢!
💻 C
字号:
#include <stdio.h>#include <string.h>#include <time.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/mywindows.h>#include <minigui/mgext.h>#include <minigui/filedlg.h>#include <minigui/newfiledlg.h>#define NEXT_X 278#define NEXT_Y 12#define BEGIN_X 8#define BEGIN_Y 0#define YELLOW 0#define GREEN 1#define BLUE 2#define RED 3#define MOVE 25typedef struct _SQUARE{	int Kind;	int Color;	int PostX;	int PostY;	int Flag[4][4];	BITMAP Shape;}SQUARE;typedef struct _BASE{	int Color;	BITMAP Shape;}BASE;static BITMAP Back_pic;static BITMAP Back_ground;static SQUARE Square[76];static BASE Base[4][160];static int Flag[10][20];int test=0;static int Line=0;static int Row=0;static LoadPicture(){	int i=0;		LoadBitmap (HDC_SCREEN, &Back_pic,"./bk/bk_pic001.bmp");	LoadBitmap (HDC_SCREEN, &Back_ground,"./bk/bk_ground.png");		LoadBitmap (HDC_SCREEN, &Square[YELLOW+0].Shape,"./square/yellow/yellowj1.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+1].Shape,"./square/yellow/yellowj2.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+2].Shape,"./square/yellow/yellowj3.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+3].Shape,"./square/yellow/yellowj4.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+4].Shape,"./square/yellow/yellowl1.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+5].Shape,"./square/yellow/yellowl2.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+6].Shape,"./square/yellow/yellowl3.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+7].Shape,"./square/yellow/yellowl4.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+8].Shape,"./square/yellow/yellowt1.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+9].Shape,"./square/yellow/yellowt2.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+10].Shape,"./square/yellow/yellowt3.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+11].Shape,"./square/yellow/yellowt4.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+12].Shape,"./square/yellow/yellows1.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+13].Shape,"./square/yellow/yellows2.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+14].Shape,"./square/yellow/yellowz1.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+15].Shape,"./square/yellow/yellowz2.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+16].Shape,"./square/yellow/yellowi1.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+17].Shape,"./square/yellow/yellowi2.png");	LoadBitmap (HDC_SCREEN, &Square[YELLOW+18].Shape,"./square/yellow/yellowo.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+0].Shape,"./square/blue/bluej1.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+1].Shape,"./square/blue/bluej2.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+2].Shape,"./square/blue/bluej3.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+3].Shape,"./square/blue/bluej4.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+4].Shape,"./square/blue/bluel1.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+5].Shape,"./square/blue/bluel2.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+6].Shape,"./square/blue/bluel3.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+7].Shape,"./square/blue/bluel4.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+8].Shape,"./square/blue/bluet1.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+9].Shape,"./square/blue/bluet2.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+10].Shape,"./square/blue/bluet3.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+11].Shape,"./square/blue/bluet4.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+12].Shape,"./square/blue/blues1.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+13].Shape,"./square/blue/blues2.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+14].Shape,"./square/blue/bluez1.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+15].Shape,"./square/blue/bluez2.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+16].Shape,"./square/blue/bluei1.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+17].Shape,"./square/blue/bluei2.png");	LoadBitmap (HDC_SCREEN, &Square[BLUE*19+18].Shape,"./square/blue/blueo.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+0].Shape,"./square/green/greenj1.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+1].Shape,"./square/green/greenj2.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+2].Shape,"./square/green/greenj3.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+3].Shape,"./square/green/greenj4.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+4].Shape,"./square/green/greenl1.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+5].Shape,"./square/green/greenl2.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+6].Shape,"./square/green/greenl3.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+7].Shape,"./square/green/greenl4.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+8].Shape,"./square/green/greent1.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+9].Shape,"./square/green/greent2.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+10].Shape,"./square/green/greent3.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+11].Shape,"./square/green/greent4.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+12].Shape,"./square/green/greens1.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+13].Shape,"./square/green/greens2.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+14].Shape,"./square/green/greenz1.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+15].Shape,"./square/green/greenz2.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+16].Shape,"./square/green/greeni1.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+17].Shape,"./square/green/greeni2.png");	LoadBitmap (HDC_SCREEN, &Square[GREEN*19+18].Shape,"./square/green/greeno.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+0].Shape,"./square/red/redj1.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+1].Shape,"./square/red/redj2.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+2].Shape,"./square/red/redj3.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+3].Shape,"./square/red/redj4.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+4].Shape,"./square/red/redl1.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+5].Shape,"./square/red/redl2.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+6].Shape,"./square/red/redl3.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+7].Shape,"./square/red/redl4.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+8].Shape,"./square/red/redt1.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+9].Shape,"./square/red/redt2.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+10].Shape,"./square/red/redt3.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+11].Shape,"./square/red/redt4.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+12].Shape,"./square/red/reds1.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+13].Shape,"./square/red/reds2.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+14].Shape,"./square/red/redz1.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+15].Shape,"./square/red/redz2.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+16].Shape,"./square/red/redi1.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+17].Shape,"./square/red/redi2.png");	LoadBitmap (HDC_SCREEN, &Square[RED*19+18].Shape,"./square/red/redo.png");	for( i=0 ; i<160; i++)	{		LoadBitmap (HDC_SCREEN, &Base[YELLOW][i].Shape,"./square/base/yellow.png");	}	for( i=0 ; i<160; i++)	{		LoadBitmap (HDC_SCREEN, &Base[GREEN][i].Shape,"./square/base/green.png");	}	for( i=0 ; i<160; i++)	{		LoadBitmap (HDC_SCREEN, &Base[BLUE][i].Shape,"./square/base/blue.png");	}	for( i=0 ; i<160; i++)	{		LoadBitmap (HDC_SCREEN, &Base[RED][i].Shape,"./square/base/red.png");	}		srand( (unsigned)time( NULL ) );}static void GetGround(int N){	int line;	int row;	int i=0;	int j=0;	line = Square[N].PostX/MOVE;	row = Square[N].PostY/MOVE - 4;	for( i=0 ; i<4 ; i++ )	{		for( j=0 ; j<4 ; j++)		{			if( Square[N].Flag[j][i]== 1)			{				Flag[line+j][row+i]== 1;				Base[Square[N].Color][(row+i)*10 + line].Color=Square[N].Color;			}		}	}	}static int ElsWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){   	HDC hdc;	int prex,prey;	int i=0;	int j=0;		int num=rand()%77;	switch (message) {			 case MSG_CREATE:  		{   		 	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,BEGIN_X+75,BEGIN_Y,100,100,&Square[test].Shape);			for( i=0 ; i<10 ; i++)			{				for( j=0 ; j++ ; j<16 )				{					if( Flag[i][j]== 1 )					{						FillBoxWithBitmap(hdc,BEGIN_X,500,25,25,&Base[Base.Color][j*10+i].Shape);					}				}			}							     		EndPaint(hWnd,hdc);      			 break;  	  	}		case MSG_LBUTTONDOWN:   		 {     		 	prex = LOSWORD (lParam);      			prey = HISWORD (lParam);			if( prex>NEXT_X && prex<NEXT_X+100 && prey>NEXT_Y && prey<NEXT_Y+100 )			{				Base.Flag[0][0]=1;				Base.Color=RED;				test=9;				InvalidateRect (hWnd,NULL,TRUE);			}			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;    CreateInfo.dwExStyle = WS_EX_NONE;    CreateInfo.spCaption = "  game ";    CreateInfo.hMenu =0;    CreateInfo.hCursor = GetSystemCursor(0);    CreateInfo.hIcon = 0;    CreateInfo.MainWindowProc = ElsWinProc;    CreateInfo.lx = 0;    CreateInfo.ty = 0;    CreateInfo.rx = 400;    CreateInfo.by = 500;    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 + -