--------------------------校验:_____________-----------------------日期:_____________贪吃蛇c语言代码贪吃蛇c语言代码#include<>#include<>#include<>#include<>#defineNULL0#defineUP18432#defineDOWN20480#defineLEFT19200#defineRIGHT19712#defineESC283#defineENTER7181structsnake{intcenterx;intcentery;intnewx;intnewy;structsnake*next;};structsnake*head;intgrade=60;/*控制速度的*******/inta,b;/*背静遮的位置*/void*far1,*far2,*far3,*far4;/*蛇身指针背静遮的指针虫子*/intsize1,size2,size3,size4;/***全局变量**/intch=RIGHT;/**************存按键开始蛇的方向为RIGHT***********/intchy=RIGHT;intflag=0;/*********判断是否退出游戏**************/intcontrol=4;/***********判断上次方向和下次方向不冲突***/intnextshow=1;/*******控制下次蛇身是否显示***************/intscenterx;/***************随即矩形中心坐标***************/intscentery;intsx;/*******在ab未改变前得到他们的值保证随机矩形也不在此出现*******/intsy;/************************蛇身初始化**************************/voidsnakede(){structsnake*p1,*p2;head=p1=p2=(structsnake*)malloc(sizeof(structsnake));p1->centerx=80;p1->newx=80;p1->centery=58;p1->newy=58;p1=(structsnake*)malloc(sizeof(structsnake));p2->next=p1;p1->centerx=58;p1->newx=58;p1->centery=58;p1->newy=58;p1->next=NULL;}/*******************end*******************/e()/*************游戏开始界面,可以选择速度**********/{intkey;intsize;intx=240;inty=300;intf;void*buf;setfillstyle(SOLID_FILL,BLUE);bar(98,100,112,125);setfillstyle(SOLID_FILL,RED);bar(98,112,112,114);setfillstyle(SOLID_FILL,GREEN);bar(100,100,110,125);size=imagesize(98,100,112,125);buf=malloc(size);getimage(98,100,112,125,buf);cleardevice();setfillstyle(SOLID_FILL,BLUE);bar(240,300,390,325);outtextxy(193,310,"speed:");setfillstyle(SOLID_FILL,RED);bar(240,312,390,314);setcolor(YELLOW);outtextxy(240,330,"DOWN");outtextxy(390,330,"UP");outtextxy(240,360,"ENTERtostart...");outtextxy(270,200,"SNAKE");fei(220,220);feiyang(280,220);yang(340,220);putimage(x,y,buf,COPY_PUT);setcolor(RED);rectangle(170,190,410,410);while(1){if(bioskey(1))/********8选择速度部分************/key=bioskey(0);switch(key){caseENTER:f=1;break;caseDOWN:if(x>=240){putimage(x-
贪吃蛇c语言代码 来自淘豆网m.daumloan.com转载请标明出处.