#include #include #include #include #define len 20
#define wid 20
coord food;//食物全域性變數
int x=2,y=1;//起始座標
int a[wid][len];
int score = 1;//體長
typedef struct nodenode;//身體節點
struct node *h;
void rbody()//record body
q=p->pro;
p->pro=null;
pos(p->a,p->b);
printf(" ");
free(p);
q->next=null;
}}int eatbody()//eat body若返回4則遊戲結束
t=t->next;
}return 0;
}int mkey()
void pos(int x,int y)
int mmove()//移動函式如果返回1則撞牆
if(yor(x,y)==1)
if(x==food.x && y==food.y)
if(eatbody()==4)
}}void automove(int n)
else if(n==2)
else if(n==4)
else if(n==6)
}void mmap()
for(i=0;i
for(i=0;i
if(a[j][i]==1)
else if(a[j][i]==0)}}
}int yor(int x,int y)//yes和or的合稱 目的是判斷是否繼續遊戲
void ffood()//產生食物的座標
int main()
C 貪吃蛇程式
方向控制表 dirdirect dir 行進方向 可轉的方向0上 左右1下左右 2左上下3 右上下 include include include include include include include using namespace std int s 12,d 12,hard 3 dir...
C語言貪吃蛇
include include include include include include define screen width 40 遊戲螢幕寬度 define screen length 15 遊戲螢幕長度 define start x 16 螢幕起始x座標 define start y ...
C語言 貪吃蛇
include include include define framewidght 22 define frameheight 22 short generaterandnumber short a,short b void posconsolecursor short x,short y voi...