#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>
#include <conio.h>
//1.2食物结构体
#define MAPHEIGHT 25
#define MAPWIDTH 60
#define SNAKESIZE 50 //蛇的最大节数
struct FOOD
{
int x;
int y;
}food;
#define SNAKESIZE 50 //蛇的最大节数
struct
{ //每一节蛇的坐标
int x[SNAKESIZE];
int y[SNAKESIZE];
int len; //蛇长
int speed; //
}snake;
///全局变量
int key='w';//初始化移动方向
int changFlag = 0;//蛇变化标记
//模块化设计
//
//1.画地图
void gotoxy(int x,int y); //实现的函数声明
void drawMap();
void createFood();
int snakeStatus();
void drawMap()
{
srand((unsigned)time(NULL)); //随机函数种子
//1.圈地
//1.1 左右边框
for(int i=0;i<=MAPHEIGHT;i++)
{
gotoxy(0,i);
printf("■");
gotoxy(MAPWIDTH,i);
printf("■");
}
for(int i=0;i<=MAPWIDTH;i+=2) //上下 ■占用两个字符
{
gotoxy(i,0);
printf("■");
gotoxy(i,MAPHEIGHT);
printf("■");
}
//2.画蛇 ■
//2.1确定蛇的属性
snake.len=3