C语言简单贪吃蛇游戏代码

上传人:cl****1 文档编号:507370657 上传时间:2023-11-22 格式:DOC 页数:4 大小:16.01KB
返回 下载 相关 举报
C语言简单贪吃蛇游戏代码_第1页
第1页 / 共4页
C语言简单贪吃蛇游戏代码_第2页
第2页 / 共4页
C语言简单贪吃蛇游戏代码_第3页
第3页 / 共4页
C语言简单贪吃蛇游戏代码_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《C语言简单贪吃蛇游戏代码》由会员分享,可在线阅读,更多相关《C语言简单贪吃蛇游戏代码(4页珍藏版)》请在金锄头文库上搜索。

1、#include #include #include #include #include int x10=0,y10=0,xx20=0,yy20=0,xxx20,yyy20,actx=0,acty=1,eggx10=13,2,11,eggy10=5,4,4;time_t time1,time2;void eogame()int i;system(cls);for(i=0;i10;i+)printf(n);printf( game over !);getch();system(exit);void show()int i,j,tempx,tempy,max=0,ifget=0;time(&tim

2、e1);system(cls);for(i=0;i10;i+)xxi=xi;yyi=yi;for(i=0;i10;i+)xx10+i=eggxi;yy10+i=eggyi;for (j=0;j19;j+)for (i=0;iyyi+1)tempy=yyi;yyi=yyi+1;yyi+1=tempy;tempx=xxi;xxi=xxi+1;xxi+1=tempx;else if(yyi=yyi+1&xxixxi+1)tempx=xxi;xxi=xxi+1;xxi+1=tempx;yyy0=yy0;xxx0=xx0;for (i=0;i19;i+)yyyi+1=yyi+1-yyi;if(yyi+1

3、=yyi)xxxi+1=xxi+1-xxi;else xxxi+1=xxi+1;for(i=0;i20;i+)for(j=0;jyyyi;j+)printf(n);for (j=1;j0|yyyi0)printf( );time(&time2);while(time2-time11)time(&time2);for(i=0;i10;i+)if(x0+actx=eggxi&y0+acty=eggyi)ifget+;eggxi=0;eggyi=0;for(i=0;i0)ifget-;x0=x0+actx;y0=y0+acty;for(i=1;i20|y0=0|y020)eogame();for(i

4、=1;i10;i+)if(x0=xi&y0=yi)eogame();DWORD WINAPI KEYBOARD(LPVOID IpParam)char key,guard=2,ch;insert:key=getch();if(key=-32)guard=0;else guard+;if(guard=1)switch(key)case 72: actx=0;acty=-1;break;case 80: actx=0;acty=1;break;case 75: actx=-1;acty=0;break;case 77: actx=1;acty=0;break;default: break;goto insert;void main()x0=1;y0=1;system(mode con:cols=40 lines=20);CreateThread(NULL,0,KEYBOARD,NULL,0,NULL);while (1)show();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 机械/制造/汽车 > 汽车技术

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号