⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snake.h

📁 一个自己编写的贪食蛇游戏.
💻 H
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -