请看下方的视频讲解
#include<stdio.h>
#include<Windows.h>//system
#include<time.h>//time
#include<conio.h>//kbhit
char dir = 1;//方向
int snake_x[1005], snake_y[1005], head = 2, snake_len;
int food_x, food_y;//食物的坐标
void gotoxy(int x, int y){ //将光标移动到x,y坐标
COORD pos;
HANDLE hOutput;
pos.X = x;
pos.Y = y;
hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOutput, pos);
}
void gotoprint(int x, int y){
gotoxy(x, y);
printf("■");
}
void creatgraph() {
for (int i = 0; i<58; i += 2) { //打印上下边框
gotoprint(i, 0);//打印第一行
gotoprint(i, 26);//打印最后一行
}
for (int i = 1; i < 26; i++) { //打印左右边框
gotoprint(0, i);//打印第一列
gotoprint(56, i);//打印最后一列
}
gotoprint(14,15);gotoprint(14,16);gotoprint(14,17);
snake_x[2] = 14; snake_y[2] = 15;//初始化蛇的坐标
snake_x[1] = 14; snake_y[1] = 16;
snake_x[0] = 14; snake_y[0] = 17;
}
void welcome() {
gotoxy(15,6); printf("/**********************************************/\n");
gotoxy(15,8); printf("/* */\n");
gotoxy(15,10); printf("/* 欢迎来到 N诺 贪吃蛇小游戏 ! */\n");
gotoxy(15,12); printf("/* */\n");
gotoxy(15,14); printf("/**********************************************/\n\n\n\n\n\n");
system("pause"); system("cls");//清除屏幕
}
void gotodelete(int x, int y){//清楚x,y坐标的内容
gotoxy(x, y);
printf(" ");
}
void creatfood() {//创建食物
while (1) {
food_y = r...
学完这个课程是不是感觉很棒,快把它安利给你的同学们吧!
登录后开始许愿
为什么createfood在主函数中不能用?