基于单片机的贪吃蛇游戏设计

利用三天假期把贪吃蛇游戏移植到了我的单片机开发板上,单片机是STC89C52只有8K的FLASH,本来想移植俄罗斯方块的但是移植编译之后大约有10K的空间。

下面是我拍的视频,优酷的链接:http://v.youku.com/v_show/id_XNjIxNjM2MzUy.html高手勿喷呐!

程序中使用的器件有:

  (1)STC82C52配置有片内RAM512B,片内FLASH存储器 8KB,时钟为8MHz。

  (2)2.4寸TFT彩屏,最大支持RGB565格式有65536种颜色。主控制器为ILI9325,程序中使用的是8位数据模式,所以运行比较慢。

  (3)红外遥控器,采用的是HS0038芯片。红外协议是NEC协议,32位数据位,第一字节为标识码,第二字节为其反码,第三字节为数据位,第四字节为数据位反码。

  下面是我的程序:

    lcd.c是TFT液晶屏的驱动程序,key.c是红外芯片的驱动程序,snake.c是贪吃蛇游戏的程序。lcd.h,key.h以及snake.h是对应的头文件,里面有一部分与平台相关的定义

移植的时候只要做对应的修改即可。下面上一下游戏的界面:

    

                          基于单片机的贪吃蛇游戏设计_第1张图片

 

                                                                   基于单片机的贪吃蛇游戏设计_第2张图片

 

                                                                    基于单片机的贪吃蛇游戏设计_第3张图片            

                                 

 

                                                                         基于单片机的贪吃蛇游戏设计_第4张图片

 

 下面开始贴源代码啦:

    第一代码,lcd.c是TFT彩屏ILI9325的驱动程序。

#include "lcd.h"      
#include "fonts_ascii8x16.h"
#include <reg51.h>


/* 不精确的延时函数 */
void Delayms(int count) 
{
        int i,j;
        for(i=0;i<count;i++)
                for(j=0;j<100;j++);
}

/* 并行数据写入函数,分高低字节写入*/
void LCD_WriteBus(char DataHigh,char DataoLow)   
{    
    LCD_DataPortH = DataHigh;    
       LCD_WR_L
    LCD_WR_H

    LCD_DataPortH = DataoLow;        
    LCD_WR_L
    LCD_WR_H
}

/* 写命令字 */
void LCD_WriteCmd(char DataHigh,char DataoLow)    
{    
    LCD_RS_L
    LCD_CS_L

    LCD_WriteBus(DataHigh,DataoLow);
    LCD_RS_H
    LCD_CS_H
}

/* 写数据 */
void LCD_WriteData(char DataHigh,char DataoLow)    
{
    LCD_CS_L
    LCD_RS_H

    LCD_WriteBus(DataHigh,DataoLow);

    LCD_CS_H

}

/*往指定寄存器写入数据 */
void LCD_WriteReg(unsigned int Register,unsigned int Data)
{
    
    LCD_WriteCmd(Register>>8, Register);
    LCD_WriteData(Data>>8, Data);
}

/* 设置绘图坐标窗口,其中(x1,y1)为左上顶点,(x2,y2)为右下顶点 */
void LCD_SetWindow(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{
    /* 设置显示的矩形区域 */
    LCD_WriteCmd(0x00,0x50);LCD_WriteData(x1>>8,x1);   //开始X
    LCD_WriteCmd(0x00,0x52);LCD_WriteData(y1>>8,y1);   //开始Y
    LCD_WriteCmd(0x00,0x51);LCD_WriteData(x2>>8,x2);   //结束X
    LCD_WriteCmd(0x00,0x53);LCD_WriteData(y2>>8,y2);   //结束Y
    /* 设置矩形绘图区域的起始点 */
    LCD_WriteCmd(0x00,0x20);LCD_WriteData(x1>>8,x1);    //设置X绘图起始坐标位置
    LCD_WriteCmd(0x00,0x21);LCD_WriteData(y1>>8,y1);    //设置Y绘图起始坐标位置
    LCD_WriteCmd(0x00,0x22);                             
}

/* 初始化LCD,写入工作模式相关命令字*/
void LCD_Init(void)
{                 
    LCD_RST_H
    Delayms(5);    
    LCD_RST_L
    Delayms(5);
    LCD_RST_H
    LCD_CS_H
    LCD_RD_H
    LCD_WR_H
    Delayms(5);

    LCD_CS_L  /*打开片选使能*/
    //************* Start Initial Sequence **********//
    LCD_WriteCmd(0x00,0xE5); LCD_WriteData(0x78,0xF0); // set SRAM internal timing
    LCD_WriteCmd(0x00,0x01); LCD_WriteData(0x01,0x00); // set SS and SM bit
    LCD_WriteCmd(0x00,0x02); LCD_WriteData(0x07,0x00); // set 1 line inversion
    LCD_WriteCmd(0x00,0x03); LCD_WriteData(0x10,0x30); // set GRAM write direction and BGR=1.
    LCD_WriteCmd(0x00,0x04); LCD_WriteData(0x00,0x00); // Resize register
    LCD_WriteCmd(0x00,0x08); LCD_WriteData(0x02,0x07); // set the back porch and front porch
    LCD_WriteCmd(0x00,0x09); LCD_WriteData(0x00,0x00); // set non-display area refresh cycle ISC[3:0]
    LCD_WriteCmd(0x00,0x0A); LCD_WriteData(0x00,0x00); // FMARK function
    LCD_WriteCmd(0x00,0x0C); LCD_WriteData(0x00,0x00); // RGB interface setting
    LCD_WriteCmd(0x00,0x0D); LCD_WriteData(0x00,0x00); // Frame marker Position
    LCD_WriteCmd(0x00,0x0F); LCD_WriteData(0x00,0x00); // RGB interface polarity
    //*************Power On sequence ****************//
    LCD_WriteCmd(0x00,0x10); LCD_WriteData(0x00,0x00); // SAP, BT[3:0], AP, DSTB, SLP, STB
    LCD_WriteCmd(0x00,0x11); LCD_WriteData(0x00,0x07); // DC1[2:0], DC0[2:0], VC[2:0]
    LCD_WriteCmd(0x00,0x12); LCD_WriteData(0x00,0x00); // VREG1OUT voltage
    LCD_WriteCmd(0x00,0x13); LCD_WriteData(0x00,0x00); // VDV[4:0] for VCOM amplitude
    LCD_WriteCmd(0x00,0x07); LCD_WriteData(0x00,0x01);
    Delayms(50); // Dis-charge capacitor power voltage
    LCD_WriteCmd(0x00,0x10); LCD_WriteData(0x10,0x90); // 1490//SAP, BT[3:0], AP, DSTB, SLP, STB
    LCD_WriteCmd(0x00,0x11); LCD_WriteData(0x02,0x27); // DC1[2:0], DC0[2:0], VC[2:0]
    Delayms(50); // Delay 50ms
    LCD_WriteCmd(0x00,0x12); LCD_WriteData(0x00,0x1F); //001C// Internal reference voltage= Vci;
    Delayms(50); // Delay 50ms
    LCD_WriteCmd(0x00,0x13); LCD_WriteData(0x15,0x00); //0x1000//1400   Set VDV[4:0] for VCOM amplitude  1A00
    LCD_WriteCmd(0x00,0x29); LCD_WriteData(0x00,0x27); //0x0012 //001a  Set VCM[5:0] for VCOMH  //0x0025  0034
    LCD_WriteCmd(0x00,0x2B); LCD_WriteData(0x00,0x0D); // Set Frame Rate   000C
    Delayms(50); // Delay 50ms
    LCD_WriteCmd(0x00,0x20); LCD_WriteData(0x00,0x00); // GRAM horizontal Address
    LCD_WriteCmd(0x00,0x21); LCD_WriteData(0x00,0x00); // GRAM Vertical Address
    // ----------- Adjust the Gamma Curve ----------//
    LCD_WriteCmd(0x00,0x30); LCD_WriteData(0x00,0x00);
    LCD_WriteCmd(0x00,0x31); LCD_WriteData(0x07,0x07);
    LCD_WriteCmd(0x00,0x32); LCD_WriteData(0x03,0x07);
    LCD_WriteCmd(0x00,0x35); LCD_WriteData(0x02,0x00);
    LCD_WriteCmd(0x00,0x36); LCD_WriteData(0x00,0x08);//0207
    LCD_WriteCmd(0x00,0x37); LCD_WriteData(0x00,0x04);//0306
    LCD_WriteCmd(0x00,0x38); LCD_WriteData(0x00,0x00);//0102
    LCD_WriteCmd(0x00,0x39); LCD_WriteData(0x07,0x07);//0707
    LCD_WriteCmd(0x00,0x3C); LCD_WriteData(0x00,0x02);//0702
    LCD_WriteCmd(0x00,0x3D); LCD_WriteData(0x1D,0x04);//1604
    
    /*------------------ Set GRAM area ---------------*/
    LCD_WriteCmd(0x00,0x50); LCD_WriteData(0x00,0x00); // Horizontal GRAM Start Address
    LCD_WriteCmd(0x00,0x51); LCD_WriteData(0x00,0xEF); // Horizontal GRAM End Address
    LCD_WriteCmd(0x00,0x52); LCD_WriteData(0x00,0x00); // Vertical GRAM Start Address
    LCD_WriteCmd(0x00,0x53); LCD_WriteData(0x01,0x3F); // Vertical GRAM Start Address
    LCD_WriteCmd(0x00,0x60); LCD_WriteData(0xA7,0x00); // Gate Scan Line
    LCD_WriteCmd(0x00,0x61); LCD_WriteData(0x00,0x01); // NDL,DataoLowE, REV
    LCD_WriteCmd(0x00,0x6A); LCD_WriteData(0x00,0x00); // set scrolling line
    /*-------------- Partial Display Control ---------*/
    LCD_WriteCmd(0x00,0x80); LCD_WriteData(0x00,0x00);
    LCD_WriteCmd(0x00,0x81); LCD_WriteData(0x00,0x00);
    LCD_WriteCmd(0x00,0x82); LCD_WriteData(0x00,0x00);
    LCD_WriteCmd(0x00,0x83); LCD_WriteData(0x00,0x00);
    LCD_WriteCmd(0x00,0x84); LCD_WriteData(0x00,0x00);
    LCD_WriteCmd(0x00,0x85); LCD_WriteData(0x00,0x00);
    /*-------------- Panel Control -------------------*/
    LCD_WriteCmd(0x00,0x90); LCD_WriteData(0x00,0x10);
    LCD_WriteCmd(0x00,0x92); LCD_WriteData(0x06,0x00);
    LCD_WriteCmd(0x00,0x07); LCD_WriteData(0x01,0x33); // 262K color and display ON
    LCD_CS_H  /*关闭片选使能 */

}

void LCD_FillScreen(uint16 color)
{
    int i,j;
    /*打开片选使能*/
    LCD_CS_L  
    /*设置绘图坐标原点*/
    LCD_SetWindow(0,0,LCD_WIDTH-1,LCD_HEIGHT-1);
    for(i=0;i<LCD_HEIGHT;i++)
    {
      for (j=0;j<LCD_WIDTH;j++)
           {
             LCD_WriteData(color>>8,color);
        }

    }
    /*关闭片选使能*/
     LCD_CS_H  
}

/*========================    定位函数    ========================*/
/* 函数参数:u8 x,u8 y                                            */
/* 返回值:     void                                                */
/*==============================================================*/
void LCD_SetCursor(unsigned int  x,unsigned int y)
{

    LCD_WriteReg(0x0020,x);            /* 设置x坐标 */
    LCD_WriteReg(0x0021,y);            /* 设置y坐标 */
    LCD_WriteCmd(0x00,0x22);        /* 开始写数据 */

}
/* 设置字符显示窗口,默认是8x16的大小,具体根据字模大小而定 */
/*
void LCD_SetCharWindow(unsigned int x,unsigned int y)
{

    LCD_SetWindow(x, y, x+7, y+15);
}
*/

/*******************************************************************************
* Function Name  : LCD_Line
* Description    : 在s_x、s_y为起始坐标,e_x、e_y为结束坐标绘制一条直线
* Input          : x  X轴坐标     y  Y轴坐标
* Output         : None
* Return         : None
* 使用前景色
*******************************************************************************/
void LCD_Line(unsigned int  s_x, unsigned int s_y, unsigned int e_x, unsigned int e_y, unsigned int color)
{  
    signed int Offset_x,Offset_y,Offset_k = 0;
    signed int Err_d = 1;
    if(s_y > e_y)
    {
        Offset_x = s_x;
        s_x = e_x;
        e_x = Offset_x;
        Offset_x = s_y;
        s_y = e_y;
        e_y = Offset_x;
    } 
    Offset_x = e_x-s_x;
    Offset_y = e_y-s_y;
    
    LCD_SetCursor(s_x,s_y);
    LCD_WriteData(color>>8, color);

    if(Offset_x < 0)
    {
        Offset_x = s_x-e_x;
        Err_d = -1;
    }
    if(0 == Offset_x )
    {
        while(s_y < e_y)
        {
              s_y++;
              if(s_y > Dis_Y_MAX) return;
              LCD_SetCursor(s_x,s_y);
              LCD_WriteData(color>>8, color);
        }
         return;
    }
    else if(Offset_y == 0)
    {
        while(s_x != e_x)
        {    
              s_x += Err_d;
              if(s_x > Dis_X_MAX) return;
              LCD_SetCursor(s_x,s_y);
              LCD_WriteData(color>>8,color);
    }
    return;
    }
    if(Offset_x > Offset_y)
    {
        Offset_k += Offset_y;
        while(s_x != e_x)
        {
          if(Offset_k>0)
          {
               s_y += 1;
            Offset_k += (Offset_y-Offset_x);
      }
      else Offset_k += Offset_y; 
          s_x += Err_d;
      if(s_x > Dis_X_MAX||s_y > Dis_Y_MAX) break;
          LCD_SetCursor(s_x,s_y);
        LCD_WriteData(color>>8 ,color);
    }    
    }
    else
    {
    Offset_k += Offset_x;
    while(s_y != e_y)
    {
      if(Offset_k > 0)
      {
        s_x += Err_d;
        Offset_k += (Offset_x-Offset_y);
      }
      else Offset_k += Offset_x;
      s_y += 1;
      if(s_x > Dis_X_MAX||s_y > Dis_Y_MAX) break;
      LCD_SetCursor(s_x,s_y);
      LCD_WriteData(color>>8, color);
    }
    }    
}


/*******************************************************************************
* Function Name  : LCD_Rectangle
* Description    : 画一个矩形(mode = 0) or 矩形面(mode = 1)
* Input          : left - 矩形的左上角横坐标,范围0到118
*         top - 矩形的左上角纵坐标,范围0到50
*         right - 矩形的右下角横坐标,范围1到119
*         bottom - 矩形的右下角纵坐标,范围1到51
*         Mode - 绘制模式,可以是下列数值之一:
*                0:    矩形框(空心矩形)
*                1:    矩形面(实心矩形)
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_Rectangle(unsigned int left, unsigned int  top, 
                   unsigned int right, unsigned int bottom, 
                   unsigned char Mode,unsigned int color)
{
  unsigned int uiTemp;
  if(Mode==0)
  {
    LCD_Line(left,top,left,bottom,color);
    LCD_Line(left,top,right,top,color);
    LCD_Line(right,bottom,left,bottom,color);
    LCD_Line(right,bottom,right,top,color);
  }
  else
  {
    if(left>right)
    {
      uiTemp = left;
      left = right;
      right = uiTemp;
    }
    if(top>bottom)
    {
      uiTemp = top;
      top = bottom;
      bottom = uiTemp;
    }
    for(uiTemp=top;uiTemp<=bottom;uiTemp++)
    {
      LCD_Line(left,uiTemp,right,uiTemp,color);
    }
  }
}

void LCD_Point(uint16 Xpos, uint16 Ypos, uint16 color) 
{
    if ( (Xpos>320)||(Ypos>240) ) return;
    LCD_SetCursor(Xpos, Ypos);
    LCD_WriteData(color>>8, color);
}

/****************************************************************************
* 名    称:void LCD_PutChar(u16 x,u16 y,u8 c,u16 charColor,u16 bkColor)
* 功    能:在指定座标显示一个8x16点阵的ascii字符
* 入口参数:x          行座标
*           y          列座标
*           charColor  字符的颜色
*           bkColor    字符背景颜色
* 出口参数:无
* 说    明:显示范围限定为可显示的ascii码
* 调用方法:LCD_DrawChar(10,10,'a',0x0000,0xffff);
****************************************************************************/
void LCD_DrawChar(uint16 x,uint16 y,uint8 c,uint16 color,uint16 bgcolor)
{
  uint16 i=0;
  uint16 j=0;
  
  uint8 tmp_char=0;

  for (i=0; i<16 ;i++)
  {
    tmp_char = Ascii_8x16[((c-0x20)*16)+i];       /* 相对位置转换 */
    for (j=0 ; j<8 ;j++)
    {
      if ( (tmp_char >> 7-j) & 0x01 == 0x01)
        {
          LCD_Point(x+j ,y+i ,color); // 字符颜色
        }
        else
        {
          LCD_Point(x+j ,y+i ,bgcolor);  // 背景颜色
        }
    }
  }
} 


/*******************************************************************************
*    函数名: LCD_DisplayStr
*    参  数:
*        Xpos : X坐标);
*        Ypos : Y坐标)
*        Ascii : 字符的ASCII代码,在0x20和0x7E之间
*    返  回: 无
*    功  能: 在LCD上显示一个字符(8x16)
*/

void LCD_DisplayStr(uint16 x,uint16 y,unsigned char *str,uint16 dcolor,uint16 bgcolor)      
{  
    uint16 Xpos,Ypos;
    Xpos = x;
    Ypos = y;
    while(*str != '\0')
    {    
        LCD_DrawChar(Xpos,Ypos,*str,dcolor,bgcolor);
        Xpos += 7;
        str++;
    }    
}

/*******************************************************************************
*    函数名: LCD_DisplayChinese
*    参  数:
*        Xpos : X坐标);
*        Ypos : Y坐标)
*        Ascii : 字符的ASCII代码,在0x20和0x7E之间
*    返  回: 无
*    功  能: 在LCD上显示一个字符(8x16)
*/
/*
void LCD_DisplayChinese(uint16 Xpos, uint16 Ypos, uchar* pData, uint16 textColor, uint16 backColor)
{
    uchar i,j,b;
    
    LCD_SetWindow(Xpos, Ypos, Xpos+15, Ypos+15);
    for(j=0;j<32;j++)
    {
        b=*(pData+j);
        for(i=0;i<8;i++)
        {
            if(b&0x80)
            {
                LCD_WriteData(textColor>>8, textColor);    
            }
            else
            {
                LCD_WriteData(backColor>>8, backColor);
            }
            b=b<<1;            
        }    
    }
    LCD_SetWindow(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1);
}
*/
/*******************************************************************************
*    函数名: LCD_DisplayChineseBig
*    参  数:
*        Xpos : X坐标);
*        Ypos : Y坐标)
*        Ascii : 字符的ASCII代码,在0x20和0x7E之间
*    返  回: 无
*    功  能: 在LCD上显示一个字符(8x16)
*/
/*
void LCD_DisplayChineseBig(uint16 Xpos, uint16 Ypos, uchar* pData, uint16 textColor, uint16 backColor)
{
    uchar i,j,b;
    
    LCD_SetWindow(Xpos, Ypos, Xpos+23, Ypos+23);
    for(j=0;j < 72;j++)
    {
        b=*(pData+j);
        for(i=0;i<8;i++)
        {
            if(b&0x80)
            {
                LCD_WriteData(textColor>>8, textColor);    
            }
            else
            {
                LCD_WriteData(backColor>>8, backColor);
            }
            b=b<<1;            
        }    
    }
    LCD_SetWindow(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1);
}
*/

下面是lcd.h是上面的头文件:

#ifndef _LCD_H_
#define _LCD_H_

/*包含头文件*/
#include <reg51.h>
/* 单片机相关的数据类型 */
#define uint16  unsigned int 
#define int16   int 
#define uint8   unsigned char
#define uint32  unsigned long
#define int32   long
#define uchar   unsigned char

/*管脚定义,与使用平台相关,移植修改部分*/

#define  LCD_DataPortH P0    //高8位数据口,8位模式下只使用高8位 
sbit LCD_CS=P2^3;             //片选    
sbit LCD_RS = P2^0;           //数据/命令切换
sbit LCD_WR = P2^1;             //写控制
sbit LCD_RD =P2^2;             //读控制
sbit LCD_RST = P2^5;         //复位   

/*与TFT彩屏相关的参数,即彩屏的分辨率*/
#define Dis_Y_MAX                       320                                      
#define Dis_X_MAX                       240

/********************************************************************
    defination of hardware
*********************************************************************/

#define        LCD_CS_L    LCD_CS = 0;     //CS管脚为低
#define        LCD_CS_H    LCD_CS = 1;        //CS管脚为高
#define        LCD_RD_L    LCD_RD = 0;        //RD管脚为低
#define        LCD_RD_H    LCD_RD = 1;        //RD管脚为高
#define     LCD_WR_L    LCD_WR = 0;        //WR管脚为低
#define     LCD_WR_H    LCD_WR = 1;        //WR管脚为高
#define        LCD_RS_L    LCD_RS = 0;        //RS管脚为低
#define        LCD_RS_H    LCD_RS = 1;        //RS管脚为高
#define        LCD_RST_L    LCD_RST = 0;    //RST管脚为低
#define        LCD_RST_H    LCD_RST = 1;    //RST管脚为高

/*******defination of color************/
#define COLOR_TO_MTK_COLOR_SIMUL(color) ((((color) >> 19) & 0x1f) << 11) \
                                            |((((color) >> 10) & 0x3f) << 5) \
                                            |(((color) >> 3) & 0x1f)

/* RGB565格式 */

#define RED         0xf800
#define GREEN         0x07E0
#define BLUE         0x001F
#define WHITE         0xffff
#define PURPLE      0xF81F
#define YELLOW         0xFFE0
#define CYAN        0x07FF
#define BLACK         0x0000

#define LIGHT_BLUE       COLOR_TO_MTK_COLOR_SIMUL(0x93DB70)
#define YELLOW_GREEN     COLOR_TO_MTK_COLOR_SIMUL(0x7FFF00)


#define LCD_WIDTH        240
#define LCD_HEIGHT        320
/*RGB 向RGB565转换,可能会有损失*/
#define RGB(r,g,b) ( (r<<8)&(RED) | ((g<<3)&GREEN) | ((b>>3)&BLUE) )


/* 不精确的延时函数 */
void Delayms(int count) ;
/* 并行数据写入函数,分高低字节写入*/
void LCD_WriteBus(char DataHigh,char DataoLow)  ;
/* 写命令字 */
void LCD_WriteCmd(char DataHigh,char DataoLow)    ;
/* 写数据 */
void LCD_WriteData(char DataHigh,char DataoLow);
/*往指定寄存器写入数据 */
void LCD_WriteReg(unsigned int Register,unsigned int Data);

/* 初始化LCD,写入工作模式相关命令字*/
void LCD_Init(void);
/* 填充屏幕 */
void LCD_FillScreen(uint16 color);

void LCD_SetCursor(unsigned int  x,unsigned int y);
/* 设置绘图坐标窗口,其中(x1,y1)为左上顶点,(x2,y2)为右下顶点 */
void LCD_SetWindow(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2);

void LCD_DrawChar(uint16 x,uint16 y,uint8 c,uint16 color,uint16 bgcolor);
//void LCD_WriteBMP(const unsigned int *ptr);
void LCD_DisplayStr(uint16 x,uint16 y,unsigned char *str,uint16 dcolor,uint16 bgcolor);
//void LCD_DisplayChinese(uint16 Xpos, uint16 Ypos, uchar* pData, uint16 textColor, uint16 backColor);
//void LCD_DisplayChineseBig(uint16 Xpos, uint16 Ypos, uchar* pData, uint16 textColor, uint16 backColor);

void LCD_Line(unsigned int  s_x, unsigned int s_y, unsigned int e_x, unsigned int e_y, unsigned int color);
void LCD_Rectangle(unsigned int left, unsigned int  top, 
                   unsigned int right, unsigned int bottom, 
                   unsigned char Mode,unsigned int color);

//void LCD_Circle(unsigned int  x, unsigned int y, unsigned int r, unsigned char mode, unsigned int color);
#endif

下面是key.c红外键盘的驱动程序,采用的是中断方式:

#include "key.h"
#include <reg52.h>

#define uchar unsigned char    
#define uint  unsigned int 

#define c(x) (x*120000/120000) 

sbit    IR   = P3^2;           //遥控接头接口    
sbit     beep   = P3^5;        //蜂鸣器接口

uchar    Data[4];            //识别码,操作码存放,Data[0] 为识别码,Data[2]为操作码

/*************这个Key全局变量很重要,他是系统中断中获取的键值************/
uchar   key = 0;

void delay_50ms(unsigned int t)
{
    unsigned int j;   
    for(;t>0;t--) 
      for(j=6245;j>0;j--) 
        {;}
}

void Beep()
{
      beep = 0;
      delay_50ms(2);
      beep = 1;
}

/********************** 外部中断函数************************/
void exint0() interrupt 0 
{      
   uint cnt;
   uchar i;

   EX0 = 0;
   cnt = 0;    
    
   while(!IR) cnt++;                               //记录引导码时间 
   if(cnt < 1000)
   {
       EX0=1;return;
   }                   //9ms的计数值(12MHz:1000< cnt <1500)
       
   cnt = 0;             
   while(IR) if(cnt++ > 400)
               {
                EX0=1;return;
            }        //防卡死,超时保护(12MHz: > 300)    
   if(cnt < 200)
               {
                EX0=1;return;
            }                    //(12MHz不分频: <260)        

   for(i=0; i<32; i++)                             //读取32位位码
       {
         cnt = 0;                                                                        
         while(!IR);               
         while(IR) if(cnt++ > 200)
                    {
                       EX0=1;return;
                   }  //超时保护(12MHz:>=200)
         Data[i/8] >>= 1;
         if(cnt>60) 
                   Data[i/8] |= 0x80;                            //0和1的计数界线(12MHz:< 109)    
       }

       if(Data[0] == ~Data[1] && Data[2] == ~Data[3])            //校验识别码,操作码    
       {
            key = Data[2];
       }

    Beep();
    EX0 = 1;         
} 

下面是key.h头文件:

#ifndef _KEY_H_
#define _KEY_H_
void Beep();
#endif

下面是贪吃蛇源文件snake.c

#include "lcd.h"
#include "key.h"
#include "snake.h"
#include <stdio.h>
#include <stdlib.h>



extern uchar key;

Food food;
Snake snake;
int score = 0; 



/*******************************************************************************
* Function Name  : ShowStartMenu
* Description    : 绘制游戏开始界面 
* Input          : None
* Output         : None
* Return         : None
* 使用前景色
*******************************************************************************/
void ShowStartMenu(void)
{
    LCD_FillScreen(BLACK);                  
    LCD_Rectangle(0, 0, LCD_WIDTH-1, 20, 1, CYAN);
    LCD_Rectangle(0,20, LCD_WIDTH-1, 40, 1, BLUE);


    LCD_Rectangle(90, 140, 120, 170, 1, RED);
    LCD_Rectangle(120, 140, 150, 170, 1, YELLOW);
    LCD_Rectangle(90, 170, 120, 200, 1, BLUE);
    LCD_Rectangle(120,170, 150, 200, 1, GREEN);
    

    LCD_DisplayStr(75, 80, "Greedy Sanke", YELLOW_GREEN, BLACK);

    LCD_DisplayStr(50, 220, "Press Key 5 To Start", WHITE, BLACK);
    LCD_Rectangle(0, 280, LCD_WIDTH-1, 300, 1, BLUE);
    LCD_Rectangle(0, 300, LCD_WIDTH-1, LCD_HEIGHT-1, 1, CYAN);
}

/* 绘制游戏进行的主界面 */
void ShowGameWindow(void ) 
{
    char i = 0;
    
    
    /*清除上面的屏幕*/
    LCD_FillScreen(BLACK);
    /*游戏主界面绘制*/
    LCD_Rectangle(0, 0, LCD_WIDTH, 5,1 ,BLUE);
    LCD_Rectangle(0, LCD_HEIGHT, LCD_WIDTH-1, LCD_HEIGHT-5, 1, BLUE);
    LCD_Rectangle(0, 5, 5, LCD_HEIGHT-5, 1, BLUE);
    LCD_Rectangle(LCD_WIDTH-5, 5, LCD_WIDTH, LCD_HEIGHT-5,    1, BLUE);

    LCD_Rectangle(5, 5, LCD_WIDTH-5, 10,1, CYAN);
    LCD_Rectangle(5, LCD_HEIGHT-5, LCD_WIDTH-5, LCD_HEIGHT-10, 1, CYAN);
    LCD_Rectangle(5, 10, 10, LCD_HEIGHT-10, 1, CYAN);
    LCD_Rectangle(LCD_WIDTH-10, 10, LCD_WIDTH-5, LCD_HEIGHT-10, 1, CYAN);

    LCD_Line(10, 30, 230, 30, RED);
    LCD_Line(90, 10, 90, 30,  RED);
    LCD_Line(160, 10, 160, 30 ,RED);


    LCD_DisplayStr(15,12, "SCORE:", PURPLE, BLACK);
    LCD_DisplayStr(100,12, "GRADE:", PURPLE, BLACK);
    LCD_DisplayStr(170,12, "ABOUT", PURPLE, BLACK);
    LCD_DisplayStr(63,12,"0",YELLOW_GREEN, BLACK);
    LCD_DisplayStr(100+8*6,12,"0", YELLOW_GREEN, BLACK);

    LCD_DisplayStr(50, 180, "Press Key 5 To Start", WHITE, BLACK);
    LCD_DisplayStr(50, 200, "Press Key 0 To Escape", WHITE, BLACK);
    LCD_DisplayStr(50, 220, "Press Key 9 To About", WHITE,BLACK);
}


void GamePlay() 
{    
    int i;

    char Status = 0;    //游戏运行状态,0为暂停1为运行
    unsigned char prevKey = START;    /*前一个被按下的按键*/
    
    food.yes=1;                        /*1代表要出现食物,0表示以存在食物*/ 
    snake.life=0; 
    snake.direction = 1;            /* 开始的方向,向右移动 */ 
    snake.x[0]=100;snake.y[0]=100; 
    snake.x[1]=110;snake.y[1]=100; 
    snake.node = 2; 

    Status = 1;

    PrintScore(); 
    while(1) /*可以重复游戏*/ 
    { 
        while((key == prevKey) && (Status == 1)) /*在没有按键的情况下蛇自己移动*/ 
        { 
            prevKey = key;
            if(food.yes == 1) /*需要食物*/ 
            { 
                food.x = rand()%200+20; 
                food.y = rand()%200+80; /*使用rand函数随机产生食物坐标*/ 
                while(food.x%10!= 0) 
                food.x++; 
                while(food.y%10!=0) 
                food.y++; /*判断食物是否出现在整格里*/ 
                food.yes=0; /*现在有食物了*/ 
            } 
            if(food.yes == 0) /*有食物了就要显示出来*/ 
            { 
                LCD_Rectangle(food.x, food.y, food.x+10, food.y-10,1, RED);
            } 
            for(i = snake.node-1; i>0; i--) /*贪吃蛇的移动算法*/ 
            { 
                snake.x[i]=snake.x[i-1]; 
                snake.y[i]=snake.y[i-1]; /*贪吃蛇的身体移动算法*/ 
            }

            switch(snake.direction) /*贪吃蛇的头部移动算法,以此来控制移动*/ 
            { 
                case 1:snake.x[0] += 10;break; 
                case 2:snake.x[0] -= 10;break; 
                case 3:snake.y[0] -= 10;break; 
                case 4:snake.y[0] += 10;break; 
            } 
            for(i=3; i<snake.node; i++) /*判断是否头部与身体相撞*/ 
            { 
                if(snake.x[i]==snake.x[0]&&snake.y[i]==snake.y[0]) 
                { 
                    GameOver(); 
                    snake.life=1; 
                    break; 
                } 
            } 
            /*下面是判断是否撞到墙壁*/ 
            if(snake.x[0]<10 || snake.x[0]>230 || snake.y[0]< 30 || snake.y[0]> 310) 
            { 
                GameOver(); 
                snake.life=1; 
            } 
            if(1 == snake.life) /*如果死亡就退出循环*/ 
                break; 
            if(snake.x[0]==food.x && snake.y[0]==food.y) /*判断蛇是否吃到食物*/ 
            { 
                
                LCD_Rectangle(food.x, food.y, food.x+10, food.y-10, 1, BLACK);
                snake.x[snake.node]=-20;snake.y[snake.node]=-20; /*现把增加的一节放到看不到的地方去*/

                snake.node++; 
                food.yes=1; 
                score+=10; 
                PrintScore(); 
            } 
            
            /*绘制贪吃蛇*/
             for(i=0; i<snake.node; i++) 
             {
                 LCD_Rectangle(snake.x[i], snake.y[i], snake.x[i]+10, snake.y[i]-10, 1, YELLOW);
             }

            DelayGameSpeed();
            /*擦掉最后一个方块 */
            LCD_Rectangle(snake.x[snake.node-1],snake.y[snake.node-1],snake.x[snake.node-1]+10,snake.y[snake.node-1]-10, 1, BLACK);

        } 
                  
            if(snake.life == 1)
                 break;     //退出游戏
            else if( key == ESC) 
                    break;  //退出游戏
            else if (key == START)
            {
                Status ^= 0x01;
                
                prevKey = key;
            }
            else if(key == ABOUT)
            {
                AboutGame();
            }
            else if((key==UP) && (snake.direction!=4))
            {
                snake.direction = 3; prevKey = key; 
            }
            else if( (key==RIGHT) && (snake.direction!=2)) 
            {
                snake.direction = 1;  prevKey = key; 
            }
            else if( (key==LEFT) && (snake.direction!=1))     
            {    
                snake.direction = 2; prevKey = key;
            }
            else if( (key==DOWN) && (snake.direction!=3)) 
            {
                snake.direction = 4; prevKey = key;
            }
         
    }
}

/*输出游戏的成绩*/
void PrintScore()
{
     int qian,bai,shi;
     char i = 0;
     qian = score/1000;
     bai = (score%1000)/100;
     shi = (score%100)/10;
     if(qian)    
     {    
         LCD_DrawChar(63,12, qian+48, YELLOW, BLACK);
        i++;    
     };
     if(bai)
     {        
         LCD_DrawChar(63+8*i,12, bai+48, YELLOW, BLACK);
        i++;
     }
     if(shi)        
     {    
         LCD_DrawChar(63+8*i,12, shi+48, YELLOW, BLACK);
        i++;
     }
     LCD_DrawChar(63+8*i,12,'0', YELLOW, BLACK);
}
/* 游戏结束 */
void GameOver() 
{     
     int qian,bai,shi;
     qian = score/1000;
     bai = (score%1000)/100;
     shi = (score%100)/10;

     LCD_FillScreen(BLACK);
     LCD_DisplayStr(100,120,"Game Over", RED, BLACK);
     LCD_DisplayStr(100, 140, "Final Score", RED, BLACK);
                           
     if(qian)        LCD_DrawChar(100,160, qian+48, YELLOW, BLACK);
     if(bai)        LCD_DrawChar(100+8,160, bai+48, YELLOW, BLACK);
     if(shi)        LCD_DrawChar(100+8*2,160, shi+48, YELLOW, BLACK);
     LCD_DrawChar(100+8*3,160,'0', YELLOW, BLACK);

     while( key != ESC)
     {
     }
     LCD_FillScreen(LIGHT_BLUE);
}

void DelayGameSpeed()
{
    Delayms(10*(100-5*(score/10)));
}

void AboutGame()
{
    LCD_FillScreen(BLACK);

    LCD_DisplayStr(20,30, "Greedy Snake Version 1.0", PURPLE, BLACK);

    LCD_Line(20,50,220,50, YELLOW);
    LCD_DisplayStr(20,60, "How To Play ?", BLUE, BLACK);
    LCD_DisplayStr(50,80, "Press Key 2 Upwords", CYAN, BLACK);
    LCD_DisplayStr(50,100, "Press Key 8 Downwords", CYAN, BLACK);
    LCD_DisplayStr(50,120, "Press Key 4 Left", CYAN, BLACK);
    LCD_DisplayStr(50,140, "Press Key 6 Left", CYAN, BLACK);

    LCD_Line(20,160,220, 160, YELLOW)    ;
    LCD_DisplayStr(20,170, "Aout This Game:", BLUE, BLACK);
    LCD_DisplayStr(50,190, "Author: FangYing", CYAN, BLACK);
    LCD_DisplayStr(50,210, "NEU EE 0903 ",CYAN, BLACK);
    LCD_DisplayStr(50,230, "QQ: 791429438 ",CYAN, BLACK);    

    while(key != START)
    {
    }
    
}

下面是snake.h

#ifndef _SNAKE_H_
#define _SNAKE_H_

#define N 20   /* 定义蛇的最大长度 */

#define ESC     0x16
#define UP         0x18
#define DOWN     0x52
#define RIGHT   0x5A
#define LEFT    0x08
#define START   0x1C
#define ABOUT   0x4A

typedef struct Food /*食物的结构体*/ 
{ 
int x; /*食物的横坐标*/ 
int y; /*食物的纵坐标*/ 
char yes; /*食物是否出现的变量*/ 
}Food; 

typedef struct Snack /*蛇的结构体*/ 
{ 
    int x[N]; 
    int y[N]; 
    int node; /*蛇的节数*/ 
    int direction; /*蛇的方向*/ 
    int life; /*蛇的生命,0活着,1死亡*/ 
}Snake; 

void ShowStartMenu(void);
void ShowGameWindow(void );
void GamePlay();
void PrintScore();
void GameOver();
void DelayGameSpeed();
void AboutGame();

#endif

最后是游戏的主程序:

#include "lcd.h"
#include "snake.h"
#include "key.h"
#include <reg51.h>

extern uchar key;

void InterruptInit() 
{
  /*初始化中断,使用中断中读取红外线键值*/
  IT0 = 1; 
  EX0 = 1;
  EA  = 1;

}

void main()
{ 
 
       LCD_Init();
    LCD_FillScreen(BLACK);
   
    InterruptInit();
    start:
    ShowStartMenu();
    
     while(1) 
     {     
        if( key == START)
        {
            key = 0;
            break;
        }
     }
     
     LCD_Init();
     LCD_FillScreen(BLACK);
     ShowGameWindow();
     while(1)
     {
     
        if( key == START)
        {
            LCD_DisplayStr(50, 180, "                      ", BLACK, BLACK);
            LCD_DisplayStr(50, 200, "                      ", BLACK, BLACK);
            LCD_DisplayStr(50, 220, "                      ", BLACK, BLACK);
            break;
        }
        else if(key == ABOUT)
        {
             AboutGame();
        }
     }
     GamePlay();

}            

 

 差点忘了还有Ascii_8x16的文件,这个是8x16的ASCII码头文件:

#ifndef _FONTS_ASCII_8x16_H_
#define _FONTS_ASCII_8x16_H_

unsigned char code Ascii_8x16[]=       
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x66,0x66,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x6C,0x6C,0xFE,0x6C,0x6C,0x6C,0xFE,0x6C,0x6C,0x00,0x00,0x00,0x00,
0x18,0x18,0x7C,0xC6,0xC2,0xC0,0x7C,0x06,0x86,0xC6,0x7C,0x18,0x18,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xC2,0xC6,0x0C,0x18,0x30,0x60,0xC6,0x86,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x6C,0x6C,0x38,0x76,0xDC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,
0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0C,0x18,0x30,0x30,0x30,0x30,0x30,0x30,0x18,0x0C,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0x18,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x18,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x30,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0xCE,0xD6,0xD6,0xE6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x38,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0x06,0x0C,0x18,0x30,0x60,0xC0,0xC6,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0x06,0x06,0x3C,0x06,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x0C,0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00,
0x00,0x00,0xFE,0xC0,0xC0,0xC0,0xFC,0x0E,0x06,0x06,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x60,0xC0,0xC0,0xFC,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0xFE,0xC6,0x06,0x06,0x0C,0x18,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7C,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0xC6,0x7E,0x06,0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x30,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x06,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x60,0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x60,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0x0C,0x18,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7C,0xC6,0xC6,0xDE,0xDE,0xDE,0xDC,0xC0,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x66,0x66,0x66,0x66,0xFC,0x00,0x00,0x00,0x00,
0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xC0,0xC0,0xC2,0x66,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0xF8,0x6C,0x66,0x66,0x66,0x66,0x66,0x66,0x6C,0xF8,0x00,0x00,0x00,0x00,
0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0xFE,0x66,0x62,0x68,0x78,0x68,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x3C,0x66,0xC2,0xC0,0xC0,0xDE,0xC6,0xC6,0x66,0x3A,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xFE,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0x3C,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x1E,0x0C,0x0C,0x0C,0x0C,0x0C,0xCC,0xCC,0xCC,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0xE6,0x66,0x6C,0x6C,0x78,0x78,0x6C,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x60,0x60,0x60,0x60,0x60,0x60,0x62,0x66,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xEE,0xFE,0xFE,0xD6,0xC6,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xE6,0xF6,0xFE,0xDE,0xCE,0xC6,0xC6,0xC6,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x6C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x6C,0x38,0x00,0x00,0x00,0x00,
0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x60,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xD6,0xDE,0x7C,0x0C,0x0E,0x00,0x00,
0x00,0x00,0xFC,0x66,0x66,0x66,0x7C,0x6C,0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,
0x00,0x00,0x7C,0xC6,0xC6,0x60,0x38,0x0C,0x06,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x7E,0x7E,0x5A,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x6C,0x38,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xD6,0xD6,0xFE,0x6C,0x6C,0x00,0x00,0x00,0x00,
0x00,0x00,0xC6,0xC6,0x6C,0x6C,0x38,0x38,0x6C,0x6C,0xC6,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0x66,0x66,0x66,0x66,0x3C,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0xFE,0xC6,0x86,0x0C,0x18,0x30,0x60,0xC2,0xC6,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x3C,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0xC0,0xE0,0x70,0x38,0x1C,0x0E,0x06,0x02,0x00,0x00,0x00,0x00,
0x00,0x00,0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00,0x00,0x00,0x00,
0x10,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,
0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x78,0x0C,0x7C,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0xE0,0x60,0x60,0x78,0x6C,0x66,0x66,0x66,0x66,0xDC,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC0,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x1C,0x0C,0x0C,0x3C,0x6C,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xFE,0xC0,0xC0,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x6C,0x64,0x60,0xF0,0x60,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0xCC,0xCC,0x7C,0x0C,0xCC,0x78,0x00,
0x00,0x00,0xE0,0x60,0x60,0x6C,0x76,0x66,0x66,0x66,0x66,0xE6,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x06,0x06,0x00,0x0E,0x06,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3C,0x00,
0x00,0x00,0xE0,0x60,0x60,0x66,0x6C,0x78,0x78,0x6C,0x66,0xE6,0x00,0x00,0x00,0x00,
0x00,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xEC,0xFE,0xD6,0xD6,0xD6,0xD6,0xD6,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xDC,0x66,0x66,0x66,0x66,0x66,0x7C,0x60,0x60,0xF0,0x00,
0x00,0x00,0x00,0x00,0x00,0x76,0xCC,0xCC,0xCC,0xCC,0xCC,0x7C,0x0C,0x0C,0x1E,0x00,
0x00,0x00,0x00,0x00,0x00,0xDC,0x76,0x62,0x60,0x60,0x60,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0xC6,0x60,0x38,0x0C,0xC6,0x7C,0x00,0x00,0x00,0x00,
0x00,0x00,0x10,0x30,0x30,0xFC,0x30,0x30,0x30,0x30,0x36,0x1C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6,0xD6,0xD6,0xFE,0x6C,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC6,0x6C,0x38,0x38,0x38,0x6C,0xC6,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC6,0xC6,0xC6,0xC6,0xC6,0xC6,0x7E,0x06,0x0C,0xF8,0x00,
0x00,0x00,0x00,0x00,0x00,0xFE,0xCC,0x18,0x30,0x60,0xC6,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x0E,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0x18,0x0E,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x70,0x18,0x18,0x18,0x0E,0x18,0x18,0x18,0x18,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x76,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x38,0x6C,0xC6,0xC6,0xC6,0xFE,0x00,0x00,0x00,0x00,0x00
};
#endif

 

你可能感兴趣的:(贪吃蛇)