c++贪吃蛇
为了满足有些人回忆童年,所以做了一款贪吃蛇......#include<stdio.h>#include<conio.h>#include<windows.h>#include<time.h>#define framex 5#define framey 5#define wide 20#define high 20int i,j,a;//将光标移动到指定位置 void gotoxy(HANDLE hout,int x,int y){ //COORD是WindowsAPI中定义的一种结构,表示一个字符在控制台屏幕上的坐标 COORD pos; pos.X=x; pos.Y=y; //SetConsoleCursorPosition是API中定位光标位置的函数。 SetConsoleCursorPosition(hout,pos);}//游戏封面void cover (HANDLE hout){ gotoxy(hout,framex+wide,framey); printf("snake——贪吃蛇游戏"); gotoxy(hout,framex+wide,framey+5); printf("开始游戏前请关闭中文输入法"); gotoxy(hout,framex+wide*2,framey+20); printf( "游戏制作者:Joe"); gotoxy(hout,framex+wide*2,framey+22); char a; a=getchar(); system("cls");} //定义蛇的结构体 struct Snake{ int x; int y; int speed; int length; int count;};//定义食物的结构体 struct Food{ int x; int y;};//制作框架 void makeframe(struct Snake snake){ //定义显示器变量句柄 HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE); gotoxy(hout,framex+wide*2+5,framey); printf( " 贪吃蛇游戏"); gotoxy(hout,framex+wide*2+5,framey+3); printf("使用方向键或wasd移动"); gotoxy(hout,framex+wide*2+5,framey+5); printf("长按方向键可加速"); gotoxy(hout,framex+wide*2+5,framey+7); printf("按任意键暂停,方向键继续"); //打印上边框 for(i=0;i<wide*2+1;i++){ gotoxy(hout,framex+i,framey); printf("*"); } //打印下边框 for(i=0;i<wide*2+2;i++){ {:5_131:}
完成!!!
可以完善下排版 木子呢 发表于 2023-11-6 11:27
可以完善下排版
ok!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1 6666666666 为什么没有换行啊? 三春牛-创客 发表于 2023-11-10 16:06
为什么没有换行啊?
嘿嘿忘了 必须参考一下,正好在学C++
{:7_223:}{:7_221:}
页:
[1]