资源描述:
《【精品】贪吃蛇课程设计(北华大学吕磊)》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#include#include#include#include#defineN200#defineLEFT0x4b00#defineRIGHT0x4d00#defineDOWN0x5000#defineUP0x4800#defineESC0x01lb#defineFILENAME,,c:\person.datHvoidInitScoreFilesO;voidWeiteFiles(structperson*tmp);intautoplay
2、=0;structperson{charname[20];intscore;}per[5J;intscore=0;intsize;inti,key;intgamespeed=50000;structSnow{intx;inty;intspeed;}snow[1001;intsnownum=0;intchange=10;void*save;structFood{intx;inty;intyes;}food;structSnakeintx[N];inty[NJ;intnode;intdirection;intlife;}snake;intdx=0,dy=0,d=l;voidPr();
3、voidpain_borad();voiddifficult(){randomize();dx=rand()%150+80;dy=rand()%100+70;while(dy%10!=0)dy++;while(dx%10!=0)dx++;}voidDrawSnow(){inti;intsx[62];setlinestyle(SOLID_LINE,0,THICK_WIDTH);lined,1,9,9);line(0,5,10,5);line(9,l,l,9);save=malloc(200);getimage(0,0,10,10,save);cleardevice();random
4、ize();for(i=0;i<62;i++)sx[i]=(i+2)*10;while(!kbhit()){Pr();if(snovvnum!=100){snow[snovnum].speed=2+random(5);i=random(62);snowfsnownuml.x=sxfi];snow[snownum].y=10-random(l00);}for(i=0;i5、num++;setfillstyle(SOLID.FILL,l5);for(i=0;i500)snowfi].y=10-random(200);}change++;if(change==140)change二10;}nosound();cleardevice();}voidPr(){ints[15]={0,100,150,200,250,150,250,300,250,150,100,250
6、,350};setcolor(change/l0);settextstyIe(0,0,4);outtextxy(20,100;*WELCOMETOOURGAME!!“);settextstyle(0,1,4);outtextxy(150,250,n654r,);settextstyle(0,0,2);outtextxy(250J90;,YSn);outtextxy(250,240/YWG”);outtextxy(250,290,uQMJ“);outtextxy(250,340;'WD”);outtextxy(250,390,“NH“);outtextxy(250,440,HNZQ
7、n);sound(s[change/lOJ);}voidGamePlayO{intlevel=l;charbuffer[10J;intfoodx=0,foody=0,foodtime=0»score1=0;score=0;food.yes=l;snake」ife二0;snake.direction=l;snake.xll]=100;snake.yfl]=200;snake.x[0]=l10;snake.y[0]=200;snake.node=2;while(l)while(!kb