c++小游戏 走迷宫
最近做了一个走迷宫,自我感觉不错。目前制作了10张地图,游玩前需先仔细阅读帮助,不然会无从下手哦!!!查看方法:运行程序,然后按h键。代码如下:
#include<iostream>
#include<windows.h>
#include"GotoXY.h"
#include <conio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
void help();
void migong();
void m();
void help()
{
char ch2;
system("cls");
cout<<"操作说明:"<<endl;
cout<<endl;
cout<<"移动说明:"<<endl;
cout<<"w-向上 s-向下 a-向左 d-向右"<<endl;
cout<<endl;
cout<<"标识说明:"<<endl;
cout<<"&-炸药 @-玩家 #-墙 $-钥匙 ^-地刺 %-传送门 0-可以被炸药炸开的墙"<<endl;
cout<<endl;
cout<<"操作说明:"<<endl;
cout<<"x-爆破(需要炸药) 移动至物品上方-捡起物品 拥有钥匙后接近传送门附近-传送(按任意键继续)"<<endl;
cout<<endl;
cout<<"注意事项:"<<endl;
cout<<"踩到地刺会s哦,请小心"<<endl;
cout<<"按任意键返回"<<endl;
ch2=_getch();
m();
}
void migong()
{
system("cls");
char ch;
srand(time(NULL));
int k;
int z=0;
int key=0;
int zx[100];
int zy[100];
int gq=0;
GotoXY(60,5);
cout<<"TNT x 0";
while (1)
{
int map[10][6][10]={
{
{
1,1,1,1,1,1,1,1,1,1},
{
1,0,3,0,4,0,1,1,0,1},
{
1,0,0,0,0,1,1,1,2,1},
{
1,0,0,0,0,1,1,1,0,1},
{
1,0,0,0,0,0,0,0,0,1},
{
1,1,1,1,1,1,1,1,1,1}
},
{
{
1,1,1,1,1,1,1,1,1,1},
{
1,0,0,0,0,0,1,0,2,1},
{
1,0,1,0,1,1,1,0,0,1},
{
1,0,1,0,0,0,0,0,0,1},
{
1,3,1,0,0,0,0,4,0,1},
{
1,1,1,1,1,1,1,1,1,1}
},
{
{
1,1,1,1,1,1,1,1,1,1},
{
1,0,0,0,0,0,0,2,0,1},
{
1,0,0,3,0,0,0,0,0,1},
{
1,0,0,0,0,0,0,0,6