行业知识
c/c++趣味小游戏集
2026-10-21 01:07:26
来源:互联网转载
c/c++趣味小游戏集
趣味���符界面小游戏集。源码取自或参考网络,可以在Dev-C++中编译的c/c++趣味小游戏。
特别提示:1、走迷宫游戏和推箱子中的黑方块符号,若不会输入可用“囗”(wéi)字代替;2、windows10中使用Dev-C++编译运行没问题,但在windows11中发现失真——对不齐。
一、走迷宫游戏
能随机生成迷宫,用方向键移动A,从“入”口走到“出”口。
源码如下:
#include #include #include #include #define Height 25 //迷宫的高度,必须为奇数#define Width 25 //迷宫的宽度,必须为奇数#define Wall 1#define Road 0#define Start 2#define End 3#define Esc 5#define Up 1#define Down 2#define Left 3#define Right 4int map[Height+2][Width+2];void gotoxy(int x,int y) //移动坐标 {COORD coord;coord.X=x;coord.Y=y;SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord );}void hidden()//隐藏光标{HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);CONSOLE_CURSOR_INFO cci;GetConsoleCursorInfo(hOut,&cci);cci.bVisible=0;//赋1为显示,赋0为隐藏SetConsoleCursorInfo(hOut,&cci);}void create(int x,int y) //随机生成迷{int c[4][2]= {0,1,1,0,0,-1,-1,0};//四个方向int i,j,t;//将方向打乱for (i=0;i{-1,0},{1,0},{0,-1},{0,1}}; /*** 输出墙 ***/void print_wall(){ cout
上一篇:服务器关闭原因怎么写英文?
下一篇:电梯机房是哪里广联达?