加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
data.h 7.98 KB
一键复制 编辑 原始数据 按行查看 历史
#ifndef _DATA_H_
#define _DATA_H_
/*头文件*/
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
#include "SDL_video.h"
/***************************配置区域***********************************/
//是否显示姓名
#define SHOW_NAME 0 // 0-不显示 1-显示
//配置音乐
#define SHOW_WIN_MUSIC 0 // 0-关闭 1-打开
#define SHOW_FAIL_MUSIC 0 // 0-关闭 1-打开
//背景上半部分调整变量,根据两侧大小和中间大小调整,用来补全空隙和填充缝隙
#define BACK_UP_TEST 8
//不同难度炸弹数量
#define BOMB_E_NUM 10
#define BOMB_E_X 9
#define BOMB_E_Y 9
#define BOMB_N_NUM 20
#define BOMB_N_X 11
#define BOMB_N_Y 11
#define BOMB_H_NUM 40
#define BOMB_H_X 15
#define BOMB_H_Y 15
#define BOMB_U_NUM 15 //用户定义的默认地雷数量
#define BOMB_U_X 10
#define BOMB_U_Y 10
/*初始难度设置 0-简单 1-中等 2-困难 3-自定义*/
#define DEFAULT_MODE 0
/*********************************************************************/
/*音乐路径*/
#define PATH_MUSIC_FAIL ".\\music\\bomb.wav"
#define PATH_MUSIC_WIN ".\\music\\win.wav"
/*图片路径*/
#define PATH_BACK_FILL ".\\images\\back_ground.png"
/*背景图片路径*/
#define PATH_BACK_UP_LEFT ".\\images\\back_u_l.png"//80*230
#define PATH_BACK_UP_MI ".\\images\\back_u_m.png"//80*47
#define PATH_BACK_UP_RIGHT ".\\images\\back_u_r.png"//80*230
#define PATH_BACK_DDOWN_LEFT ".\\images\\back_d_dl.png"//30*20
#define PATH_BACK_DDOWN_RIGHT ".\\images\\back_d_dr.png"//30*19
#define PATH_BACK_DUP_RIGHT ".\\images\\back_d_ur.png"//21*19
#define PATH_BACK_DUP_LEFT ".\\images\\back_d_ul.png"//21*20
#define PATH_BACK_PL_UP ".\\images\\back_u_pl.png"//21*47
#define PATH_BACK_PL_LEFT ".\\images\\back_l_pl.png"//47*20
#define PATH_BACK_PL_DOWN ".\\images\\back_d_pl.png"//30*47
#define PATH_BACK_PL_RIGHT ".\\images\\back_r_pl.png"//47*19
/*开始/结束按钮*/
#define PATH_GAME_END ".\\images\\end.png"//19*76
#define PATH_GAME_BEGIN ".\\images\\start.png"
/*笑脸图片*/
#define PATH_ENJOY_WIN_UP ".\\images\\enjoy_w_u.png"//31*31
#define PATH_ENJOY_WIN_DOWN ".\\images\\enjoy_w_d.png"
#define PATH_ENJOY_NORMAL_UP ".\\images\\enjoy_n_u.png"
#define PATH_ENJOY_NORMAL_DOWN ".\\images\\enjoy_n_d.png"
#define PATH_ENJOY_FAIL_UP ".\\images\\enjoy_f_u.png"
#define PATH_ENJOY_FAIL_DOWN ".\\images\\enjoy_f_d.png"
/*成绩和时间图片*/
#define PATH_TIME ".\\images\\time.png"//18*39
#define PATH_GRADES ".\\images\\grades.png"
/*难度选择图片*/
#define PATH_BUT_EASY ".\\images\\easy.png"//23*46
#define PATH_BUT_NORMAL ".\\images\\normal.png"
#define PATH_BUT_HARD ".\\images\\hard.png"
#define PATH_BUT_CUSTOMIZE ".\\images\\customize.png"//23*69
/*自定义难度选择区域图片*/
#define PATH_THREE_CHOIC ".\\images\\three_choic.png"//23*175
#define PATH_SURE ".\\images\\sure.png"//23*46
#define PATH_BUT_UP ".\\images\\up_bot.png"//12*17
#define PATH_BUT_DOWN ".\\images\\down_bot.png"
/*数字图片本地路径*/
#define PATH_NUMBER ".\\images\\number.png"//19*180
/*单元格路径*/
#define PATH_PLAID_NORMAL ".\\images\\blank.png"//47*47
#define PATH_PLAID_EMPTY ".\\images\\empty.png"
#define PATH_PLAID_1 ".\\images\\1.png"
#define PATH_PLAID_2 ".\\images\\2.png"
#define PATH_PLAID_3 ".\\images\\3.png"
#define PATH_PLAID_4 ".\\images\\4.png"
#define PATH_PLAID_5 ".\\images\\5.png"
#define PATH_PLAID_6 ".\\images\\6.png"
#define PATH_PLAID_7 ".\\images\\7.png"
#define PATH_PLAID_8 ".\\images\\8.png"
#define PATH_PLAID_TAG ".\\images\\tag.png"
#define PATH_PLAID_UNKNOW ".\\images\\unknow.png"
#define PATH_PLAID_BOMB_1 ".\\images\\bomb-2.png"
#define PATH_PLAID_BOMB_2 ".\\images\\bomb-3.png"
/*名称图片*/
#define PATH_NAME ".\\images\\name.png"//15*460
#define NAME_W 460
#define NAME_H 15
/*最小窗口设置*/
#define WINDOW_MIN_WIDTH 460
#define WINDOW_MIN_HEIGHT 131
/*背景图片大小设置*/
#define BACE_FILL_W 2000
#define BACE_FILL_H 2000
#define BACE_UP_LEFT_W 230
#define BACE_UP_LEFT_H 80
#define BACE_UP_MI_W 47
#define BACE_UP_MI_H 80
#define BACE_UP_RIGHT_W 230
#define BACE_UP_RIGHT_H 80
#define BACE_DOWN_LU_W 20
#define BACE_DOWN_LU_H 21
#define BACE_DOWN_RU_W 19
#define BACE_DOWN_RU_H 21
#define BACE_DOWN_LD_W 20
#define BACE_DOWN_LD_H 30
#define BACE_DOWN_RD_W 19
#define BACE_DOWN_RD_H 30
#define BACE_PL_UP_W 47
#define BACE_PL_UP_H 21
#define BACE_PL_LEFT_W 20
#define BACE_PL_LEFT_H 47
#define BACE_PL_DOWN_W 47
#define BACE_PL_DOWN_H 30
#define BACE_PL_RIGHT_W 19
#define BACE_PL_RIGHT_H 47
/*笑脸图片大小*/
#define ENJOY_W 30
#define ENJOY_H 30
/*成绩和时间*/
#define TIME_X 200 //距离右边
#define TIME_Y 31
#define TIME_W 39
#define TIME_H 18
#define GRADES_X 103 //距离右边
#define GRADES_Y 31
#define GRADES_W 39
#define GRADES_H 18
/*难度选择图片大小和位置*/
#define PATH_BUT_EASY_X 15
#define PATH_BUT_EASY_Y 68
#define PATH_BUT_EASY_W 46
#define PATH_BUT_EASY_H 23
#define PATH_BUT_NORMAL_X 15
#define PATH_BUT_NORMAL_Y 68
#define PATH_BUT_NORMAL_W 46
#define PATH_BUT_NORMAL_H 23
#define PATH_BUT_HARD_X 15
#define PATH_BUT_HARD_Y 68
#define PATH_BUT_HARD_W 46
#define PATH_BUT_HARD_H 23
#define PATH_BUT_CUSTOMIZE_X 15
#define PATH_BUT_CUSTOMIZE_Y 68
#define PATH_BUT_CUSTOMIZE_W 69
#define PATH_BUT_CUSTOMIZE_H 23
/*自定义难度各个大小*/
#define THREE_CHOIC_X 283 //此值为到有边界的距离
#define THREE_CHOIC_Y 69
#define THREE_CHOIC_W 175
#define THREE_CHOIC_H 23
#define SURE_X 14 //此值为到有边界的距离
#define SURE_Y 68
#define SURE_W 46
#define SURE_H 23
#define BUT_X_X 231 //x位置(距离右边界)(包括自己宽度)
#define BUT_Y_X 155 //y位置(距离右边界)(包括自己宽度)
#define BUT_N_X 79 //地雷位置(距离右边界)(包括自己宽度)
#define BUT_UP_Y 68 //上按钮的Y
#define BUT_DOWN_Y 84 //下按钮的Y
#define BUT_X 90 //难度选择按钮位置
#define BUT_W 17
#define BUT_H 12
/*开始/结束按钮*/
#define PATH_GAME_W 76
#define PATH_GAME_H 19
#define PATH_GAME_BEGIN_X 30 //开始位置
#define PATH_GAME_END_X 120 //结束位置
#define PATH_GAME_Y 30 //高度
/*单元格信息*/
#define PLAID_W 47 //格子宽高
#define PLAID_H 47
#define PLAID_1_X 20 // 1的X坐标
#define PLAID_1_Y 101 // 1的Y坐标
/* 分数每位数字大小及数字位置 */
#define GRADES_DST_Y 30
#define TIME_DST_Y 30
#define NUMBER_DST_W 18
#define NUMBER_DST_H 19
#define NUMBER_SRC_Y 0
#define NUMBER_SRC_W 18
#define NUMBER_SRC_H 19
//游戏难度选择
typedef enum gamemode
{
ModeE = 0, //简单
ModeN, //中等
ModeH, //困难
ModeU //自定义
}GameMode;
//笑脸状态
typedef enum enjoy
{
EnjoyWinUp = 0, //胜利
EnjoyWinDown , //胜利
EnjoyNormalUp, //正常
EnjoyNormalDown, //正常
EnjoyFailUp, //失败
EnjoyFailDown //失败
}Enjoy;
//游戏是否胜利
typedef enum gamestate
{
Ongoing =0, //正在进行
Win, //胜利
Fail //失败
}GameState;
/*图片类型结构体*/
typedef struct picture
{
SDL_Texture* pPic;//图片纹理
SDL_Rect srcRect;//源区域
SDL_Rect dstRect;//目标区域
}Picture;
/* 单元格的已知类型枚举 */
typedef enum plaidTypeKn
{
TypeEmpty = 0, // 无类型
TypeNum, //周围有炸弹
TypeBomb, //炸弹
TypeBombed //已经炸了
} PlaidTypeKn;
/* 单元格的未知类型枚举 */
typedef enum plaidTypeUnkn
{
TypeNormal = 0, // 无类型
TypeTag, //旗子
TypeQue //问号
} PlaidTypeUnkn;
typedef enum plaidStatf
{
StateUnknow = 0, // 未知
StateKnow, // 已知
StateOver
} PlaidState;
/* 单元格结构体 */
typedef struct plaid
{
PlaidTypeKn type; // 已知精灵类型
PlaidTypeUnkn type_un;//未知精灵
PlaidState state; // 精灵状态
SDL_Rect initRect; // 精灵显示区域
}Plaid;
//游戏状态
typedef struct game
{
GameMode gamemode; //游戏难度
GameState gamestate; //游戏进行状态
int g_time;
int g_grades;
int g_bombNum;
int g_PlaidXNum;
int g_PlaidYNum;
int g_unbombNum;
int g_unPlaidXNum;
int g_unPlaidYNum;
int g_MaxPlaidXNum;
int g_MaxPlaidYNum;
int g_WindowX;
int g_WindowY;
int g_MusicWin;
SDL_Rect g_MaxWindow;
Enjoy g_enjoy;
}Game;
#endif // !_DATA_H_
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化