zoukankan
html css js c++ java
2019春第二次课程设计报告
2019春第二次课程设计报告
一、实验项目名称
贪吃蛇
二、实验项目功能描述
通过a、s、d、w四个按键来控制小蛇吃到食物F,不断增加自身长度,如果撞到边框或自己则游戏结束。
三、项目模块结构介绍
第一步:构造小蛇。对于二维数组canvas[High][Width]的对应元素,值为0输出空格,值为-1输出边框#。值为1输出蛇头@,值大于1输出蛇身*,其余蛇身在startup()函数中实现。
第二步:小蛇的移动。定义变量 int moveDirection表示小蛇的移动方向,值为1,2,3,4分别表示小蛇向上下左右方向移动。小蛇的移动在moveSnakeDirection()中实现。
第三步:调用moveSnakeDirection()实现小蛇在不同方向的移动。
第四步;判断游戏失败。当小蛇和边框或者自身发生碰撞时游戏失败。
第五步:吃食物增加长度。当二维数组canvas[High][Width]元素值为-2时输出食物数值‘F’当蛇头碰到食物长度加一。
四、实现界面展示
五、代码托管链接
https://gitee.com/yhcyhcyhc/yxrw/blob/master/3.4%20%E8%B4%AA%E5%90%83%E8%9B%87.cpp
.
六、实验总结
问题1:git闪退的问题?问题2:代码总是编译错误?
解决方法:第一个问题通过百度解决。在设置中点击更新与安全,再点恢复,进入高级启动模式,按7强制性关闭数字签证即可解决。第二个问题书上把Sleep(100)的s打印成了小写,导致编译失败,无法运行,改正即可。
感悟:一个小游戏就是100多行代码,需要足够的知识积累和极大的细心才能完成,实现以后还要进行维护,工作量比较大。于是我想到做事要细心,一步一个脚印才有收获。即使现在被很多问题困扰,但通过自己的努力还是能解决一部分的。
查看全文
相关阅读:
130行C语言实现个用户态线程库(2)
130行C语言实现个用户态线程库(1)
用C语言模仿Python函数
ES 2.4 bigdesk 安装失败解决方案.
使用SqlBulkCopy, 插入整个DataTable中的所有数据到指定数据库中
表A的数据减去表B ,最终得到表C
关于把A表中的数据复制到B表中(整理)
需求池整理
app主流推广渠道
流程图梳理
原文地址:https://www.cnblogs.com/wsyhc/p/10955030.html
最新文章
CSV Data Set Config设置
jmeter对返回json数据做统计
jmeter参数化之数据库+正则表达式
jmeter参数化之数据库传参
jmeter参数化之用户参数
jmeter参数化之_CSVRead()函数
(macOS)一劳永逸地修改finder所有文件夹的显示选项
windows下配置caffe(环境:win7+vs2013+opencv3.0)
一种调用opencv库的C++工程通用的Makefile模板
二维码开源库zbar、zxing使用心得
热门文章
<有序数组>转化为<按二分法遍历顺序排列的数组>(C++实现)
CORE3.1 WebAPI Serilog日志框架
C#算法大纲
C#基本面试题
SQL SERVER数据库基本操作
在.NET Framework4.8 MVC项目中使用AJAX上传图片
跨域:使用MVVM模式.NET CORE WebAPI+vue
算法题:一个N字节的数,如何逆序排列各个位(bit)?例如1字节的数 0010 0011 => 1100 0100
TCP/IP详解卷二——开坑记
如何学习操作系统原理?
Copyright © 2011-2022 走看看