请看下方的视频讲解
#include<stdio.h>
#include<Windows.h>//system
#include<time.h>//time
#include<conio.h>//kbhit
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);
}
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 Running() {//游戏引擎
int x = 14, y = 15;
while(1) {
Sleep(500);//暂停500毫秒
gotodelete(x, y + 2);
y -= 1;
if (y < 1) break;//达到边界就退出
gotoprint(x, y);
}
system("cls");//清除屏幕
system("pause");
}
int...
学完这个课程是不是感觉很棒,快把它安利给你的同学们吧!
登录后开始许愿
代码通俗易懂,我喜欢!