65.9K
CodeProject 正在变化。 阅读更多。
Home

桌面拼图游戏

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.44/5 (29投票s)

2006年5月31日

CPOL
viewsIcon

71052

downloadIcon

1405

一个桌面益智游戏。

引言

这是一个广为人知的但略有不同的益智游戏。 拼图的图像未包含在内; 实际上,图像是从您的桌面捕获的! 首先,您可以选择游戏难度:简单、中等、困难,然后按“开始”按钮,游戏将在您指定的时间秒数后开始(默认值为 2 秒)。

游戏说明

  • 要移动一个矩形,请先单击第一个矩形,然后单击第二个矩形。
  • 要将矩形旋转 180 度,请右键单击该矩形。
  • 要显示每个切片的边框,您可以单击鼠标中键。

Sample Image - Desktop_Puzzle_Game.jpg

以下是主要方法

// - 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);

这不是一个新游戏,只是一个帮助其他人了解如何编写此类程序并可能从中找到一些技术的尝试。 欢迎提出任何建议和改进。 享受游戏!

© . All rights reserved.