Click here to Skip to main content
Licence CPOL
First Posted 30 May 2006
Views 43,725
Bookmarked 35 times

Desktop Puzzle Game

By | 12 Sep 2006 | Article
A Desktop puzzle game.

Introduction

This is a known but a different puzzle game. The images of puzzles are not included; in fact, the images are captured from your desktop! First of all, you can select the game difficulty: easy, medium, hard, and by pressing the Start button, the game will begin after the number of seconds you have specified (default is 2 seconds).

Game instructions

  • to move a rectangle, select the first and then a second one by clicking on the rectangles.
  • to rotate a rectangle by 180 degrees, right click on the rectangle.
  • to reveal the borders of each slice, you can click the middle button of the mouse.

Sample Image - Desktop_Puzzle_Game.jpg

Here are the main methods:

// - Saves the bitmap of display DC to a memory DC
void        CaptureDesktop();

// - Replaces two rects in memory device context
void        ReplaceRects(CRect rectSource, CRect rectDest);

// - Inverts selected rect
void        InvertRect(CRect rect);

// - Draws a frame around a rectangle
void        FrameRect(CRect rect, BOOL bClear=FALSE);

// - Draws a frame around all rectangles
void        DrawFrames();

// - Checks if user has been corrected all rectangles
int        CheckForWin();

// - Returns rect of selected square
CRect        GetSquareFromPoint(CPoint point);

// - Select a rectangle (source) or Replace first selected rectangle (source) 
//   with new selected rectangle (destination)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);

// - Draw all frames for help or clear them all
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);

// - Invert selected rectangle
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);

// - Checks for number of wrong items
afx_msg void OnExit();

// - Draws wrong items
afx_msg void OnTimer(UINT nIDEvent);

This is not a new game, just an attempt to help others on how to write such programs and may be find some techniques from this. Any suggestions and refinements are welcome. Enjoy the game!

License

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

About the Author

Hadi Dayvary

Software Developer
www.LogicSims.ir
Iran (Islamic Republic Of) Iran (Islamic Republic Of)

Member

Hadi Dayvary graduated from Azad University in spring 2003 in Apply Mathematics.
Started Visual C++ in 1999.
He likes to program all the time.
He lives in Iran.
www.LogicSims.ir

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
Generalnice one i like it Pinmemberzzx_12345623:13 24 Jun '09  
Generalsend project Pinmemberfarzaneh13650:06 1 May '08  
GeneralRe: send project PinmemberH adi Dayvary18:50 2 May '08  
Generalnice Pinmemberbhage19:22 15 Sep '06  
GeneralNice Idea Pinmembernorm .net4:54 12 Sep '06  
GeneralGood idea & some suggestion. Pinmemberjcem22:04 16 Jul '06  
GeneralA great idea, and some challenges ahead... PinmemberJun Du3:14 31 May '06  
GeneralRe: A great idea, and some challenges ahead... PinmemberHadi Dayvary21:10 31 May '06  
GeneralRe: A great idea, and some challenges ahead... PinmemberJun Du13:20 1 Jun '06  
GeneralGreat Article PinmemberSBaghestani0:17 31 May '06  
GeneralRe: Rubbish Article but interesting project PinmemberMichael P Butler23:07 15 Jul '06  
GeneralI like it Pinmemberqiuqianren23:45 30 May '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
Web03 | 2.5.120517.1 | Last Updated 12 Sep 2006
Article Copyright 2006 by Hadi Dayvary
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid