资源描述:
《贪吃蛇游戏c语言源代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Ì°³ÔÉßÓÎÏ·cÓïÑÔÔ´´úÂë.txtÊÀÉÏ×îÕä¹óµÄ²»ÊÇÓÀÔ¶µÃ²»µ½»òÒѾµÃµ½µÄ£¬¶øÊÇÄãÒѾµÃµ½²¢ÇÒËæʱ¶¼ÓпÉÄÜʧȥµÄ¶«Î÷£¡°®ÇéÊǵƣ¬ÓÑÇéÊÇÓ°×Ó¡£µÆÃðʱ£¬Äã»á·¢ÏÖÖÜΧ¶¼ÊÇÓ°×Ó¡£ÅóÓÑ£¬ÊÇÔÚ×îºó¿ÉÒÔ¸øÄãÁ¦Á¿µÄÈË¡£#include#include#include#include#incl
2、ude#defineEnter7181#defineESC283#defineUP18432#defineDOWN20480#defineLEFT19200#defineRIGHT19712#ifdef__cplusplus#define__CPPARGS...#else#define__CPPARGS#endifvoidinterrupt(*oldhandler)(__CPPARGS);voidinterruptnewhandler(__CPPARGS);voidSetTimer(voidinterr
3、upt(*IntProc)(__CPPARGS));voidKillTimer(void);voidInitgra(void);voidTheFirstBlock(void);voidDrawMap(void);voidInitsnake(void);voidInitfood(void);voidSnake_Headmv(void);voidFlag(int,int,int,int);voidGameOver(void);voidSnake_Bodymv(void);voidSnake_Bodyadd(void);voi
4、dPrntScore(void);voidTimer(void);voidWin(void);voidTheSecondBlock(void);voidFood(void);voidDsnkorfd(int,int,int);voidDelay(int);structSnake{intx;inty;intcolor;}Snk[12];structFood{intx;inty;intcolor;}Fd;intflag1=1,flag2=0,flag3=0,flag4=0,flag5=0,flag6=0,checkx,che
5、cky,num,key=0,Times,Score,Hscore,Snkspeed,TimerCounter,TureorFalse;charSco[2],Time[6];voidmain(){Initgra();SetTimer(newhandler);TheFirstBlock();while(1){DrawMap();Snake_Headmv();GameOver();Snake_Bodymv();Snake_Bodyadd();PrntScore();Timer();Win();if(key==ESC)break
6、;if(key==Enter){cleardevice();TheFirstBlock();}TheSecondBlock();Food();Delay(Snkspeed);}closegraph();KillTimer();}voidinterruptnewhandler(__CPPARGS){TimerCounter++;oldhandler();}voidSetTimer(voidinterrupt(*IntProc)(__CPPARGS)){oldhandler=getvect(0x1c);disable();s
7、etvect(0x1c,IntProc);enable();}voidKillTimer(){disable();setvect(0x1c,oldhandler);enable();}voidInitgra(){intgd=DETECT,gm;initgraph(&gd,&gm,"d:\tc");}voidTheFirstBlock(){setcolor(11);settextstyle(0,0,4);outtextxy(100,220,"TheFirstBlock");loop:key=bioskey(0);if(k
8、ey==Enter){cleardevice();Initsnake();Initfood();Score=0;Hscore=1;Snkspeed=10;num=2;Times=0;key=0;TureorFalse=1;TimerCounter=0;Time[0]='0';Time[1]='0';Time[2]='