资源描述:
《Win-TC(C语言)贪吃蛇游戏程序设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Win-TC(C语言)贪吃蛇游戏程序设计贪吃蛇游戏是大家熟悉的一个经典游戏,现在用Win-TC编译环境来实现游戏过程。游戏功能如下:游戏开始后在屏幕出现一条自由活动的蛇,玩家可通过小键盘的方向功能键来控制蛇的运动方向,系统每间隔10秒钟随机投放一次食物(一颗食用果或毒果)。蛇每吃到一颗食用果后其身体长度会自动增长一节,玩家得到5分的成绩奖励,当蛇吃到毒果或碰到四周边界和蛇头碰到蛇身的某一部位时,游戏结束。(更新版本) 图1、贪吃蛇游戏效果图游戏源程序清单如下:#include#include#includ
2、e#include#include#include#defineMAXSIZE1000/*定义贪吃蛇最大长度*/#defineLEFT75/*定义方向键左向键盘值*/#defineRIGHT77/*定义方向键右向键盘值*/#defineUP72/*定义方向键上向键盘值*/#defineDOWN80/*定义方向键下向键盘值*/#defineWINTOP120/*定义游戏区上边界y坐标值*/#defineWINDOWN360/*定义游戏区下边界y坐标值*/#defineWINLEFT140/*定
3、义游戏区左边界x坐标值*/#defineWINRIGHT500/*定义游戏区右边界x坐标值*/charFILLC[]={0xfe,0x90,0x49,0xa0,0x30,0xc0,0x29,0xc0,0x46,0xa0,0xfe,0x90,0x49,0xa0,0x30,0xc0,0x21,0xc0,0x53,0x20,0x80,0x90,0x10,0x40};/*恢复屏幕数据*/charRNULL[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0
4、x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/*头部数据*//*top*/charheadt[]={0x00,0x00,0x0f,0x00,0x1f,0x80,0x3f,0xc0,0x26,0x40,0x26,0x40,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x1f,0x80,0x1f,0x80};/*down*/charheadd[]={0x1f,0x80,0x1f,0x80,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xc0,0x26,
5、0x40,0x26,0x40,0x3f,0xc0,0x1f,0x80,0x0f,0x00,0x00,0x00};/*right*/charheadr[]={0x00,0x00,0x00,0x00,0x3f,0x80,0xfc,0xc0,0xfc,0xe0,0xff,0xe0,0xff,0xe0,0xfc,0xe0,0xfc,0xc0,0x3f,0x80,0x00,0x00,0x00,0x00};/*left*/charheadl[]={0x00,0x00,0x00,0x00,0x1f,0xc0,0x33,0xf0,0x73,0xf0,0x7f,0xf0,
6、0x7f,0xf0,0x73,0xf0,0x33,0xf0,0x1f,0xc0,0x00,0x00,0x00,0x00};/*身体数据*//*leftdown*/charleftd[]={0x1f,0x80,0x1f,0x80,0x1f,0xc0,0x1f,0xf0,0x1f,0xf0,0x0f,0xf0,0x0f,0xf0,0x07,0xf0,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,0x00};/*rightdown*/charrightd[]={0x1f,0x80,0x1f,0x80,0x3f,0x80,0xff,0x8
7、0,0xff,0x80,0xff,0x00,0xff,0x00,0xfe,0x00,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/*lefttop*/charleftt[]={0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xf0,0x07,0xf0,0x0f,0xf0,0x0f,0xf0,0x1f,0xf0,0x1f,0xf0,0x1f,0xc0,0x1f,0x80,0x1f,0x80};/*righttop*/charrightt[]={0x00,0x00,0x00,0x00,0x00,0
8、x00,0xf8,0x00,0xfe,0x00,0xff,0x00,0xff,0