Click here to Skip to main content
Click here to Skip to main content

XMineSweeper

By , 25 Feb 2006
 

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

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questioncan I use the GNU License Agreement [modified]memberzach callaway9 Nov '08 - 6:47 
GeneralDebug Assertion Failed!membersandeepkavade24 Oct '07 - 0:52 
Generalbrilliant plus an improvementmemberdysfunctional@freesurf.fr24 Aug '07 - 2:57 
QuestionHow to look into resource file of exe?memberMuhammed Nasir5 Jun '07 - 20:33 
AnswerRe: How to look into resource file of exe?memberGarth J Lancaster5 Jun '07 - 21:19 
AnswerRe: How to look into resource file of exe?memberahmadaa5 Jun '07 - 23:39 
QuestionRe: How to look into resource file of exe?memberMuhammed Nasir6 Jun '07 - 19:55 
GeneralTouch Screen Editionmemberphm3713 Jan '07 - 7:40 
AnswerRe: Touch Screen Editionmemberahmadaa15 Jan '07 - 9:10 
Questionhow do i compile the source codememberlyhlyh10 Mar '06 - 21:03 
AnswerRe: how do i compile the source codememberahmadaa11 Mar '06 - 6:14 
GeneralRe: how do i compile the source codememberlyhlyh11 Mar '06 - 6:31 
GeneralRe: how do i compile the source codememberahmadaa12 Mar '06 - 7:24 
AnswerRe: how do i compile the source codememberHomero De la Garza25 Mar '06 - 10:42 
Generalsource codememberRoger6526 Feb '06 - 12:05 
GeneralRe: source codememberahmadaa27 Feb '06 - 7:18 
Generalabout sakhrmemberMohamad Al Husseiny25 Feb '06 - 13:43 
GeneralRe: about sakhrmemberahmadaa26 Feb '06 - 7:23 
GeneralRe: about sakhrmemberMohamad Al Husseiny26 Feb '06 - 14:23 
GeneralBrilliantmemberAshraf_s25 Feb '06 - 10:47 
GeneralRe: Brilliantmemberahmadaa26 Feb '06 - 7:27 
GeneralRe: BrilliantmemberAshraf_s28 Feb '06 - 0:21 
GeneralRe: Brilliantmemberahmadaa28 Feb '06 - 1:39 
Generalgood jobmemberkhalouda25 Feb '06 - 6:47 
GeneralRe: good jobmemberahmadaa25 Feb '06 - 9:17 
GeneralRe: good jobmemberMember 338166211 Mar '09 - 7:39 
QuestionNice...?memberLee Middleotn25 Feb '06 - 5:43 
AnswerRe: Nice...?memberahmadaa25 Feb '06 - 9:18 
GeneralRe: Nice...?memberLee Middleotn25 Feb '06 - 18:47 
GeneralRe: Nice...?memberahmadaa26 Feb '06 - 7:19 

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

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