2002-03-09 23:29:33 +00:00
|
|
|
/*
|
2003-11-26 03:40:01 +00:00
|
|
|
* Copyright 2000 Joshua Thielen
|
2002-03-09 23:29:33 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-09 23:29:33 +00:00
|
|
|
*/
|
|
|
|
|
2000-03-15 19:06:39 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#define BEGINNER_MINES 10
|
2008-06-24 18:09:34 +00:00
|
|
|
#define BEGINNER_COLS 9
|
|
|
|
#define BEGINNER_ROWS 9
|
2000-03-15 19:06:39 +00:00
|
|
|
|
|
|
|
#define ADVANCED_MINES 40
|
|
|
|
#define ADVANCED_COLS 16
|
|
|
|
#define ADVANCED_ROWS 16
|
|
|
|
|
|
|
|
#define EXPERT_MINES 99
|
|
|
|
#define EXPERT_COLS 30
|
|
|
|
#define EXPERT_ROWS 16
|
|
|
|
|
|
|
|
#define MAX_COLS 30
|
|
|
|
#define MAX_ROWS 24
|
|
|
|
|
|
|
|
#define BOTTOM_MARGIN 20
|
|
|
|
#define BOARD_WMARGIN 5
|
|
|
|
#define BOARD_HMARGIN 5
|
|
|
|
|
|
|
|
/* mine defines */
|
|
|
|
#define MINE_WIDTH 16
|
|
|
|
#define MINE_HEIGHT 16
|
|
|
|
#define LED_WIDTH 12
|
|
|
|
#define LED_HEIGHT 23
|
|
|
|
#define FACE_WIDTH 24
|
|
|
|
#define FACE_HEIGHT 24
|
|
|
|
|
2008-06-24 18:09:54 +00:00
|
|
|
#define MAX_PLAYER_NAME_SIZE 31
|
|
|
|
|
2000-03-15 19:06:39 +00:00
|
|
|
typedef enum { SPRESS_BMP, COOL_BMP, DEAD_BMP, OOH_BMP, SMILE_BMP } FACE_BMP;
|
|
|
|
|
|
|
|
typedef enum { WAITING, PLAYING, GAMEOVER, WON } GAME_STATUS;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
MPRESS_BMP, ONE_BMP, TWO_BMP, THREE_BMP, FOUR_BMP, FIVE_BMP, SIX_BMP,
|
|
|
|
SEVEN_BMP, EIGHT_BMP, BOX_BMP, FLAG_BMP, QUESTION_BMP, EXPLODE_BMP,
|
|
|
|
WRONG_BMP, MINE_BMP, QPRESS_BMP
|
|
|
|
} MINEBMP_OFFSET;
|
|
|
|
|
|
|
|
typedef enum { BEGINNER, ADVANCED, EXPERT, CUSTOM } DIFFICULTY;
|
|
|
|
|
|
|
|
typedef struct tagBOARD
|
|
|
|
{
|
|
|
|
BOOL IsMarkQ;
|
|
|
|
HDC hdc;
|
|
|
|
HINSTANCE hInst;
|
|
|
|
HWND hWnd;
|
|
|
|
HBITMAP hMinesBMP;
|
|
|
|
HBITMAP hFacesBMP;
|
|
|
|
HBITMAP hLedsBMP;
|
|
|
|
RECT mines_rect;
|
|
|
|
RECT face_rect;
|
|
|
|
RECT timer_rect;
|
2002-05-31 23:06:46 +00:00
|
|
|
RECT counter_rect;
|
2000-03-15 19:06:39 +00:00
|
|
|
|
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
|
|
|
POINT pos;
|
|
|
|
|
|
|
|
unsigned time;
|
2002-05-31 23:06:46 +00:00
|
|
|
unsigned num_flags;
|
2000-03-15 19:06:39 +00:00
|
|
|
unsigned boxes_left;
|
|
|
|
unsigned num_mines;
|
|
|
|
|
|
|
|
/* difficulty info */
|
|
|
|
unsigned rows;
|
|
|
|
unsigned cols;
|
|
|
|
unsigned mines;
|
2008-06-24 18:09:54 +00:00
|
|
|
char best_name [3][MAX_PLAYER_NAME_SIZE+1];
|
2005-07-03 11:20:08 +00:00
|
|
|
DWORD best_time [3];
|
2000-03-15 19:06:39 +00:00
|
|
|
DIFFICULTY difficulty;
|
|
|
|
|
|
|
|
POINT press;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-03-15 19:06:39 +00:00
|
|
|
/* defines for mb */
|
2005-03-02 12:23:20 +00:00
|
|
|
#define MB_NONE 0
|
|
|
|
#define MB_LEFTDOWN 1
|
|
|
|
#define MB_LEFTUP 2
|
|
|
|
#define MB_RIGHTDOWN 3
|
|
|
|
#define MB_RIGHTUP 4
|
|
|
|
#define MB_BOTHDOWN 5
|
|
|
|
#define MB_BOTHUP 6
|
2000-03-15 19:06:39 +00:00
|
|
|
unsigned mb;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2000-03-15 19:06:39 +00:00
|
|
|
FACE_BMP face_bmp;
|
|
|
|
GAME_STATUS status;
|
|
|
|
struct BOX_STRUCT
|
|
|
|
{
|
|
|
|
unsigned IsMine : 1;
|
|
|
|
unsigned IsPressed : 1;
|
|
|
|
unsigned FlagType : 2;
|
|
|
|
unsigned NumMines : 4;
|
|
|
|
} box [MAX_COLS + 2] [MAX_ROWS + 2];
|
|
|
|
|
|
|
|
/* defines for FlagType */
|
2005-03-02 12:23:20 +00:00
|
|
|
#define NORMAL 0
|
|
|
|
#define QUESTION 1
|
|
|
|
#define FLAG 2
|
|
|
|
#define COMPLETE 3
|
2000-03-15 19:06:39 +00:00
|
|
|
|
|
|
|
} BOARD;
|
|
|
|
|
|
|
|
void CheckLevel( BOARD *p_board );
|
|
|
|
|
2006-06-03 15:28:04 +00:00
|
|
|
INT_PTR CALLBACK CustomDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
2000-03-15 19:06:39 +00:00
|
|
|
|
2006-06-03 15:28:04 +00:00
|
|
|
INT_PTR CALLBACK CongratsDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
2000-03-15 19:06:39 +00:00
|
|
|
|
2006-06-03 15:28:04 +00:00
|
|
|
INT_PTR CALLBACK TimesDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
2000-03-15 19:06:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* end of header */
|