设为首页 加入收藏

TOP

扫雷游戏(纯C实现)(三)
2014-11-23 21:46:20 来源: 作者: 【 】 浏览:8
Tags:扫雷 游戏 实现

使用WIN32API连接窗口

首先,我弄个主窗口出来,没有用到MFC,直接调用API函数实现,先看看代码吧:

   
///////////////////////////////////////
//
// 主函数:扫雷
//
///////////////////////////////////////

#include
< windows.h >
#include
< stdio.h >
#include
" DrawMap.h "//见下文
#include
" def.h "

int m = 10 , n = 10 ;
int map[MAX_X][MAX_Y];
int Global_x[MAX_X], Global_y[MAX_Y];


LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
WINGDIAPI BOOL WINAPI MoveToEx(HDC hdc,
int x, int y, LPPOINT lppt);
// 移动当前画笔的位置
WINGDIAPI BOOL WINAPI LineTo(HDC hdc, int x, int y); // 用来画直线的函数
WINGDIAPI HPEN WINAPI CreatePen( int iStyle, int cWidth, COLORREF color);




int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine,
int iCmdShow)
{
init();
// 初始化数组(地雷分布
int x_position, y_position, x_size, y_size;
set_position_size(
& x_position, & y_position, & x_size, & y_size);

static TCHAR szAppName[] = TEXT ( " MainWin " ) ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;

wndclass.style
= CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc
= WndProc ;
wndclass.cbClsExtra
= 0 ;
wndclass.cbWndExtra
= 0 ;
wndclass.hInstance
= hInstance ;
wndclass.hIcon
= LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor
= LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground
= (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName
= NULL ;
wndclass.lpszClassName
= szAppName ;

if ( ! RegisterClass ( & wndclass))
{
MessageBox (NULL, TEXT (
" This program requires Windows NT! " ),
szAppName, MB_ICONERROR) ;
return 0 ;
}

hwnd
= CreateWindow (szAppName, // window class name
TEXT ( " 扫雷游戏――The ClearMines Game " ), // window caption
WS_OVERLAPPED |
WS_CAPTION
|
WS_SYSMENU
|
WS_MINIMIZEBOX,
// window style
x_position, // initial x position
<script type="text/java script">BAIDU_CLB_fillSlot("771048");
点击复制链接 与好友分享! 回本站首页
<script> function copyToClipBoard(){ var clipBoardContent=document.title + '\r\n' + document.location; clipBoardContent+='\r\n'; window.clipboardData.setData("Text",clipBoardContent); alert("恭喜您!复制成功"); }
分享到: 更多
<script type="text/java script" id="bdshare_js" data="type=tools&uid=12732"> <script type="text/java script" id="bdshell_js"> <script type="text/java script"> var bds_config = {'snsKey':{'tsina':'2386826374','tqq':'5e544a8fdea646c5a5f3967871346eb8'}}; document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js cdnversion=" + Math.ceil(new Date()/3600000)
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇经典算法研究系列:十、从头到尾.. 下一篇经典算法研究系列:十一、从头到..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: