Krzysztof Mossakowski
Windows Programming
2005 - Tasks
Drawing simple figures
Version B
Memory Game
Demonstration
The board:
background color - standard for a window
grid for 4x4 fields
8 pairs of objects: rectangles and ellipses in 4 colors
draw gray hatch pattern when field is not revealed
resizeable (make sure it will scale properly to the size of window's client area)
initialize the board randomly after pressing Escape key
Rules of the game:
two revealed the same objects become visible to the end of game
show message box with information when all objects are visible
Hints:
all created GDI objects must be deleted
objects selected as current on DC must not be deleted
good scenario:
create new object
select new object on DC and remember old object
draw something
restore old object
delete new object
example:
HBRUSH brush = CreateSolidBrush( RGB( 255, 0, 0 ));
HBRUSH oldBrush = (HBRUSH)SelectObject( hdc, brush );
// drawing
SelectObject( hdc, oldBrush );
DeleteObject( brush );
WM_KEYDOWN
WM_LBUTTONDOWN
CreateSolidBrush(), CreateHatchBrush()
Approximate points:
drawing the board : 2.5
resizing the board: 1.5
drawing objects: 1.5
drawing hatch pattern for hidden objects: 1.0
initializing the board randomly: 1.0
logic of the game: 2.5