资源简介
应付计算机系大学生的作业或者实训课最佳之选,本作者考虑到你们编写文档报告的问题。先说明,网上绝对找不到第二个类似的程序,本作者学习时亲自开发的。解压后有4个文件,其中testncur.c是贪吃蛇源代码,有中文注释,极易上手,代码可读性极强,不用担心看不懂。其中有编写好的Makefile,下载后,解压将得到testncur_stu文件夹,文件夹通过共享方式或者ftp,samba方式,移动到虚拟机的linux下,使用cd命令进入testncur_stu文件夹中,执行清除命令make clean,然后再执行make,生成testncur文件,使用 ./testncur 执行该文件。可用做应付作业哟,代码有中文注释,针对小白编写报告时用的,本作者就帮到这里吧,搜索到本资源就是你的福气。

代码片段和文件信息
#include
#include
#include
#include
#include
#include
#define DFL_SPEED 500 /* snake default speed */
#define _LEN 9
int maxxmaxy;
int *psnk*lsnk*px*py;
void delay1s(int n)
{
int ij;
for(i=0;i for(j=0;j }
void drawrect(int rowsint cols)
{
int begainrowendrowbegaincolendcol;
int currow=0curcol=0;
int ij;
int count;
begainrow=0;
endrow =rows - 1;
begaincol=0;
endcol =cols - 1;
currow=begainrowcurcol=begaincol;
for(count=0;count {
// 从左到右显示一行
for(;;)
{
mvaddch(currowcurcol‘A‘);
refresh();
delay1s(100);
if(curcol != endcol)
curcol ++;
else
{
endcol--;
break;
}
}
// 从上倒下显示一竖行
for(;;)
{
if(currow != endrow)
currow++;
else
{
endrow--;
break;
}
mvaddch(currowcurcol‘A‘);
refresh();
delay1s(3000);
}
// 从右到左显示一行
for(;;)
{
if(curcol != begaincol)
curcol--;
else
{
begaincol++;
break;
}
mvaddch(currowcurcol‘A‘);
refresh();
delay1s(3000);
}
// 从下到上显示一行
for(;;)
{
if(currow != begainrow+1)
currow--;
else
{
begainrow++;
break;
}
mvaddch(currowcurcol‘A‘);
refresh();
delay1s(3000);
}
}
}
void disppoint(int rowsint cols)
{
int currowcurcol;
int c;
currow = rand() % rows;
curcol = rand() % cols;
keypad(stdscr true);
}
typedef struct food
{
int x;
int y;
}_FOOD;
_FOOD fo;
void showfo(int colsint rows) //随机食物
{
mvaddch(fo.yfo.x‘ ‘);
fo.x=rand() % cols ;
fo.y=rand() % rows ;
mvaddch(fo.yfo.x‘?‘);
}
//蛇头是否碰到食物
int eat(int xint yint y1int x1)
{
if(x ==x1 && y == y1)
{
showfo(maxy-1maxx-1); //碰到食物响应代码
//mvaddch(11‘K‘);
return 1;
}
return 0;
}
void snkj(int lenint *p) //显示蛇身体,和清除蛇的尾巴
{
int i;
char g=‘@‘;
for(i=len;i>=0;i--)
{
if(i==len)
{
mvaddch(p[2*i]p[2*i+1]‘ ‘);
}
else
{
if(i==0)
{
mvaddch(p[2*i]p[2*i+1]‘#‘);
continue;
}
mvaddch(p[2*i]p[2*i+1]g);
//g++;
}
}
}
void ch2(int *xint *y) //数据交换
{
int temp;
temp=*x;
*x = *y;
*y = temp;
}
void snkjmv(int xint yint *pint len) //蛇数组移动
{
int i;
for(i=0;i<=len;i++)
{
ch2(&p[0]&p[2*(i+1)]);
ch2(&p[1]&p[2*(i+1)+1]);
}
p[0]=x;
p[1]=y;
}
void addsnkL(int xint yint *pint len) //加蛇长度
{
int i;
for(i=2*len-1;i<=0;i=i-2)
{
p[i+2]=p[i];
p[i+1]=p[i-1];
}
}
int same(int aint b) //比较2数是否相等
{
if(a == b)
return 1;
return 0;
}
int samesnk(int *pint len) //数组是否与第一个数组相等
{
int i;
for(i=1;i {
if ( same(p[0]p[2*i]) == 1 && same(p[1]p[2*i+1]) == 1) //game over
{
return 1;
}
}
return 0;
}
int set_ticker(int n_msecs)
{
struct itimerval new_timeset;
long n_sec n_usecs;
n_sec = n_msecs / 1000;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 193 2015-04-08 12:38 testncur_stu\Makefile
....... 10728 2015-04-21 13:05 testncur_stu\testncur
....... 6947 2015-04-21 13:05 testncur_stu\testncur.c
....... 7116 2015-04-21 13:05 testncur_stu\testncur.o
目录 0 2015-04-26 22:21 testncur_stu
----------- --------- ---------- ----- ----
24984 5
相关资源
- 登录注册界面.zip48872
- 条码字体barcode128
- Rational Rose Common破解文件
- res10_300x300_ssd_iter_140000.caffemodel与dep
- scratch 第1课 翻跟斗的小猫(入门)
- stm32f407上的两个can发送和接收例程
- Scrach 欢乐狙击手.sb2
- 04741计算机网络原理知识点整理.docx(
- Wolfram Mathematica 矩阵初等变换函数(
- pscad近海风电模型 Fortran语言
- 程序员专用字体YaHei.Consolas.1.11b42517
- scratch3.0 源程序(说相声)
- AutoCAD永久去教育版破解补丁
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- 欧姆龙CP1系列单轴定位PLC程序.cxp
- 用Beckhoff(倍福)PLC读写巴鲁夫RFID
- CVSNT 完整覆盖版防TortoiseCVS中文乱码
- pfc 使用说明.doc
- Scratch 飞机大战.sb3
- STC8951系列单片机中方指南
- 《Visual Prolog 基础类》 中文参考.chm
- Omron ETN21模块进行modbustcp通讯
- 基于ACCESS的生产管理信息系统.mdb
- CANopen使用手册_埃斯顿
- Scratch 吃豆人追踪者.sb3
- Scratch 变脸(将人物图片变成各种各样
- oracle数据迁移项目实施方案
- CanuMobiSim
评论
共有 条评论