Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Desktop Puzzle Game

0.00/5 (No votes)
12 Sep 2006 1  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here