- 1、本文档共34页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
PAGE
唐 山 学 院
毕 业 设 计
设计题目:贪吃蛇游戏
信息工程二系
信息工程二系
04计算机与信息管理(3)班
04计算机与信息管理(3)班
翟 丽 丽班 级:____________________________
翟 丽 丽
姜 方 正班 级:____________________________
姜 方 正
指 导 教 师:____________________________
2006年6月9 日
贪吃蛇游戏
摘 要
贪吃蛇游戏是一个深受人们喜爱的游戏,它能够让你在忙碌的工作中放松一下自己,游戏贪吃蛇就是在屏幕上画出蛇,同时随机地给出食物。游戏者通过键盘操作控制贪吃蛇的移动,去吃食物,吃到后食物消失,然后再随机给出食物同时蛇的身体增长。撞到墙壁或身体交叉蛇头撞到自己的身体,则游戏结束。
这个程序关键点是表示蛇的图形以及蛇的移动。用一个小矩形块表示蛇的一节身体,身体每长一节,增加一个矩形块,蛇头用两节表示。移动时必须从蛇头开始,所以蛇不能向相反的方向移动,也就是蛇尾不能改作蛇头。如果不按任何键,蛇自行在当前方向上前移,当游戏者按了有效的方向键后,蛇头朝着指定的方向移动,一步移动一节身体,所以当按了有效的方向键后,先确定蛇头的位置,然后蛇身体随着蛇头移动,图形的实现是从蛇头的新位置开始画出蛇,这时,由于没有清屏的原因,原来蛇的位置差一个单位,所以看起来蛇会多一节身体,所以将蛇的最后一节用背景色覆盖。食物的出现和消失也是画矩形块和覆盖矩形块。
本程序实现的主要技巧在二维数组的应用上。编写此游戏掌握了用C语言知识的了解,通过这次毕业设计,提高了我们的编程的水平。
关键词:食物和蛇
Tanchishe game
Abstract
Tanchishe game is a very popular game is that it can allow you to relax at work in a busy themselves in the game Tanchiyi screen is painted snake while random to give food. Tanchiyi operational control of the game through keyboard movement, eat food, after eating food disappeared, and then randomly given food and snake physical growth. Hit the walls or physical cross-snake hit their physical, the game ended.
The key point is that the procedures of the snake and the snake mobile graphics. Using a small rectangle pieces that snake section body, the body of each long section, add a rectangle pieces, with two sections that snakeheads. Movement must start from the snake, the snake can not be contrary to the direction of movement that is capable not for snakeheads. If we do not by any keys, snakes themselves in the current direction of everything, when those games by an effective direction keys, snake head towards the designated direction movements, step movement section of the body, so when the effective direction keys, to identify the snakes position, and then snake body with snakeheads movement graphic realization from the snakeheads new location beginning painted snake, then, In the absence of
文档评论(0)