一个超级简单且粗糙的走迷宫游戏,控制“同心圆”走到“出”的位置。
如果想要不必回车,摁下WASD四个键,同心圆就可以走动;只需要加入头文件conio.h ,然后将111、112行的代码替换为c=getch();
open函数启动开始界。
Creative函数创建迷宫。
Ismaze判断迷宫是否能够走通。
Printmaze打印迷宫的现态。
代码:
#include<iostream>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<windows.h>
using namespace std;
int flag;
int x=1,y=1;
int maze[30][30];
char name[100];
bool vis[30][30];
struct Node
{
int x,y;
};
void open()
{
cout<<"\n\n---Welcome to Maze!---"<<endl<<endl;
cout<<"Enter 1 to start the game."<<endl;
cout<<"Enter 0 to over the game.\n"<<endl;
cout<<" --Made by jack_jxnu\n"<<endl;
cin>>flag;
while(flag!=1&&flag!=0)
{
cout<<"Please enter a legal number!\n";
cin>>flag;
}
if(!flag) return ;
system("cl