去年五一寫的乙個貪吃蛇遊戲,在tc3下執行成功,過幾天加點注釋~~ 大家先湊和看吧...hoho....
#include
#include
#include
#include
#include
#include
#define vk_esc 0x11b
#define vk_up 0x4800
#define vk_down 0x5000
#define vk_left 0x4b00
#define vk_right 0x4d00
#define timer 0x1c
#ifdef __cplusplus
#define __cppargs ...
#else
#define __cppargs
#endif
int timercounter=0;
typedef struct snakenode,*snakelink;
typedef struct beandef,*beanlink;
void initsnake(snakelink,beanlink);
void showsnake(snakelink,beanlink);
void randbean(beanlink);
void snakedeath(int);
void interrupt ( *oldhandler)(__cppargs);
void interrupt newhandler(__cppargs)
void settimer(void interrupt (*intproc)(__cppargs))
void killtimer()
void main(void)
;settimer(newhandler);
initgraph(&gdriver, &gmode, bgifile);
errorcode = graphresult();
if (errorcode != grok)
setbkcolor(1);
// outtextxy(1,1,"you canceled!! thanks for playing!!");
outtextxy(230,200,"press key to start snake!");
getchar();
setcolor(1);
outtextxy(230,200,"press key to start snake!");
initsnake(snode,&bean);
setcolor(5);
showsnake(snode,&bean);
while(1)
}if (timercounter>2)
}killtimer();
closegraph();
}void initsnake(snakelink snode,beanlink bean)
randbean(bean);
for(i=0;i<15;i++)
setcolor(12);
outtextxy(510,45,"snake v1.0");
setcolor(11);
rectangle(508,43,590,53);
setcolor(6);
outtextxy(485,85,"design by gabriel");
outtextxy(540,100,"bnu");
outtextxy(490,180,"snake length:");
void showsnake(snakelink snode,beanlink bean)
for(i=snode[0].length-1;i>0;i--)
switch(snode[0].di)
if(snode[0].x<=15||snode[0].x>=465||snode[0].y<=15||snode[0].y>=465) snakedeath(1);
for(i=0;ix*10==snode[0].x&&bean->y*10==snode[0].y)
else
for(i=1;i=465||snode[0].y<=15||snode[0].y>=465) snakedeath(1);
setcolor(14);
circle(bean->x*10,bean->y*10,3);
//gotoxy(1,1);printf("<%d,%d><%d,%d>",bean->x,bean->y,snode[0].x,snode[0].y);
setcolor(5);
}void randbean(beanlink bean)
void snakedeath(int death)
killtimer();
getchar();
closegraph();
exit(0);
}
java貪吃蛇原始碼
業務分析 一 找物件 塊 組成貪吃蛇的組成元素和每次隨機生成的塊。cell 貪吃蛇 可以考慮用陣列表示,不單獨設定乙個類 主窗體物件 tcs 二 分析類 cell x y width height image up dpwn left right tcs 各種變數,c 存下次出現的塊 she 存貪吃...
貪吃蛇遊戲(附原始碼)
貪吃蛇遊戲,現在還有很多bug。等待大家挑錯。難度 1最難,500最簡單。吃夠20個食物就可以過關了 呵呵。無聊時候玩玩吧 include include include include const int maxn 100 const int n 20 struct node int map ma...
貪吃蛇遊戲(附原始碼)
貪吃蛇遊戲,現在還有很多bug。等待大家挑錯。難度 1最難,500最簡單。吃夠20個食物就可以過關了 呵呵。無聊時候玩玩吧 include include include include const int maxn 100 const int n 20 struct node int map ma...