贪吃蛇C语言游戏代码
//开始编写游戏需要的类
#include //EasyX_2011惊蛰版(绘图库)
#include
#include
#include
#define UP1
#define DOWN2
#define LEFT3
#define RIGHT4
//格子类,定义一个格子的属性及行为
class Cell
{
public:
friend class GameArea; //设置友元函数
void setxy(short x, short y) //设置格子左上角坐标
{
m_x = x, m_y = y;
}
void setfull(short full) //设置格子属性,0为空,1为障碍,2为食物
{
m_full = full;
}
void display(COLORREF color) //设置格子颜色并显示
{
m_color = color;
setfillstyle(m_color);
bar(m_x, m_y, m_x+7, m_y+7);
}
void LaserDisplay() //显示镭射状态的格子
{
IMAGE image(10,10);
SetWorkingImage(&image);
<