没有合适的资源?快使用搜索试试~ 我知道了~
贪吃蛇课程设计主程序代码 采用模块化设计方法 详细
资源详情
资源评论
资源推荐
----------------------------------------------------------------------
File : Snake.c
Purpose : 贪食蛇游戏
----------------------------------------------------------------------
*/
#include "gui.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define CHAR_WIDTH 8
#define CHAR_HIGH 8
#define SCREEN_HEIGHT (240 - CHAR_HIGH)
#define SCREEN_WIDTH (240 - CHAR_WIDTH)
#define MAX_NODE 2000
#define VK_LEFT ('4')
#define VK_RIGHT ('6')
#define VK_UP ('2')
#define VK_DOWN ('8')
#define VK_RESTAR ('0')
#define VK_ESC ('E')
#define VK_SPEED_UP ('C')
#define VK_SPEED_DOWN ('D')
#define CH_HEAD 0x1
#define CH_BODY 0x1
#define CH_TAIL 0x1
#define CH_BKG 0
#define DIRE_LEFT 1
#define DIRE_UP 2
#define DIRE_RIGHT 3
#define DIRE_DOWN 4
#define DIRE_STOP 5
int head, tail, length; /*定义头尾坐标及长度*/
int speed; /*游戏速度*/
int key; /*键盘按键*/
int food_x, food_y, food_value; /*食物的坐标及其分值*/
int score;
static int nodes[MAX_NODE][3]; /*蛇身节点坐标及移动方向(理论上蛇身最长可有 2000 节)*/
/*
----------------------------------------------------------------------
File : FONT_ShiftJIS.c
Purpose : Example demonstrating ShiftJIS capabilities of emWin
----------------------------------------------------------------------
*/
#include "gui.h"
/* LATIN CAPITAL LETTER A */
static const unsigned char acFontSnake13_0000[ 13] = { /* code 0000 */
________,
________,
________,
________,
________,
________,
________,
________,
________,
________,
________,
________,
________};
/* LATIN CAPITAL LETTER B */
static const unsigned char acFontSnake13_0001[ 13] = { /* code 0001 */
XXXXXXXX,
XXXXXXXX,
XXXXXXXX,
XXXXXXXX,
XXXXXXXX,
XXXXXXXX,
XXXXXXXX,
XXXXXXXX,
XXXXXXXX,
XXXXXXXX,
XXXXXXXX,
XXXXXXXX,
XXXXXXXX};
static const GUI_CHARINFO GUI_FontSnake13_CharInfo[2] = {
{ 8, 8, 1, (void *)&acFontSnake13_0000 } /* code 0000 */
,{ 8, 8, 1, (void *)&acFontSnake13_0001 } /* code 0001 */
};
static const GUI_FONT_PROP GUI_FontSnake13_Prop1 = {
0x0000 /* first character */
,0x0001 /* last character */
,&GUI_FontSnake13_CharInfo[ 0] /* address of first character */
,(void*)0 /* pointer to next GUI_FONT_PROP */
};
static const GUI_FONT GUI_FontSnake13 = {
GUI_FONTTYPE_PROP_SJIS /* type of font */
,8 /* height of font */
,8 /* space of font y */
,1 /* magnification x */
,1 /* magnification y */
,(void *)&GUI_FontSnake13_Prop1
};
/********************************************************************
// Function name : is_xy_inbody
// Description : 检查点(x, y)是否已被占用
// Return type : int
// Argument : int x
// Argument : int y
*********************************************************************/
int is_xy_inbody(int x, int y) /*检查点(x, y)的是否已被占用*/
{
int i;
if(head>tail)
{
for(i=tail; i<head; i++)
if(nodes[i][0]==x && nodes[i][1]==y) return 1;
}
else
{
for(i=tail; i<=MAX_NODE; i++)
if(nodes[i][0]==x && nodes[i][1]==y) return 1;
for(i=0; i<head; i++)
if(nodes[i][0]==x && nodes[i][1]==y) return 1;
};
return 0; /*正常返回 0*/
}
/********************************************************************
// Function name : drawfood
// Description : 绘制食物
// Return type : void
// Argument :
*********************************************************************/
void drawfood()
{
GUI_SetFont(&GUI_FontSnake13);
do
剩余10页未读,继续阅读
stuber
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Picasso_v3.1 2.ipa
- chromedriver-mac-arm64.zip
- 蓝zapro.apk
- chromedriver-linux64.zip
- UCAS研一深度学习实验-MNIST手写数字识别python源码+详细注释(高分项目)
- 基于Python和PyTorch框架完成的一个手写数字识别实验源码(带MINIST手写数字数据集)+详细注释(高分项目)
- 基于Matlab在MNIST数据集上利用CNN完成手写体数字识别任务,并实现单层CNN反向传播算法+源代码+文档说明(高分项目)
- NVIDIA驱动、CUDA和Pytorch及其依赖
- 基于SVM多特征融合的微表情识别python源码+项目说明+详细注释(高分课程设计)
- html动态爱心代码一(附源码)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0