【AI聊天源码】【亚博源码出售】【手游源码0】c贪吃蛇源码_贪吃蛇源代码python
1.å¦ä½ç¨Cè¯è¨åè´ªåè
2.求c语言控制面板贪吃蛇源代码
3.C语言贪吃蛇游戏代码
4.ç¨cè¯è¨åè´ªåè
5.c语言贪吃蛇代码
6.贪吃蛇c语言源代码
å¦ä½ç¨Cè¯è¨åè´ªåè
#include<conio.h> #include<graphics.h> #include<time.h> #include<string.h> #include<malloc.h> #include<stdio.h> int grade=5,贪贪吃AI聊天源码point=0,life=3; void set(),menu(),move_head(),move_body(),move(),init_insect(),left(),upon(),right(),down(),init_graph(),food_f(),ahead(),crate(); struct bug { int x; int y; struct bug *last; struct bug *next; }; struct fd { int x; int y; int judge; }food={ 0,0,0}; struct bug *head_f=NULL,*head_l,*p1=NULL,*p2=NULL; void main() { char ch; initgraph(,); set(); init_insect(); while(1) { food_f(); Sleep(grade*); setcolor(BLACK); circle(head_l->x,head_l->y,2); setcolor(WHITE); move_body(); if(kbhit()) { ch=getch(); if(ch==) { ahead(); set(); } else if(ch==-) { switch(getch()) { case :upon();break; case :down();break; case :left();break; case :right();break; } } else ahead(); } else { ahead(); } if(head_f->x==food.x&&head_f->y==food.y) { Sleep(); crate(); food.judge=0; point=point+(6-grade)*; if(food.x<||food.y<||food.x>||food.y>) life++; menu(); } if(head_f->x<5||head_f->x>||head_f->y<5||head_f->y>) { Sleep(); life--; food.judge=0; init_graph(); init_insect(); menu(); } for(p1=head_f->next;p1!=NULL;p1=p1->next) { if(head_f->x==p1->x&&head_f->y==p1->y) { Sleep(); life--; food.judge=0; init_graph(); init_insect(); menu(); break; } } if(life==0) { outtextxy(,,"游æç»æï¼"); getch(); return; } move(); }; } void init_graph() { clearviewport(); setlinestyle(PS_SOLID,1,5); rectangle(2,2,,); setlinestyle(PS_SOLID,1,1); } void set() { init_graph(); outtextxy(,,"1ãå¼å§ / è¿å"); outtextxy(,,"2ãéåº"); outtextxy(,,"3ãé¾åº¦"); outtextxy(,,"4ãéæ°å¼å§"); switch(getch()) { case '1': menu();setcolor(GREEN);circle(food.x,food.y,2);setcolor(WHITE);return; case '2': exit(0);break; case '3': outtextxy(,,"ï¼1 2 3 4 5");grade=getch()-;set();break; case '4': food.judge=0,grade=5;point=0;life=3;init_insect();menu();break; default: outtextxy(,,"è¾å ¥é误ï¼"); set();break; } } void menu() { char str[],str1[]={ "åæ°ï¼"},str2[]={ "é¾åº¦ï¼"},str3[]={ "çå½å¼ï¼"}; init_graph(); sprintf(str,"%d",point); strcat(str1,str); outtextxy(,,str1); sprintf(str,"%d",grade); strcat(str2,str); outtextxy(,,str2); sprintf(str,"%d",life); strcat(str3,str); outtextxy(,,str3); outtextxy(,,"设置ï¼ESC"); } void init_insect() { head_f=(struct bug *)malloc(sizeof(struct bug)); head_f->last=NULL; head_f->x=; head_f->y=; p2=head_f->next=p1=(struct bug *)malloc(sizeof(struct bug)); p1->last=head_f; p1->x=; p1->y=; p1=p1->next=(struct bug *)malloc(sizeof(struct bug)); p1->next=NULL; p1->x=; p1->y=; p1->last=p2; head_l=p1; } void move() { for(p1=head_f;p1!=NULL;p1=p1->next) { circle(p1->x,p1->y,2); } } void move_head() { } void move_body() { for(p1=head_l,p2=p1->last;p2!=NULL;p1=p2,p2=p2->last) { p1->x=p2->x; p1->y=p2->y; } } void ahead() { p1=head_f; p2=p1->next; p2=p2->next; if(p1->x==p2->x) { if(p1->y>p2->y) head_f->y+=5; else head_f->y-=5; } else { if(p1->x>p2->x) { head_f->x+=5; } else head_f->x-=5; } } void upon() { p1=head_f->next; p1=p1->next; head_f->y-=5; if(p1->x==head_f->x&&p1->y==head_f->y) { head_f->y+=5; ahead(); } } void down() { p1=head_f->next; p1=p1->next; head_f->y+=5; if(p1->x==head_f->x&&p1->y==head_f->y) { head_f->y-=5; ahead(); } } void left() { p1=head_f->next; p1=p1->next; head_f->x-=5; if(p1->x==head_f->x&&p1->y==head_f->y) { head_f->x+=5; ahead(); } } void right() { p1=head_f->next; p1=p1->next; head_f->x+=5; if(p1->x==head_f->x&&p1->y==head_f->y) { head_f->x-=5; ahead(); } } void food_f() { if(!food.judge) { food.x=(rand()%+1)*5; food.y=(rand()%+1)*5; food.judge=1; if(food.x<||food.y<||food.x>||food.y>) { setcolor(RED); circle(f
求c语言控制面板贪吃蛇源代码
//