太复杂,我分成几部分试着做一下
首先是画棋盘,定义两个二维数组来表示每个棋子的状态和棋子周围的雷数,用于显示。
//画棋盘 a表示棋子是否已被翻开,b表示附近的雷数bool MakeMap(bool a[9][9],int b[9][9])
{
int i=0,j=0;
for(i=0;i<9;i++)
{
for(j=0;j<9;j++)
{
if(a[i][j]) printf("%d ",b[i][j]);
else printf("# ");
}
printf("\n");
}
return true;
}
Public _Form1
_Form1=CreateObject("Form1")
_Form1show
RETURN
-----------------------------------------------------------------
-VFP应用程式算法群:12787940 行者孙:310727570-
-----------------------------------------------------------------
DEFINE CLASS Form1 AS form
Top = 0
Left = 0
Height = 68
Width = 153
ShowWindow = 2
DoCreate = T
Caption = "行者示例"
Name = "Form1"
PROCEDURE Load
DECLARE Long ReadProcessMemory IN WIN32API ;
Long hProcess,;
Long lpBaseAddress,;
Long lpBuffer,;
Long nSize,;
Long @lpNumberOfBytesWritten
DECLARE INTEGER OpenProcess IN kernel32;
INTEGER dwDesiredAccessas,;
INTEGER bInheritHandle,;
INTEGER dwProcId
DECLARE INTEGER GetSystemDirectory IN kernel32 As GetSystemDirectoryA;
STRING @ lpBuffer,;
INTEGER nSize
DECLARE INTEGER FindWindow IN user32;
STRING lpClassName,;
STRING lpWindowName
DECLARE INTEGER GetWindowThreadProcessId IN user32;
INTEGER hWnd,;
INTEGER @ lpdwProcId
DECLARE INTEGER ShellExecute IN shell32;
INTEGER hwnd,;
STRING lpOperation,;
STRING lpFile,;
STRING lpParameters,;
STRING lpDirectory,;
INTEGER nShowCmd
DECLARE integer GetProcessHeap IN WIN32API
DECLARE integer HeapAlloc IN WIN32API integer hHeap, integer dwFlags, integer dwBytes
DECLARE integer HeapFree IN WIN32API integer hHeap, integer dwFlags, integer lpMem
DECLARE INTEGER SendMessage IN user32;
INTEGER hWnd,;
INTEGER Msg,;
INTEGER wParam,;
INTEGER lParam
ENDPROC
PROCEDURE Init
thisAddObject("Command1","_classname1")
thisAddObject("Command2","_classname2")
ENDPROC
ENDDEFINE
DEFINE CLASS _classname1 AS commandbutton
Visible=T
Top = 24
Left = 12
Height = 25
Width = 60
Caption = "运行扫雷"
Name = "Command1"
PROCEDURE Click
打开扫雷程序
uDir=REPLICATE(CHR(0),256)
GetSystemDirectoryA(@uDir,256)
uExe=STRTRAN(uDir,CHR(0),'')+'\winmineexe'
uExe='C:\WINDOWS\system32\winmineexe'
ShellExecute(0, "open", uExe, "", "", 4)
ENDPROC
ENDDEFINE
DEFINE CLASS _classname2 AS commandbutton
Visible=T
Top = 24
Left = 84
Height = 25
Width = 60
Caption = "显示雷区"
Name = "Command2"
PROCEDURE Click
显示雷区
dzHeight = 0x1005338 &&地址空间
dzWidth = 0x1005334
dzStart = 0x1005361
PID=0
WM_RBUTTONDOWN = 0x204
WM_RBUTTONUP = 0x205
PROCESS_ALL_ACCESS=0x1F0FFF
lpNumberOfBytesRead=0
hProcHeap = GetProcessHeap()
AdrStr = HeapAlloc(hProcHeap,0,1)
uHwnd = FindWindow(NULL,"扫雷")
GetWindowThreadProcessId(uHwnd,@PID)
hProcess = OpenProcess(PROCESS_ALL_ACCESS,0,PId)
ReadProcessMemory(hProcess, dzWidth, AdrStr, 1,@lpNumberOfBytesRead)
lie = ASC(SYS(2600,AdrStr,1))
ReadProcessMemory(hProcess, dzHeight, AdrStr, 1,@lpNumberOfBytesRead)
hang = ASC(SYS(2600,AdrStr,1))
For Row = 0 To (hang - 1)
For Col = 0 To (lie - 1)
ReadProcessMemory(hProcess, dzStart + Row 32 + Col, AdrStr, 1,@lpNumberOfBytesRead)
If ASC(SYS(2600,AdrStr,1)) = 143
SendMessage(uHwnd, WM_RBUTTONDOWN, 0,(20 + 16 Col)+(60 + 16 Row)65536)
SendMessage(uHwnd, WM_RBUTTONUP, 0, (20 + 16 Col)+(60 + 16 Row)65536)
EndIf
Endf
Endf
ENDPROC
ENDDEFINE
saolei
\项目-扫雷
\\Usersmdf
\\Users_logldf
\\上交文件txt
\\扫雷-HelpCHM
\\扫雷-项目文档doc
\\数据库配置文件(若无法使用自带的数据库则可用此文件新建并初始化数据库)sql
\\用户手册(GB8567——88)1doc
\\程序数据库设计图vsd
\\程序流程图vsd
\\程序类设计图vsd
\\项目文件-代码
\\\Mine
\\\\HelpCHM
\\\\Mine
\\\\\ADL
\\\\\\VisitDatabasecs
\\\\\bin
\\\\\\Debug
\\\\\BLL
\\\\\Cnfigxml
\\\\\Minecsproj
\\\\\Model
\\\\\\Controlscs
\\\\\\Managecs
\\\\\\Panecs
\\\\\\usercs
\\\\\obj
\\\\\\Debug
\\\\\\MinecsprojFileListtxt
\\\\\Programcs
\\\\\Properties
\\\\\\AssemblyInfocs
\\\\\\ResourcesDesignercs
\\\\\\Resourcesresx
\\\\\\SettingsDesignercs
\\\\\\Settingssettings
\\\\\Resources
\\\\\\-png
\\\\\\-1png
\\\\\\0png
\\\\\\01png
\\\\\\1png
\\\\\\11png
\\\\\\2png
\\\\\\21png
\\\\\\3png
\\\\\\31png
\\\\\\4png
\\\\\\41png
\\\\\\5png
\\\\\\51png
\\\\\\6png
\\\\\\61png
\\\\\\7png
\\\\\\71png
\\\\\\8png
\\\\\\81png
\\\\\\9png
\\\\\\91png
\\\\\\BPNG
\\\\\\B1PNG
\\\\\\BompPNG
\\\\\\Bomp1PNG
\\\\\\button1PNG
\\\\\\button11PNG
\\\\\\button2PNG
\\\\\\button21PNG
\\\\\\button3PNG
\\\\\\button31PNG
\\\\\\button4PNG
\\\\\\button41PNG
\\\\\\button5PNG
\\\\\\button51PNG
\\\\\\button6PNG
\\\\\\button61PNG
\\\\\\button7PNG
\\\\\\button71PNG
\\\\\\button8PNG
\\\\\\button81PNG
\\\\\\Face1png
\\\\\\Face11png
\\\\\\Face2png
\\\\\\Face21png
\\\\\\Face3png
\\\\\\Face31png
\\\\\\Face4png
\\\\\\Face41png
\\\\\\Markedpng
\\\\\\Marked1png
\\\\\\MarkedWrongPNG
\\\\\\MarkedWrong1PNG
\\\\\\questionPNG
\\\\\\question1PNG
\\\\\UIL
\\\\\\HeroListFormscs
\\\\\\HeroListFormsDesignercs
\\\\\\HeroListFormsresx
\\\\\\MainFormscs
以上就是关于C语言编一个9*9的扫雷游戏程序,跟网上那些不一样,求大神给个正确的答案全部的内容,包括:C语言编一个9*9的扫雷游戏程序,跟网上那些不一样,求大神给个正确的答案、想用C#写一个扫雷游戏程序,但是关于雷区分布和DGI绘图以及左右鼠标按键不是很清楚,来个高手教教啊!、跪求C#扫雷程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)