[项目分享]c++贪吃蛇

1412浏览
查看: 1412|回复: 7

[项目分享] 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[2];//将光标移动到指定位置 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[100]; int y[100]; 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++){
完成!!!

木子呢  管理员

发表于 2023-11-6 11:27:27

可以完善下排版
回复

使用道具 举报

开朗的小马  见习技师
 楼主|

发表于 2023-11-7 19:45:00


ok!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
回复

使用道具 举报

三春牛-创客  初级技神

发表于 2023-11-10 16:04:47

6666666666
回复

使用道具 举报

三春牛-创客  初级技神

发表于 2023-11-10 16:06:22

为什么没有换行啊?
回复

使用道具 举报

开朗的小马  见习技师
 楼主|

发表于 2023-11-11 18:50:46


嘿嘿  忘了
回复

使用道具 举报

星辰之子  中级技师 来自手机

发表于 2023-11-14 21:24:24

必须参考一下,正好在学C++
回复

使用道具 举报

星辰之子  中级技师

发表于 2023-11-15 20:11:01

c++贪吃蛇图1
WedNovember-202311158273..png
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail