snake.h

来自「一个自己编写的贪食蛇游戏.」· C头文件 代码 · 共 53 行

H
53
字号
// Snake.h: 棋子类负责绘制自身,同象棋类对象协同完成移动,吃子
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_Snake_H__55E618A2_784A_4823_86DA_8D5CD8339022__INCLUDED_)
#define AFX_Snake_H__55E618A2_784A_4823_86DA_8D5CD8339022__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "GSnakeID.h"
class GSnake;

class Snake  
{
private:
	void		ComputeRect();
	bool		CanMove();
	RECT		m_rect;
	int			m_iLength;
	int			m_iAppleEat;
	Direct		m_to;						//棋子位置
	COLORREF	m_rColor;					//棋子颜色
	bool		m_bIsDie;
	bool		m_bIsEat;
	POINT		m_pos[TOTALLEN+1];			//位置0未使用
	static		GSnake	*m_pGSnake;			//棋子所属象棋对象的指针

public:
	bool IsSnake(int x, int y);
	void ChangeDirect(Direct to = SNK_DEFDIR); 
	bool Move();
	
	RECT GetMinRect()const{ return	m_rect; }
	int GetPosX(int i)const{ return m_pos[i].x; }
	int GetPosY(int i)const{ return m_pos[i].y; }
	COLORREF GetColor()const{ return m_rColor; }
	int GetLength() const { return m_iLength; }
	bool IsDie() const {return m_bIsDie; }
	void Die() {m_bIsDie = true;}
	int GetAppleEated()const {return m_iAppleEat;}

	void Show(HDC hdc,  bool isMove = false, bool isAdd = false);								//显示蛇

	Snake(GSnake * theGSnake, int iLen = SNK_DEFLEN, COLORREF rCol = SNK_DEFCOL);
	virtual ~Snake();
};



#endif // !defined(AFX_Snake_H__55E618A2_784A_4823_86DA_8D5CD8339022__INCLUDED_)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?