资源简介
我是北京交大教师程轶平,这是我为我开设的课程“ Windows程序设计”编写的扫雷代码,是基于ReactOS的WinEMine改写的,采用Win32 API。界面完全模仿微软自带的扫雷,完整地实现了整个功能。而且代码很简洁。
代码片段和文件信息
/*===========================================================================
This is the fifth step toward building the WinMine application
Adapted for educational purpose by Yiping Cheng
Beijing Jiaotong University Mar. 2011
based on the WinMine program written by the ReactOS team
Original Copyright Notice:
* WineMine (main.c)
*
* Copyright 2000 Joshua Thielen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not write to the Free Software
* Foundation Inc. 51 Franklin Street Fifth Floor Boston MA 02110-1301 USA
---------------------------------------------------------------------------*/
#include
#include
#include “resource.h“
#include “WinMine.h“
// the only global variable
extern BOARD board;
void TranslateMouseMsg(UINT* puMsg WPARAM wParam)
{
if (*puMsg == WM_LBUTTONDOWN)
SetCapture(board.hWnd);
else if (*puMsg == WM_LBUTTONUP)
ReleaseCapture();
else if ((*puMsg == WM_MOUSEMOVE) && (wParam & MK_LBUTTON))
{
*puMsg = WM_LBUTTONDOWN;
}
}
void ProcessMouseMsg(UINT uMsg LPARAM lParam)
{
POINT pt;
int row col;
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
if (PtInRect(&board.FaceRect pt))
{
if (uMsg == WM_LBUTTONDOWN)
{
DisplayFace(FACE_DOWN);
}
else if (uMsg == WM_LBUTTONUP)
{
NewGame();
}
return;
}
if (board.GameState == GAMEWON)
{
DisplayFace(FACE_WIN);
return;
}
else if (board.GameState == GAMELOST)
{
DisplayFace(FACE_LOSE);
return;
}
Pt2RowCol(pt &row &col);
if (uMsg == WM_LBUTTONDOWN)
{
if (row != board.rowPressed || col != board.colPressed)
{
UnPressBox();
PressBox(row col);
}
DisplayFace(FACE_CAUTION);
}
else
{
UnPressBox();
if (row < 0)
{
// row<0 means we clicked outside the grid
DisplayFace(FACE_HAPPY);
return;
}
if (uMsg == WM_LBUTTONUP)
{
if (board.GameState == WAITING)
{
LayMines(row col);
board.GameState = PLAYING;
SetTimer
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 537 2011-03-08 10:24 WinMine\WinMine.dsw
文件 115712 2011-04-19 08:28 WinMine\WinMine.ncb
文件 1412 2011-04-19 08:27 WinMine\WinMine.plg
文件 48640 2011-04-19 08:28 WinMine\WinMine.opt
文件 4238 2011-04-19 07:55 WinMine\WinMine.h
文件 13820 2011-04-19 00:41 WinMine\WinMine.c
文件 8104 2011-04-19 08:13 WinMine\MineGame.c
文件 7325 2011-04-18 21:09 WinMine\WinMine.dsp
文件 3033 2011-04-19 08:15 WinMine\WinMine.rc
文件 1048 2011-04-19 00:22 WinMine\resource.h
文件 62168 2011-04-19 08:15 WinMine\WinMine.aps
文件 5322 2011-04-19 08:13 WinMine\MinePaint.c
..A.SH. 22528 2011-03-08 14:53 WinMine\res\Thumbs.db
文件 22542 2011-03-07 00:19 WinMine\res\Mine.ico
文件 2326 2011-03-08 11:33 WinMine\res\leds.BMP
文件 1558 2011-03-08 11:33 WinMine\res\faces.bmp
文件 2166 2011-03-08 11:33 WinMine\res\mines.BMP
文件 65536 2011-04-19 08:27 WinMine\Release\WinMine.exe
目录 0 2011-04-19 08:29 WinMine\res
目录 0 2011-04-19 08:29 WinMine\Unicode Debug
目录 0 2011-04-19 08:29 WinMine\Unicode Release
目录 0 2011-04-19 08:29 WinMine\Release
目录 0 2011-04-19 08:29 WinMine\Debug
目录 0 2011-04-19 08:29 WinMine
----------- --------- ---------- ----- ----
388015 24
- 上一篇:计算机网络编程vc++学生管理系统
- 下一篇:C语言socket编程实现网络数据传输
相关资源
- 用c语言编写的扫雷程序
- MATLAB数字图像处理:从仿真到C C++代码
- 数米粒实验源码
- SCAN扫描程序中jtwain.dll文件源码
- 原创一次性口令OneTimePasswordC语言源码
- 扫雷小游戏,c++版本
- DLT645-97/07报文解释器VC源码
- RSA加解密源码VC++实现
- 邮票问题C语言源码
- pop3协议的摆渡木马演示程序
- mfc实现画图板源码+实验报告
- cocos2dx3.0打地鼠源码
- 酒店管理系统源码完整版C++
- Windows文件系统过滤驱动开发教程(第
- 远程桌面(带C++源码)
- 一个基于C++实现的完整进行FTP应用管
- 基于vc++的波形显示源码
- C Socket通信多线程数据双向收发VS201
- C语言编写的扫雷exe文件,附排行榜
- VC++软键盘源码和QQ软键盘差不多哦
- 仿雷电游戏OpenGL源码C++版
- VC++制作程序安装向导完整源码实现
- 简易的VC++点对点文件传输
- 扫雷游戏c++源码实现
- 防火墙C++源码,测试可以运行
- 用c++自编的GPS单点定位程序源码
- 车牌识别源码
- OpenCV手势识别-手掌特征提取源码
- c++primerplus第六版源码
- 汉诺塔VC6.0可视化实现源码
评论
共有 条评论