//Draw_Point(x,y,1); //清除这个点 //Delayms(5000); //设置断点,用于测试 x=x+16; y=y+18; if(x>127) { x=1; } if(y>63) { y=0; } } }
/*------------------------------------------------------------------------------------------------------------ 判断是否撞边框
-------------------------------------------------------------------------------------------------------------*/ void Bump_Wall() { if((a[0]>127||a[0]<0)||(b[0]<0||b[0]>63)) { TR0=0; ClrScreen(); //Disp_HZ(0x98,hang4,8); LCD_PutString(0,3,\撞墙死亡了\ Write_Score(3,7,allpoints); } }
/*------------------------------------------------------------------------------------------------------------ 判断是否自身相撞
-------------------------------------------------------------------------------------------------------------*/ void Self_Bump() { uchar i,j; for(j=flag-1;j>=3;j--) { if(c[j]==0) { for(i=a[j+1];i
if((a[0]==i)&&(b[0]==b[j])) { TR0=0; ClrScreen(); //Disp_HZ(0x98,hang3,7); LCD_PutString(0,4,\死亡\ Write_Score(3,7,allpoints); } } } else if(c[j]==1) { for(i=b[j+1];i for(i=b[j];i
} }
//Disp_HZ(0x98,hang3,7); LCD_PutString(0,4,\死亡\ Write_Score(3,7,allpoints); } }
#include
#include \
/*--------------------------------------------------------------------------------------------------------------------------- 声明全局变量,不能赋值,只是声明;本函数中用时会去其他函数(那个函数已对他进行了定义并赋了初值)中找,
----------------------------------------------------------------------------------------------------------------------------*/
extern uchar a[]; extern uchar b[]; extern uchar c[]; extern uchar flag; extern uint timestatus;
/*--------------------------------------------------------------------------------------------------- 主程序
----------------------------------------------------------------------------------------------------*/ void main(void) { WELA=0; DULA=0; Init_IO(); Init_12864(); Init_Time(); ClrScreen(); Clr_GDRAM(); while(1) { Keyscan(); statuschange(); if(timestatus==10) { timestatus=0; Add_Point(); //显示食物,若吃到,则更新首点坐标,并重新放置食物 Stat_Point(); //首点坐标更新 Draw_Point(a[0],b[0],0); //加上首点,即第一次画的点
Bump_Wall(); Draw_Point(a[flag],b[flag],1); //去掉尾点,即第一次画的点 Last_Point(); //尾点坐标更新 Self_Bump(); }
if(speed==0) { if(timestatus==2) { timestatus=0; Add_Point(); 并重新放置食物 Stat_Point(); Draw_Point(a[0],b[0],0); Bump_Wall(); Draw_Point(a[flag],b[flag],1); Last_Point(); Self_Bump(); } } Draw_all_lines(); } }
//显示食物,若吃到,则更新首点坐标,//首点坐标更新 //加上首点,即第一次画的点 //去掉尾点,即第一次画的点 //尾点坐标更新