计算机编程c语言入门 c在线编程菜鸟教程( 二 )


网络效果图
【计算机编程c语言入门 c在线编程菜鸟教程】代码如下:
#define _CRT_SECURE_NO_WARNINGS 1#include #include #include #include #include #include #define MAXWIDTH 30#define MAXHEIGHT 30#define INITLEN 3 //贪吃蛇的初始长度 struct{
char *ch; int color; char type;
}
charBorder = { “”, 4, 1 }, //边框charBg = { “”, 2, 2 }, //背景charSnake = { “”, 0xe, 3 }, //贪吃蛇节点charFood = { “”, 0xc, 4 }; //食物//用一个结构体数组保存地图中的各个点struct{
char type; int index;
}globalMap[MAXWIDTH][MAXHEIGHT];struct{
int x; int y;
} snakeMap[(MAXWIDTH – 2)*(MAXHEIGHT – 2)], scoresPostion;int scores = 0; //得分int snakeMapLen = (MAXWIDTH – 2)*(MAXHEIGHT – 2);int headerIndex, tailIndex;
HANDLE hStdin;
// 设置光标位置,x为行,y为列void setPosition(int x, int y){
COORD coord;
coord.X = 2 * y;
coord.Y = x;
SetCo

猜你喜欢