qg777钱柜误乐

热门关键词: qg777钱柜误乐

[开源]扫雷

VC6与DEV都得以编写翻译通过。代码是2400格300个雷的,能够校正。

//sl.c#includewindows.h#includestdlib.h#includestdio.h#includetime.h#includemath.h#defineNOLE0#defineOOO-1#defineX18#defineW60#defineH40#defineLE300constCOLORREFLERGB[]={0x008000,0x800000,0x0080FF,0X800080,0X404080,0XC08000,0X40FF00,0XFF00FF,0X00FFC0};intmap[W+2][H+2];intcount;intle;chara[10];HWNDhWnd;HDChDc;PAINTSTRUCTpt;HDCdhdc,mhdc;RECTdrect;HBITMAPhmbmp;intcx,cy;voidMapInit();voidLeftClick(intx,inty);voidRightClick(intx,inty);voidIfLe();voidLeDraw(inti,intj);voidLeColor(inti,intj,COLORREFx,ints);voidZeroLe(inti,intj);voidOld();voidSetOld(intx,inty,COLORREFr,inti,ints);voidDrawInit();LRESULTCALLBACKWndProc(HWNDhwnd,UINTMessage,WPARAMwParam,LPARAMlParam){switch(Message){caseWM_KEYDOWN:switch(wParam){case'N':MapInit();break;}break;caseWM_LBUTTONDOWN:LeftClick(LOWORD(lParam),HIWORD(lParam));break;caseWM_RBUTTONDOWN:RightClick(LOWORD(lParam),HIWORD(lParam));break;caseWM_PAINT:hDc=BeginPaint(hWnd,pt);BitBlt(dhdc,0,0,cx,cy,mhdc,0,0,SRCCOPY);EndPaint(hWnd,pt);break;caseWM_CLOSE:DestroyWindow(hwnd);break;caseWM_DESTROY:PostQuitMessage(0);break;default:returnDefWindowProc(hwnd,Message,wParam,lParam);}return0;}intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow){WNDCLASSEXwc;HWNDhwnd;MSGMsg;memset(wc,0,sizeof(wc));wc.cbSize=sizeof(WNDCLASSEX);wc.lpfnWndProc=WndProc;wc.hInstance=hInstance;wc.hCursor=LoadCursor(NULL,IDC_ARROW);wc.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);wc.lpszClassName="WindowClass";wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);wc.hIconSm=LoadIcon(NULL,IDI_APPLICATION);if(!RegisterClassEx(wc)){MessageBox(NULL,"WindowRegistrationFailed!","Error!",MB_ICONEXCLAMATION|MB_OK);return0;}hwnd=CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass","Caption",WS_VISIBLE|WS_OVERLAPPEDWINDOW^WS_THICKFRAME^WS_MAXIMIZEBOX,CW_USEDEFAULT,CW_USEDEFAULT,1090,752,NULL,NULL,hInstance,NULL);if(hwnd==NULL){MessageBox(NULL,"WindowCreationFailed!","Error!",MB_ICONEXCLAMATION|MB_OK);return0;}hWnd=hwnd;count=0;le=0;srand(time(NULL));DrawInit();MapInit();while(GetMessage(Msg,NULL,0,0)0){TranslateMessage(Msg);DispatchMessage(Msg);}DeleteObject(mhdc);ReleaseDC(hWnd,dhdc);returnMsg.wParam;}voidMapInit(){inti,j,k,d;count=0;le=0;for(i=1;i=W;i++)for(j=1;j=H;j++)map[i][j]=NOLE;while(countLE){i=(rand()%W)+1;j=(rand()%H)+1;if(map[i][j]==0){map[i][j]=OOO;count++;}}for(i=1;i=W;i++)for(j=1;j=H;j++)if(map[i][j]=NOLE){count=0;for(k=-1;k=1;k++)for(d=-1;d=1;d++)if(1=i+ki+k=W1=j+dj+d=Hmap[i+k][j+d]NOLE)count++;map[i][j]=count;}SelectObject(mhdc,GetStockObject(GRAY_BRUSH));SetBkColor(mhdc,0x808080);for(i=1;i=W;i++)for(j=1;j=H;j++){Rectangle(mhdc,(i-1)*X,(j-1)*X,i*X,j*X);}BitBlt(dhdc,0,0,cx,cy,mhdc,0,0,SRCCOPY);}voidLeftClick(intx,inty){inti=(int)floor(x/X);intj=(int)floor(y/X);if(map[i+1][j+1]=NOLE){if(map[i+1][j+1]==NOLE)ZeroLe(i,j);elseLeDraw(i,j);BitBlt(dhdc,0,0,cx,cy,mhdc,0,0,SRCCOPY);}else{IfLe();BitBlt(dhdc,0,0,cx,cy,mhdc,0,0,SRCCOPY);MessageBox(hWnd,"Bad","Game",MB_OK);MapInit();}}voidRightClick(intx,inty){inti=(int)floor(x/X);intj=(int)floor(y/X);LeColor(i,j,0,-1);if(map[i+1][j+1]==OOO){le++;map[i+1][j+1]=-2;}if(le==LE){IfLe();MessageBox(hWnd,"Good","Game",MB_OK);MapInit();}BitBlt(dhdc,0,0,cx,cy,mhdc,0,0,SRCCOPY);}voidIfLe(){inti,j;for(i=0;iW;i++)for(j=0;jH;j++)if(map[i+1][j+1]=NOLE)LeDraw(i,j);elseLeColor(i,j,0,-1);}voidLeDraw(inti,intj){if(map[i+1][j+1]==0x100||map[i+1][j+1]==0){SelectObject(mhdc,GetStockObject(LTGRAY_BRUSH));Rectangle(mhdc,i*X,j*X,(i+1)*X,(j+1)*X);}elseLeColor(i,j,LERGB[map[i+1][j+1]],0);}voidLeColor(inti,intj,COLORREFx,ints){if(s==0){SetTextColor(mhdc,x);SelectObject(mhdc,GetStockObject(GRAY_BRUSH));Rectangle(mhdc,i*X,j*X,(i+1)*X,(j+1)*X);itoa(map[i+1][j+1],a,10);TextOut(mhdc,i*X+4,j*X+1,a,1);}else{SetTextColor(mhdc,0x008000);SelectObject(mhdc,GetStockObject(GRAY_BRUSH));Rectangle(mhdc,(i)*X,(j)*X,(i+1)*X,(j+1)*X);TextOut(mhdc,(i)*X+5,(j)*X+1,"#",1);}}voidZeroLe(intx,inty){inti,j;if(0=xxW0=yyHmap[x+1][y+1]==NOLE){for(j=-1;j=1;j++)for(i=-1;i=1;i++){LeDraw(x+i,y+j);map[x+1][y+1]=0x100;ZeroLe(x+i,y+j);}}}voidDrawInit(){dhdc=GetDC(hWnd);GetClientRect(hWnd,drect);cx=drect.right;cy=drect.bottom;mhdc=CreateCompatibleDC(dhdc);hmbmp=CreateCompatibleBitmap(dhdc,drect.right,drect.bottom);SelectObject(mhdc,hmbmp);FillRect(mhdc,drect,NULL);}

本文由qg777发布于操作系统,转载请注明出处:[开源]扫雷

TAG标签:
Ctrl+D 将本页面保存为书签,全面了解最新资讯,方便快捷。