贪吃蛇c语言程序代码(跪求大神解难,贪吃蛇c语言代码,vc6,确保可以运行,C语言渣渣急着交作业,300行左右(T_T))

本文目录
- 跪求大神解难,贪吃蛇c语言代码,vc6,确保可以运行,C语言渣渣急着交作业,300行左右(T_T)
- C语言贪吃蛇代码求注释
- c语言 贪吃蛇 求大食物代码ps:每吃四个食物随机出现一个加大分值的食物,与小食物同时存在
- 求 贪吃蛇C语言代码
- 求c语言的贪吃蛇的代码 能运行的
跪求大神解难,贪吃蛇c语言代码,vc6,确保可以运行,C语言渣渣急着交作业,300行左右(T_T)
/*
program by wlfryq 71693456@qq.com
*/
#include 《stdio.h》
#include 《stdlib.h》
#include 《conio.h》
#include 《windows.h》
#include 《time.h》
#include 《direct.h》
//#include 《stdbool.h》
#define W 80 //屏幕宽度
#define H 37 //屏幕高度
#define SNAKE_ALL_LENGTH 200 //蛇身最长为
void CALLBACK TimerProc(
HWND hwnd,
UINT message,
UINT idTimer,
DWORD dwTime);
void start();
struct MYPOINT
{
int x;
int y;
} s , head, end, food;
int max_count=0; //历史最高分,如果count》max_count, 则max_count=count
int old_max_count=0; //历史最高分,不会变动, 用于死亡时判断max_count是否大于old_max_count,如果大于,则写入文件
int count=0; //得分
int len=20; //当前蛇身长度
int direct=0; //方向: 0-向右, 1-向下, 2-向左, 3-向上
int speed=200; //速度:毫秒
bool isfood=false; //食物是否存在
int timerID;
bool stop=false; //暂停
char* ini_path; //数据文件绝对路径
void setxy(int x, int y) //设置CMD窗口光标位置
{
COORD coord = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void hide_cursor() //隐藏CMD窗口光标
{
CONSOLE_CURSOR_INFO cci;
cci.bVisible = FALSE;
cci.dwSize = sizeof(cci);
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorInfo(handle, &cci);
}
void set_food() //设置食物坐标
{
if(isfood==true)
{
return;
}
int x,y,i;
bool flag=false;
while(1)
{
flag=false;
x=rand()%(W-14)+6;
y=rand()%(H-12)+6;
for(i=0;i《len;i++) //判断食物是否落在蛇身上
{
if(s.y==y)
{
flag=true;
break;
}
}
if(flag==true)
{
continue;
}
else
{
food.x=x;
food.y=y;
break;
}
}
setxy(food.x,food.y);
printf("*");
isfood=true;
}
void check_board() //检测蛇身是否越界和相交
{
int i;
if(s.y《=2)
{
setxy(W/2-5,0);
printf("game over\n");
stop=true;
if(old_max_count《max_count)
{
char t={’\0’};
sprintf(t,"%d",max_count);
WritePrivateProfileString("MAX_COUNT","max_count",t,ini_path);
}
}
for(i=1;i《len;i++)
{
if(s.y)
{
setxy(W/2-5,0);
printf("game over\n");
stop=true;
if(old_max_count《max_count)
{
char t={’\0’};
sprintf(t,"%d",max_count);
WritePrivateProfileString("MAX_COUNT","max_count",t,ini_path);
}
break;
}
}
if(stop==true)
{
KillTimer(NULL,timerID);
int c;
while(1)
{
fflush(stdin);
c=_getch();
if(c==’n’ || c==’N’)
{
start();
}
else if(c==’q’ || c==’Q’)
{
exit(0);
}
else continue;
}
}
}
void printf_body(bool is_first) //打印蛇身
{
if(is_first==true) //如果是第一次打印蛇身
{
int i;
for(i=0;i《len;i++)
{
setxy(s.y);
printf("O");
}
}
else //如果不是第一次打印蛇身
{
setxy(end.x,end.y);
printf(" ");
setxy(s.y);
printf("O");
}
if(food.x==s.y) //如果吃到食物
{
count++;
isfood=false; //重置食物
set_food();
len++;
KillTimer(NULL,timerID);
if(speed》100) speed-=10;
else if(speed》50) speed-=5;
else if(speed》30) speed-=2;
else if(speed》16) speed-=1;
else ;
setxy(0,0);
if(max_count《count)max_count=count;
printf(" speed : %d ms score : %d best score:%d ",speed,count,max_count);
timerID=SetTimer(NULL,001,speed,TimerProc);
}
}
void change_body_pos(int x, int y) //改变蛇身的坐标数据
{
end.x=s.x;
end.y=s.y;
int i;
for(i=len-1;i》0;i--)
{
s.x;
s.y;
}
s.x=x;
s.y=y;
}
void CALLBACK TimerProc(
HWND hwnd,
UINT message,
UINT idTimer,
DWORD dwTime)
{
switch(direct)
{
case 0:
head.x++;
change_body_pos(head.x,head.y);
printf_body(false);
check_board();
break;
case 1:
head.y++;
change_body_pos(head.x,head.y);
printf_body(false);
check_board();
break;
case 2:
head.x--;
change_body_pos(head.x,head.y);
printf_body(false);
check_board();
break;
case 3:
head.y--;
change_body_pos(head.x,head.y);
printf_body(false);
check_board();
break;
}
}
void start()
{
int i;
KillTimer(NULL,timerID);
count=0; //得分
len=20; //当前蛇身长度
direct=0; //方向: 0-向右, 1-向下, 2-向左, 3-向上
speed=200; //速度:毫秒
isfood=false; //食物是否存在
stop=false; //停止
system("cls");
setxy(1,4);
printf("┌─────────────────────────────────────┐\n");
for(i=0;i《33;i++)
{
printf(" │ │\n");
}
printf(" └─────────────────────────────────────┘");
head.x=len-1+5;
head.y=H/2;
for(i=0;i《len;i++)
{
s.x=head.x-i;
s.y=head.y;
}
setxy(0,0);
printf(" speed : %d:ms score : %d best score:%d ",speed,count,max_count);
printf_body(true);
set_food();
timerID=SetTimer(NULL,001,speed,TimerProc);
int c;
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
if(stop==true)break;
if(_kbhit()) //如果按下的是方向键或功能键, _getch()要调用两次,第一次返回0XE0或0
{
fflush(stdin);
c=_getch(); //上: 72 下:80 左:75 右:77
if(c==0XE0 || c==0)
{
c=_getch();
if(c==72 && direct!=1 && direct!=3)
{
direct=3;
}
else if(c==80 && direct!=1 && direct!=3)
{
direct=1;
}
else if(c==75 && direct!=0 && direct!=2)
{
direct=2;
}
else if(c==77 && direct!=0 && direct!=2)
{
direct=0;
}
}
else if(c==’ ’)
{
setxy(W/2-10,0);
system("pause");
setxy(W/2-10,0);
printf(" ");
}
}
if(msg.message==WM_TIMER)
{
DispatchMessage(&msg);
}
}
}
int main()
{
ini_path=(char*)malloc(sizeof(char)*50);
srand((unsigned)time(0));
getcwd(ini_path,50);//取得当前程序绝对路径
ini_path=strcat(ini_path,"snake.dat");
max_count=GetPrivateProfileInt("MAX_COUNT","max_count",0,ini_path);
old_max_count=max_count;
char cmd;
sprintf(cmd,"mode con cols=%d lines=%d\0",W,H);
system(cmd);//改变CMD窗口大小
hide_cursor();
start();
return 0;
}
C语言贪吃蛇代码求注释
void main()
{
int a={0};/*先声明一个30*30的数组,用于存储屏幕上的蛇、食物的分布情况*/
int i,j,t,flag=0;
char c=’d’,c1=’d’;
struct Food food={10,16,’A’};/*初始化一个食物对象,在10,16位置,它的另一个参数是’A’*/
int gameover=0;/*让游戏状态切换到正常*/
struct Node *head,*p,*rear,*pt;/*head存储蛇的头部,pt用来临时遍历蛇的每一节、rear用来存储蛇的尾部(不过你截的这段代码没有使用到尾部信息的值、p是增删结点时采用的一个临时变量)*/
head=(struct Node *)malloc(sizeof(struct Node));/*给蛇分配内存空间*/
head-》x=10;/*蛇头的x值为10*/
head-》y=16;/*同理*/
head-》pre=NULL;/*蛇头前面没有结点*/
head-》next=NULL;/*蛇头后面也没有结点(空空荡荡的一个大头)*/
rear=head;/*所以~蛇的屁股就是它的脑袋……*/
srand((unsigned)time(NULL));/*初始化随机数发生器,让程序每一次执行时产生的随机数序列都不一样*/
while(1)
{
if(food.x==head-》x && food.y==head-》y)/*如果蛇头碰到了食物*/
{
p=(struct Node *)malloc(sizeof(struct Node));/*创建一个新的结点,并分配空间*/
pt=head;/*pt指向蛇头,准备遍历*/
while(pt-》next!=NULL)/*只要pt指向的结点后面还有结点,即没有遍历到蛇尾*/
pt=pt-》next ;/*pt指向下一个结点*/
p-》pre= pt;/*新增结点的上一个结点是尾部(此时pt已经指向了蛇尾)*/
pt-》next = p;/*蛇尾的下一个结点变为新增结点,链表被链接在一起了*/
p-》next=NULL;/*新增结点的下一个结点设为没有,即下一次遍历时,它默认为尾部*/
rear=p;/*蛇尾变成新增结点*/
food.x=rand()%15;/*初始化下一个食物位置(0-14,0-14)范围内*/
food.y=rand()%15;
food.c=65+rand()%26;/*食物的另一个参数随机分配为某一个英文字母*/
flag=1;/*让旗标变为1,旗标的作用在这段被截断的代码中未知,下同*/
t=0;
c语言 贪吃蛇 求大食物代码ps:每吃四个食物随机出现一个加大分值的食物,与小食物同时存在
#include《stdio.h》
#include《stdlib.h》
#include《time.h》
#include《conio.h》
typedef struct snake
{
int a;
int b;
struct snake *u;
struct snake *n;
}snake,*snake1;
typedef struct food
{
int a;
int b;
}food;
int main()
{
char c,c0 = ’d’;
int i,j,k,n=1,t,at;
snake p,q;
snake *dd,*dd0,*dd1,*dd2;
food f;
srand(time(NULL));
p.u = NULL;
p.n = &q
p.a = 5;p.b = 6;q.a = 5;q.b = 5;
q.u = &pq.n = NULL;
dd=dd2= &q
f.a=(rand()%15+1);
f.b=(rand()%15+1);
while(1)
{
srand(time(NULL));
system("cls");
for(i = 0;i 《 17;i ++)
{
for(j = 0; j 《 17;j++)
{
if(i == 0 )
printf("▁");
else if(i == 16)
printf("▔");
else if(j == 0)
printf("▕");
else if(j == 16)
printf("▏");
else if(i == p.a && j == p.b)
printf("◆");
else if(i == f.a && j == f.b)
printf("☆");
else
{
t = 0;
dd = dd2;
for(k = 0; k 《 n ;k++)
{
if(i == dd-》a && j == dd-》b)
{
printf("¤");
t = 1;
break;
}
dd = dd-》u;
}
if(t == 0)
printf(" ");
}
}printf("\n");
}
at = 0;
dd =dd2;
for(i=0;i《n;i++)
{
if(p.a == dd-》a && p.b == dd-》b)
{
printf("game over!!\n");
for (int iii=0;iii《1000;iii++) {};
exit(0);
}
dd = dd-》u;
}
if(p.a == f.a && p.b == f.b)
{
dd = dd2;
at =1;
f.a = (rand()%15+1);
f.b = (rand()%15+1);
for(i=0;i《n;i++)
{
if(f.a == dd-》a && f.b == dd-》b)
{
f.a = dd2-》a;
f.b = dd2-》b;
break;
}
}
n++;
}
if(kbhit())
{
c = getch();
dd = dd2;
if(c == ’w’ && c0 != ’s’)
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0-》a = dd2-》a;dd0-》b = dd2-》b;
dd0-》n = NULL;dd0-》u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i《n ; i++)
{
dd1 = dd-》u;
dd-》b = dd1-》b;
dd-》a = dd1-》a;
dd = dd-》u;
}
if(p.a == 1)
p.a = 15;
else
p.a = (p.a-1)%15;
}
else if(c == ’s’ && c0 != ’w’)
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0-》a = dd2-》a;dd0-》b = dd2-》b;
dd0-》n = NULL;dd0-》u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i《n ; i++)
{
dd1 = dd-》u;
dd-》b = dd1-》b;
dd-》a = dd1-》a;
dd = dd-》u;
}
p.a = (p.a%15)+1;
}
else if(c == ’a’ && c0 != ’d’)
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0-》a = dd2-》a;dd0-》b = dd2-》b;
dd0-》n = NULL;dd0-》u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i《n ; i++)
{
dd1 = dd-》u;
dd-》b = dd1-》b;
dd-》a = dd1-》a;
dd = dd-》u;
}
if(p.b == 1)
p.b = 15;
else
p.b = (p.b-1)%15;
}
else if(c == ’d’ && c0 != ’a’)
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0-》a = dd2-》a;dd0-》b = dd2-》b;
dd0-》n = NULL;dd0-》u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i《n ; i++)
{
dd1 = dd-》u;
dd-》b = dd1-》b;
dd-》a = dd1-》a;
dd = dd-》u;
}
p.b = (p.b%15)+1;
}
else
{
goto qq;
}
c0 = c;
}
else
{
qq: if(c0 == ’w’)
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0-》a = dd2-》a;dd0-》b = dd2-》b;
dd0-》n = NULL;dd0-》u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i《n ; i++)
{
dd1 = dd-》u;
dd-》b = dd1-》b;
dd-》a = dd1-》a;
dd = dd-》u;
}
if(p.a == 1)
p.a = 15;
else
p.a=(p.a-1)%15;
}
else if(c0 == ’s’)
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0-》a = dd2-》a;dd0-》b = dd2-》b;
dd0-》n = NULL;dd0-》u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i《n ; i++)
{
dd1 = dd-》u;
dd-》b = dd1-》b;
dd-》a = dd1-》a;
dd = dd-》u;
}
p.a=(p.a%15)+1;
}
else if(c0 == ’a’)
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0-》a = dd2-》a;dd0-》b = dd2-》b;
dd0-》n = NULL;dd0-》u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i《n ; i++)
{
dd1 = dd-》u;
dd-》b = dd1-》b;
dd-》a = dd1-》a;
dd = dd-》u;
}
if(p.b == 1)
p.b = 15;
else
p.b=(p.b-1)%15;
}
else if(c0 == ’d’)
{
if(at == 1)
{
dd0 =(snake1)malloc(sizeof(snake));
dd0-》a = dd2-》a;dd0-》b = dd2-》b;
dd0-》n = NULL;dd0-》u = dd2;
dd2=dd0;
}
dd = dd2;
for(i = 0; i《n ; i++)
{
dd1 = dd-》u;
dd-》b = dd1-》b;
dd-》a = dd1-》a;
dd = dd-》u;
}
p.b=(p.b%15)+1;
}
}
fflush(stdin);
dd = &q
_sleep(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,num;
char score;
char tail;
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) //判断出界
{
if ((head 》 N))
return 1;
return 0;
}
int Eat(char snake) //吃了苹果
{
if ((snake))
{
apple = 0;
gotoxy(N+44,10);
color(13);
printf("%d",score*10);
color(11);
return 1;
}
return 0;
}
void Draw(char **snake, int len) //蛇移动
{
if (apple)
{
gotoxy(apple);
color(12);
printf("●");
color(11);
}
gotoxy(tail);
if (tail)
{
color(num);
printf("★");
color(num);
}
else
printf("■");
gotoxy(snake);
color(num);
printf("★");
color(num);
putchar(’\n’);
}
char** Move(char **snake, char dirx, int *len) //控制方向
{
int i, full = Eat(snake);
memcpy(tail, snake, 2);
for (i = (*len) - 1; i 》 0; --i)
memcpy(snake, 2);
switch (dirx)
{
case ’w’: case ’W’: --snake; break;
case ’s’: case ’S’: ++snake; break;
case ’a’: case ’A’: --snake; break;
case ’d’: case ’D’: ++snake; break;
default: ;
}
if (full)
{
snake = (char **)realloc(snake, sizeof(char *) * ((*len) + 1));
snake = (char *)malloc(sizeof(char) * 2);
memcpy(snake, tail, 2);
++(*len);
++score;
if(score 《 16)
++score;
tail = 1;
}
else
tail = 0;
return snake;
}
void init(char plate, char ***snake_x, int *len) //初始化
{
int i, j;
char **snake = NULL;
*len = 3;
score =3;
snake = (char **)realloc(snake, sizeof(char *) * (*len));
for (i = 0; i 《 *len; ++i)
snake = (char *)malloc(sizeof(char) * 2);
for (i = 0; i 《 3; ++i)
{
snake = N/2 + 1;
snake = N/2 + 1 + i;
}
for (i = 1; i 《= N; ++i)
for (j = 1; j 《= N; ++j)
plate = 1;
apple = rand()%N + 1;
apple = 1;
for (i = 0; i 《 N + 2; ++i)
{
gotoxy(0, i);
for (j = 0; j 《 N + 2; ++j)
{
switch (plate)
{
case 0:
color(12);printf("□");color(11); continue;
case 1: printf("■"); continue;
default: ;
}
}
putchar(’\n’);
}
for (i = 0; i 《 (*len); ++i)
{
gotoxy(snake);
printf("★");
}
putchar(’\n’);
*snake_x = snake;
}
void Manual()
{
gotoxy(N+30,2);
color(10);
printf("按 W S A D 移动方向");
gotoxy(N+30,4);
printf("按 space 键暂停");
gotoxy(N+30,8);
color(11);
printf("历史最高分为: ");
color(12);
gotoxy(N+44,8);
printf("%d",score*10);
color(11);
gotoxy(N+30,12);
printf("你现在得分为: 0");
}
int File_in() //取记录的分数
{
FILE *fp;
if((fp = fopen("C:\\tcs.txt","a+")) == NULL)
{
gotoxy(N+18, N+2);
printf("文件不能打开\n");
exit(0);
}
if((score = fgetc(fp)) != EOF);
else
score = 0;
return 0;
}
int File_out() //存数据
{
FILE *fp;
if(score)
{gotoxy(10,10);
color(12);
puts("闯关失败 加油耶");
gotoxy(0,N+2);
return 0;
}
if((fp = fopen("C:\\tcs.txt","w+")) == NULL)
{
printf("文件不能打开\n");
exit(0);
}
if(fputc(--score,fp)==EOF)
printf("输出失败\n");
gotoxy(10,10);
color(12);
puts("恭喜您打破记录");
gotoxy(0,N+2);
return 0;
}
void Free(char **snake, int len) //释放空间
{
int i;
for (i = 0; i 《 len; ++i)
free(snake);
free(snake);
}
int main(void)
{
int len;
char ch = ’g’;
char a = {{0}};
char **snake;
srand((unsigned)time(NULL));
color(11);
File_in();
init(a, &snake, &len);
Manual();
while (ch != 0x1B) // 按 ESC 结束
{
Draw(snake, len);
if (!apple) {
apple = rand()%N + 1;
apple = rand()%N + 1;
apple = 1;
num++;
if(num》8)
num=0;
}
Sleep(200-score*10);
setbuf(stdin, NULL);
if (kbhit())
{
gotoxy(0, N+2);
ch = getche();
}
snake = Move(snake, ch, &len);
if (Block(snake)==1)
{
gotoxy(N+2, N+2);
puts("你输了");
File_out();
Free(snake, len);
getche();
exit(0);
}
}
Free(snake, len);
exit(0);
}
求c语言的贪吃蛇的代码 能运行的
// ConsoleApplication1.cpp: 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include 《stdio.h》
#include 《windows.h》
#include 《time.h》
#include 《conio.h》
#define frame_height 20 //define map size
#define frame_width 40
#define UP ’w’ //define operate key
#define DOWN ’s’
#define LEFT ’a’
#define RIGHT ’d’
int i, j, k;
char ch = UP; //initial direction
int grow = 0; //flag: if snake grow
struct Food {
int x;
int y;
}food;
struct Snake {
int x;
int y;
int len;
int speed;
}snake; //snake is head
void init_map(void);
void update_food(void);
void move_snake(void);
int is_alive(void);
void get_speed(void);
void gotoxy(int x, int y);
int main()
{
init_map(); //初始化地图
while (1)
{
update_food();
//是否产生食物
get_speed(); //获取速度
move_snake(); //移动蛇身
Sleep(snake.speed);
//移动速度
if (!(is_alive()))
//蛇的死活(撞墙或自食)
break;
}
printf("Game Over!");
_getch();
return 0;
}
//initialize
void init_map(void)
{
//initial food
srand(time(NULL));
food.x = rand() % (frame_height - 2) + 1;
food.y = rand() % (frame_width - 2) + 1;
gotoxy(food.x, food.y);
printf("!");
//initial snake
snake.x = frame_height / 2;
snake.y = frame_width / 2;
gotoxy(snake.x);
printf("@");
snake.len = 3;
snake.speed = 200;
for (k = 1; k《snake.len; k++)
{
snake.x + 1;
snake.y;
gotoxy(snake.x);
printf("@");
}
//initial bar
for (j = 0; j《frame_width; j++)
{
gotoxy(0, j);
printf("#");
gotoxy(frame_height - 1, j);
printf("#");
}
for (i = 1; i《frame_height - 1; i++)
{
gotoxy(i, 0);
printf("#");
gotoxy(i, frame_width - 1);
printf("#");
}
}
//generate food
void update_food()
{
if (snake.x == food.y)
{
srand(time(NULL));
food.x = rand() % (frame_height - 2) + 1;
food.y = rand() % (frame_width - 2) + 1;
gotoxy(food.x, food.y);
printf("!");
snake.len++;
grow = 1;
}
}
//move snake
void move_snake()
{
if (_kbhit())
ch = _getch();
if (!grow)
{
gotoxy(snake.x);
printf(" ");
}
for (k = snake.len - 1; k》0; k--)
{
snake.x;
snake.y;
}
switch (ch)
{
case UP: snake.x--; break;
case DOWN: snake.x++; break;
case LEFT: snake.y--; break;
case RIGHT: snake.y++; break;
default: break;
}
gotoxy(snake.x);
printf("@");
grow = 0;
gotoxy(frame_height, 0);
}
//is alive
int is_alive(void)
{
if (snake.x == 0)
return 0;
for (k = 1; k《snake.len; k++)
if (snake.x)
return 0;
return 1;
}
//speed up
void get_speed(void)
{
if (snake.len 《= 6)
snake.speed = 200;
else if (snake.len 《= 10)
snake.speed = 100;
else if (snake.len 《= 20)
snake.speed = 50;
else if (snake.len 《= 30)
snake.speed = 30;
else snake.speed = 20;
}
//move cursor
void gotoxy(int x, int y)
{
HANDLE hout;
COORD cor;
hout = GetStdHandle(STD_OUTPUT_HANDLE);
cor.X = y;
cor.Y = x;
SetConsoleCursorPosition(hout, cor);
}

更多文章:
抖音小游戏帽子先生大冒险攻略(帽子先生大冒险第16关钥匙在哪)
2026年9月24日 09:00








