📄 cball.h
字号:
// CBall.h: interface for the CCBall class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CBALL_H__FEDD3954_6FD0_11D6_9B6C_BFA0FD215847__INCLUDED_)
#define AFX_CBALL_H__FEDD3954_6FD0_11D6_9B6C_BFA0FD215847__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "SeqStack.h"
#include "uRgbColor.h"
#define MAX_GRIDX 9 //横向表格数
#define MAX_GRIDY 9 //纵向表格数
#define GRIDWIDTH 35 //表格宽度
#define TOPGRIDWIDTH 30 //顶部表格宽度
#define MAX_COLOR 7 //颜色数
//////////////////////////////////////////////////////////
struct ITEM
{
int x; //x
int y; //y
int dir; //方向
};
struct OFFSET
{
int x; //x方向
int y; //y方向
};
enum directions {UP, LEFT, DOWN, RIGHT};
////////////////////////////////////////////////////////////
class CCBall
{
public:
CCBall();
virtual ~CCBall();
public:
void Init(); //初始化数据
void SwapActiveBall(int nX, int nY); //交换激活状态小球
void SetActiveBall(int nX, int nY); //设置球为激活状态
BOOL IsExistBall(int nX, int nY); //是否有小球
void MoveBall(int nX, int nY); //移动小球
int GetPreBallColor(int nNum); //
void GrowPreBall(int nNum);
int GetFirstColor();
bool GrowBallForFirst(int &x, int &y, int &color);
bool GrowBall(int &x, int &y, int &color, int index);
int GetActiveBall(); //得到被激活的小球
BOOL IsCanMoveBall(int nX, int nY); //是否能移到
bool CheckCanClear(); //检查是否能消掉
int GetBallColor(int nX, int nY); //得到球的颜色
int m_nClearX[MAX_GRIDX][MAX_GRIDY];//要清掉的球的数据,
bool IsOver();
private:
int m_nWidth;
int m_nHeight;
int m_nPreColor[5];
int m_nData[MAX_GRIDX][MAX_GRIDY]; //球的数据, 横纵向
//坐标值为颜色
CDC *m_pDC; //设备描述指针
CBrush m_Brush; //Brush
CPen m_Pen; //Pen
CRect m_rectGrid;
CRect m_rectTop;
CRect m_rectHigher;
CRect m_rectPlayer;
CString m_strHigher;
CString m_strPlayer;
int m_nCurY; //当前的纵列
int m_nCurX; //当前的横列
int m_nCurColor; //当前的球色
int m_nSorce; //分数
BOOL bMoveFlag;
int GetRandomPos(); //得到随机位置
int GetRandomColor(); //得到随机颜色
//迷宫
void SetMaze();
bool GetPath(int x, int y, int xend, int yend, int dir);
void ClearMaze();
private:
OFFSET m_move[4];
int m_mark[MAX_GRIDY+2][MAX_GRIDX+2];
int m_maze[MAX_GRIDY+2][MAX_GRIDX+2];
};
#endif // !defined(AFX_CBALL_H__FEDD3954_6FD0_11D6_9B6C_BFA0FD215847__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -