Click here to Skip to main content
Licence CPOL
First Posted 25 Feb 2006
Views 55,461
Bookmarked 16 times

XMineSweeper

By | 25 Feb 2006 | Article
A simulation of the famous MineSweeper game by Microsoft.

Sample Image - XMineSweeper.jpg

Introduction

The XMineSweeper is a simulation for the famous 'MineSweeper' game by Microsoft which is shipped with its Windows operating system.

It is a light game that can help you spend some minutes with fun, far from coding problems.

Benefits

I know it sounds silly to make the MineSweeper which is already developed for best outputs by the software gurus at Microsoft, but it was first an assignment for joining a job in a firm (without mentioning its name, Sakhr).

But after development, it was really fun, and it made me learn some practical skills.

Features

Using the resources bitmap files from the original MineSweeper (%windir%\System32\winmine.exe) for drawing with GDI, I tried to make it look like the original by drawing 3D-like lines (by drawing white line on one side, and a gray one on the other side to make it feels like the effect of light and shadow).

The CMineSweeper Class

Here comes the main class for the game which manages the sequence of the game (this is how we learn the Game Engine from game developers). The class responds to user clicks, checks for mines, and draws the output for the 'Device Context' passed to it.

void CMineSweeper::Draw(CDC *pDC);

The draw function is essential for rendering the game to the CDC object passed to it. This design avoids the problem of flicker, by calling this function in the WM_PAINT message, and also call it when we need to update the view for the user.

Handle both right and left mouse button down

Handling the middle mouse button down is straight (ON_WM_MBUTTONUP()), but to handle both right-left mouse buttons down, you have to add a small check for the other button using the API function GetKeyState() which is used by game developers when they can't wait for the message to be sent, rather they go checking for it by themselves.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

ahmadaa

Web Developer

Egypt Egypt

Member

C#
C++
GDI
MFC
ASP.NET

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questioncan I use the GNU License Agreement [modified] Pinmemberzach callaway6:47 9 Nov '08  
GeneralDebug Assertion Failed! Pinmembersandeepkavade0:52 24 Oct '07  
Generalbrilliant plus an improvement Pinmemberdysfunctional@freesurf.fr2:57 24 Aug '07  
QuestionHow to look into resource file of exe? PinmemberMuhammed Nasir20:33 5 Jun '07  
AnswerRe: How to look into resource file of exe? PinmemberGarth J Lancaster21:19 5 Jun '07  
AnswerRe: How to look into resource file of exe? Pinmemberahmadaa23:39 5 Jun '07  
QuestionRe: How to look into resource file of exe? PinmemberMuhammed Nasir19:55 6 Jun '07  
GeneralTouch Screen Edition Pinmemberphm377:40 13 Jan '07  
AnswerRe: Touch Screen Edition Pinmemberahmadaa9:10 15 Jan '07  
Questionhow do i compile the source code Pinmemberlyhlyh21:03 10 Mar '06  
AnswerRe: how do i compile the source code Pinmemberahmadaa6:14 11 Mar '06  
GeneralRe: how do i compile the source code Pinmemberlyhlyh6:31 11 Mar '06  
GeneralRe: how do i compile the source code Pinmemberahmadaa7:24 12 Mar '06  
AnswerRe: how do i compile the source code PinmemberHomero De la Garza10:42 25 Mar '06  
Generalsource code PinmemberRoger6512:05 26 Feb '06  
GeneralRe: source code Pinmemberahmadaa7:18 27 Feb '06  
Generalabout sakhr PinmemberMohamad Al Husseiny13:43 25 Feb '06  
GeneralRe: about sakhr Pinmemberahmadaa7:23 26 Feb '06  
GeneralRe: about sakhr PinmemberMohamad Al Husseiny14:23 26 Feb '06  
GeneralBrilliant PinmemberAshraf_s10:47 25 Feb '06  
GeneralRe: Brilliant Pinmemberahmadaa7:27 26 Feb '06  
GeneralRe: Brilliant PinmemberAshraf_s0:21 28 Feb '06  
GeneralRe: Brilliant Pinmemberahmadaa1:39 28 Feb '06  
Generalgood job Pinmemberkhalouda6:47 25 Feb '06  
GeneralRe: good job Pinmemberahmadaa9:17 25 Feb '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 25 Feb 2006
Article Copyright 2006 by ahmadaa
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid