russia.c

来自「minigui PDA系统 可实现手机功能」· C语言 代码 · 共 2,258 行 · 第 1/5 页

C
2,258
字号
    	{        	"edit",        	WS_VISIBLE | WS_BORDER | WS_TABSTOP, 			SETTING_TABLE_ORIGINX+SETTING_TABLE_WIDTH1,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*4,			SETTING_TABLE_WIDTH2,			SETTING_TABLE_HEIGHT,        	IDC_RIGHT_1,        	NULL,        	0    	},    	{        	"edit",        	WS_VISIBLE | WS_BORDER | WS_TABSTOP, 			SETTING_TABLE_ORIGINX+SETTING_TABLE_WIDTH1+SETTING_TABLE_WIDTH2,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*4,			SETTING_TABLE_WIDTH2,			SETTING_TABLE_HEIGHT,        	IDC_RIGHT_2,        	NULL,        	0    	},	{       		"static",        	WS_VISIBLE | SS_CENTER,			SETTING_TABLE_ORIGINX,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*5,			SETTING_TABLE_WIDTH1,			SETTING_TABLE_HEIGHT,        	IDC_STATIC,         	"旋转",        	0    	},    	{        	"edit",        	WS_VISIBLE | WS_BORDER | WS_TABSTOP, 			SETTING_TABLE_ORIGINX+SETTING_TABLE_WIDTH1,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*5,			SETTING_TABLE_WIDTH2,			SETTING_TABLE_HEIGHT,        	IDC_ROTATE_1,         	NULL,        	0    	},    	{        	"edit",        	WS_VISIBLE | WS_BORDER | WS_TABSTOP, 			SETTING_TABLE_ORIGINX+SETTING_TABLE_WIDTH1+SETTING_TABLE_WIDTH2,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*5,			SETTING_TABLE_WIDTH2,			SETTING_TABLE_HEIGHT,        	IDC_ROTATE_2,         	NULL,        	0    	},	{       		"static",        	WS_VISIBLE | SS_CENTER,			SETTING_TABLE_ORIGINX,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*6,			SETTING_TABLE_WIDTH1,			SETTING_TABLE_HEIGHT,        	IDC_STATIC,         	"暂停",        	0    	},    	{        	"edit",        	WS_VISIBLE | WS_BORDER | WS_TABSTOP, 			SETTING_TABLE_ORIGINX+SETTING_TABLE_WIDTH1,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*6,			SETTING_TABLE_WIDTH2,			SETTING_TABLE_HEIGHT,        	IDC_PAUSE_1,         	NULL,        	0    	},    	{        	"edit",        	WS_VISIBLE | WS_BORDER | WS_TABSTOP, 			SETTING_TABLE_ORIGINX+SETTING_TABLE_WIDTH1+SETTING_TABLE_WIDTH2,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*6,			SETTING_TABLE_WIDTH2,			SETTING_TABLE_HEIGHT,        	IDC_PAUSE_2,         	NULL,        	0    	},	{       		"static",        	WS_VISIBLE | SS_CENTER,			SETTING_TABLE_ORIGINX,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*7,			SETTING_TABLE_WIDTH1,			SETTING_TABLE_HEIGHT,        	IDC_STATIC,         	"开始",        	0    	},    	{        	"edit",        	WS_VISIBLE | WS_BORDER | WS_TABSTOP, 			SETTING_TABLE_ORIGINX+SETTING_TABLE_WIDTH1,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*7,			SETTING_TABLE_WIDTH2,			SETTING_TABLE_HEIGHT,        	IDC_START_1,         	NULL,        	0    	},    	{        	"edit",        	WS_VISIBLE | WS_BORDER | WS_TABSTOP, 			SETTING_TABLE_ORIGINX+SETTING_TABLE_WIDTH1+SETTING_TABLE_WIDTH2,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*7,			SETTING_TABLE_WIDTH2,			SETTING_TABLE_HEIGHT,        	IDC_START_2,         	NULL,        	0    	},	{        	"button",        	WS_VISIBLE | BS_PUSHBUTTON | BS_DEFPUSHBUTTON | WS_TABSTOP, 			SETTING_TABLE_ORIGINX+SETTING_TABLE_WIDTH1,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*8,			SETTING_TABLE_WIDTH2,			SETTING_TABLE_HEIGHT,        	IDOK,         	"确定",        	0     	},    	{       		"button",        	WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,			SETTING_TABLE_ORIGINX+SETTING_TABLE_WIDTH1+SETTING_TABLE_WIDTH2,			SETTING_TABLE_ORIGINY+SETTING_TABLE_HEIGHT*8,			SETTING_TABLE_WIDTH2,			SETTING_TABLE_HEIGHT,        	IDCANCEL,         	"取消",         	0    	}};static void DialogKeySetting(HWND hWnd){    DlgKeySetting.controls = CtrlKeySetting;    theApp.bBusy=TRUE;       if(DialogBoxIndirectParam (&DlgKeySetting, hWnd, DialogKeySettingProc, 0L))	SaveSettingValue();    theApp.bBusy=FALSE;   }static int DialogKeySettingProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam){	int iCtrlID;	char strText[50];	static KeySetting tempKeySetting[2];    switch (message) {    case MSG_INITDIALOG:		ConvertScanCode(theApp.KeySetting1.iKeyRotate,strText);	 	SetDlgItemText(hDlg,IDC_ROTATE_1,strText);		tempKeySetting[0].iKeyRotate = theApp.KeySetting1.iKeyRotate;		ConvertScanCode(theApp.KeySetting2.iKeyRotate,strText);	 	SetDlgItemText(hDlg,IDC_ROTATE_2,strText);		tempKeySetting[1].iKeyRotate = theApp.KeySetting2.iKeyRotate;		ConvertScanCode(theApp.KeySetting1.iKeyDown,strText);	 	SetDlgItemText(hDlg,IDC_DOWN_1,strText);		tempKeySetting[0].iKeyDown = theApp.KeySetting1.iKeyDown;		ConvertScanCode(theApp.KeySetting2.iKeyDown,strText);	 	SetDlgItemText(hDlg,IDC_DOWN_2,strText);		tempKeySetting[1].iKeyDown = theApp.KeySetting2.iKeyDown;		ConvertScanCode(theApp.KeySetting1.iKeyLeft,strText);	 	SetDlgItemText(hDlg,IDC_LEFT_1,strText);		tempKeySetting[0].iKeyLeft = theApp.KeySetting1.iKeyLeft;		ConvertScanCode(theApp.KeySetting2.iKeyLeft,strText);	 	SetDlgItemText(hDlg,IDC_LEFT_2,strText);		tempKeySetting[1].iKeyLeft = theApp.KeySetting2.iKeyLeft;		ConvertScanCode(theApp.KeySetting1.iKeyRight,strText);	 	SetDlgItemText(hDlg,IDC_RIGHT_1,strText);		tempKeySetting[0].iKeyRight = theApp.KeySetting1.iKeyRight;		ConvertScanCode(theApp.KeySetting2.iKeyRight,strText);	 	SetDlgItemText(hDlg,IDC_RIGHT_2,strText);		tempKeySetting[1].iKeyRight = theApp.KeySetting2.iKeyRight;		ConvertScanCode(theApp.KeySetting1.iKeyStart,strText);	 	SetDlgItemText(hDlg,IDC_START_1,strText);		tempKeySetting[0].iKeyStart = theApp.KeySetting1.iKeyStart;		ConvertScanCode(theApp.KeySetting2.iKeyStart,strText);	 	SetDlgItemText(hDlg,IDC_START_2,strText);		tempKeySetting[1].iKeyStart = theApp.KeySetting2.iKeyStart;		ConvertScanCode(theApp.KeySetting1.iKeyPause,strText);	 	SetDlgItemText(hDlg,IDC_PAUSE_1,strText);		tempKeySetting[0].iKeyPause = theApp.KeySetting1.iKeyPause;		ConvertScanCode(theApp.KeySetting2.iKeyPause,strText);	 	SetDlgItemText(hDlg,IDC_PAUSE_2,strText);		tempKeySetting[1].iKeyPause = theApp.KeySetting2.iKeyPause;		//ConvertScanCode(theApp.KeySetting1.iDifficulty,strText);		snprintf(strText,50,"%d",theApp.KeySetting1.iDifficulty);	 	SetDlgItemText(hDlg,IDC_DIFFICULT_1,strText);		tempKeySetting[0].iDifficulty = theApp.KeySetting1.iDifficulty;		//ConvertScanCode(theApp.KeySetting2.iDifficulty,strText);		snprintf(strText,50,"%d",theApp.KeySetting2.iDifficulty);	 	SetDlgItemText(hDlg,IDC_DIFFICULT_2,strText);		tempKeySetting[1].iDifficulty = theApp.KeySetting2.iDifficulty;        return 1;        	case MSG_KEYDOWN:		if(wParam == SCANCODE_TAB)			break;		if(wParam == SCANCODE_ENTER)			break;		iCtrlID = GetDlgCtrlID(GetFocusChild(hDlg));		if((iCtrlID != IDOK) && (iCtrlID != IDCANCEL)){			if(((iCtrlID == IDC_DIFFICULT_1) || (iCtrlID == IDC_DIFFICULT_2)) &&	((wParam<2)||(wParam>11)))			 {				if(iCtrlID==IDC_DIFFICULT_1)					snprintf(strText,50,"%d",tempKeySetting[0].iDifficulty);				else					snprintf(strText,50,"%d",tempKeySetting[1].iDifficulty);	 			SetDlgItemText(hDlg,iCtrlID,strText);				return 1;			}			if(ConvertScanCode(wParam,strText)){				SaveKeySetting(wParam,iCtrlID,tempKeySetting);	 			SetDlgItemText(hDlg,iCtrlID,strText);			}		}		return 1;    case MSG_COMMAND:        switch (wParam) {        case IDOK:		if(HaveSameKeySetting(tempKeySetting)){				MessageBox(hDlg,"The Key setting repeat!","Warning",MB_OK);			    break;				}		theApp.KeySetting1.iKeyRotate = tempKeySetting[0].iKeyRotate;		theApp.KeySetting2.iKeyRotate = tempKeySetting[1].iKeyRotate;		theApp.KeySetting1.iKeyDown = tempKeySetting[0].iKeyDown;		theApp.KeySetting2.iKeyDown = tempKeySetting[1].iKeyDown;		theApp.KeySetting1.iKeyLeft = tempKeySetting[0].iKeyLeft;		theApp.KeySetting2.iKeyLeft = tempKeySetting[1].iKeyLeft;		theApp.KeySetting1.iKeyRight = tempKeySetting[0].iKeyRight;		theApp.KeySetting2.iKeyRight = tempKeySetting[1].iKeyRight;		theApp.KeySetting1.iKeyStart = tempKeySetting[0].iKeyStart;		theApp.KeySetting2.iKeyStart = tempKeySetting[1].iKeyStart;		theApp.KeySetting1.iKeyPause = tempKeySetting[0].iKeyPause;		theApp.KeySetting2.iKeyPause = tempKeySetting[1].iKeyPause;		theApp.KeySetting1.iDifficulty = tempKeySetting[0].iDifficulty;		theApp.KeySetting2.iDifficulty = tempKeySetting[1].iDifficulty;	    EndDialog(hDlg,1);	    break;        case IDCANCEL:            EndDialog (hDlg, 0);            break;        }        break;            }        return DefaultDialogProc (hDlg, message, wParam, lParam);}DLGTEMPLATE DlgInputName = {    WS_BORDER | WS_CAPTION,    WS_EX_IMECOMPOSE,    70, 80, 460, 158,    "输入",    0, 0,    4, NULL,    0};CTRLDATA CtrlInputName [] = {    {        "static",        WS_VISIBLE | SS_RIGHT,        14, 30, 150, 18,        IDC_STATIC,         "请输入您的姓名:",        0    },    {        "edit",        WS_VISIBLE | WS_BORDER | WS_TABSTOP,         180, 30, 200, 22,         IDC_NAMEINPUT,         NULL,        0    },    {        "button",        WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,         80, 94, 100, 28,         IDOK,         "确定",        0     },    {        "button",        WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,        276, 94, 100, 28,         IDCANCEL,         "取消",         0    }}; //高分榜用户名 static int  DialogInputNameProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam){    switch (message) {    case MSG_INITDIALOG:        return 1;            case MSG_COMMAND:        switch (wParam) {        case IDOK:	 		GetDlgItemText(hDlg,IDC_NAMEINPUT,theApp.strText,50);	    	EndDialog(hDlg,1);			break;        case IDCANCEL:            EndDialog (hDlg, 0);            break;        }        break;            }        return DefaultDialogProc (hDlg, message, wParam, lParam);}void FreePlayingWindow(HWND hWnd){	PlayingWindow * pPlayingWindow;		pPlayingWindow = theApp.pPlayingWindow1;	if(pPlayingWindow){		if(pPlayingWindow->pMovingSquare)			free(pPlayingWindow->pMovingSquare);		if(pPlayingWindow->pPreCreatedSquare)			free(pPlayingWindow->pPreCreatedSquare);		free(theApp.pPlayingWindow1);		KillTimer(hWnd,RUSSIA_SQUARE_TIMER1);	}	theApp.pPlayingWindow1 = NULL;	pPlayingWindow = theApp.pPlayingWindow2;	if(pPlayingWindow){		if(pPlayingWindow->pMovingSquare)			free(pPlayingWindow->pMovingSquare);		if(pPlayingWindow->pPreCreatedSquare)			free(pPlayingWindow->pPreCreatedSquare);		free(theApp.pPlayingWindow2);		KillTimer(hWnd,RUSSIA_SQUARE_TIMER2);	}	theApp.pPlayingWindow2 = NULL;}void OnCommandNewOne(HWND hWnd){	PlayingWindow * pPlayingWindow;		FreePlayingWindow(hWnd);	theApp.pPlayingWindow1 = (PlayingWindow*)calloc(1,sizeof(PlayingWindow));	pPlayingWindow = theApp.pPlayingWindow1;	pPlayingWindow->iLevel = theApp.KeySetting1.iDifficulty;#ifdef _TIMER_UNIT_10MS	SetTimer(hWnd,RUSSIA_SQUARE_TIMER1,1000/TimerFreq[pPlayingWindow->iLevel]);#else	SetTimer(hWnd,RUSSIA_SQUARE_TIMER1,TimerFreq[pPlayingWindow->iLevel]);#endif}void OnCommandNewTwo(HWND hWnd){	PlayingWindow * pPlayingWindow;		FreePlayingWindow(hWnd);	theApp.pPlayingWindow1 = (PlayingWindow*)calloc(1,sizeof(PlayingWindow));	pPlayingWindow = theApp.pPlayingWindow1;	pPlayingWindow->iLevel = theApp.KeySetting1.iDifficulty;#ifdef _TIMER_UNIT_10MS	SetTimer(hWnd,RUSSIA_SQUARE_TIMER1,1000/TimerFreq[pPlayingWindow->iLevel]);#else	SetTimer(hWnd,RUSSIA_SQUARE_TIMER1,TimerFreq[pPlayingWindow->iLevel]);#endif	theApp.pPlayingWindow2 = (PlayingWindow*)calloc(1,sizeof(PlayingWindow));	pPlayingWindow = theApp.pPlayingWindow2;	pPlayingWindow->iLevel = theApp.KeySetting2.iDifficulty;#ifdef _TIMER_UNIT_10MS	SetTimer(hWnd,RUSSIA_SQUARE_TIMER2,1000/TimerFreq[pPlayingWindow->iLevel]);#else	SetTimer(hWnd,RUSSIA_SQUARE_TIMER2,TimerFreq[pPlayingWindow->iLevel]);#endif}void OnClose(HWND hWnd){	 if(!hWnd) return;	 FreePlayingWindow(hWnd);	 //saving the high score,keys arrange...     DestroyMainWindow (hWnd);     PostQuitMessage (hWnd);}//绘制游戏主界面窗体void DrawPlayingWindow(HDC hDC, HWND hWnd, POINT poStart,\	int iSideLength,PlayingWindow * pPlayingWindow){	RECT rect;	char strText[50];	int i,j;		MovingSquare *pMovingSquare;	BOOL bMeetBrick;	POINT poStart1;	assert(hDC);	assert(pPlayingWindow);	rect.left = poStart.x -4;	rect.top  = poStart.y -4;	rect.right = poStart.x +iSideLength*RUSSIA_SQUARE_WIDTH+4;	rect.bottom = poStart.y + iSideLength*			(RUSSIA_SQUARE_HEIGHT+4)+RUSSIA_SQUARE_GRID+4;	Draw3DBorder (hDC,rect.left,rect.top,rect.right,rect.bottom);	rect.left += 2;	rect.top  += 2;	rect.right -= 2;	rect.bottom -= 2;   	Draw3DBorder (hDC,rect.left,rect.top,rect.right,rect.bottom);		snprintf(strText,50,"Score:%d",pPlayingWindow->iScore);		TextOut(hDC,poStart.x+2,poStart.y+2,strText);	if(!pPlayingWindow->bBegin){		TextOut(hDC,poStart.x+2,poStart.y+22,"Push start key...");		return;	}else if (pPlayingWindow->bPause){		TextOut(hDC,poStart.x+2,poStart.y+22,"Paused...");		return;	}else if(pPlayingWindow->bDead){		TextOut(hDC,poStart.x+2,poStart.y+22,"Die...");	}	poStart.y += RUSSIA_SQUARE_GRID;

⌨️ 快捷键说明

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