没有合适的资源?快使用搜索试试~ 我知道了~
首页贪吃蛇代码-C语言-VC 6.0
贪吃蛇代码-C语言-VC 6.0
需积分: 17 165 浏览量
更新于2023-03-16
评论 7
收藏 46KB DOC 举报
贪吃蛇代码-C语言-VC 6.0 一个C语言写的简单贪吃蛇源代码
资源详情
资源评论
资源推荐

#include <windows.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
#define N 21
int apple[3];
char score[3];
char tail[3];
void gotoxy(int x, int y) //输出坐标
{
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void color(int b) //颜色函数
{
HANDLE hConsole = GetStdHandle((STD_OUTPUT_HANDLE)) ;
SetConsoleTextAttribute(hConsole,b) ;
}
int Block(char head[2]) //判断出界
{
if ((head[0] < 1) || (head[0] > N) || (head[1] < 1) || (head[1] > N))
return 1;
return 0;
}
int Eat(char snake[2]) //吃了苹果
{
if ((snake[0] == apple[0]) && (snake[1] == apple[1]))
{
apple[0] = apple[1] = apple[2] = 0;
gotoxy(N+44,10);
color(13);
printf("%d",score[0]*10);
color(11);
return 1;
}















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0