#include<iostream>
#include<stdio.h>
#include<string>
#include<conio.h>
#include<windows.h>
using namespace std;
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
string map[15][30][30];
int px = 5, py = 5;
int dir = 0, sc = 1;
const int dx[5] = {-1, -1, 1, 0, 0};
const int dy[5] = {-1, 0, 0, -1, 1};
// 1 上 2 下 3 左 4 右
bool have[25];
/*
1.key
*/
int door[25][2] = {{}, {}, {}, {3, 25}, {20, 1}};
void printmap()
{
system("cls");
for(int i = 1; i <= 25; i++)
{
for(int j = 1; j <= 25; j++)
{
if(i == px && j == py)
{
cout << "我";
}
else cout << map[sc][i][j];
}
cout << endl;
}
//cout << dir << " " << dx[dir] << " " << dy[dir] << endl;
}
void readmap(string file)
{
freopen(file.c_str(), "r", stdin);
for(int i = 1; i <= 25; i++)
{
for(int j = 1; j <= 25; j++)
{
cin >> map[sc][i][j];
}
}
}
string white[50] = {"-", "·", "石"}
void acc(string s)
{
for(int i = 1; i <= )
}
int main()
{
readmap("map1.in");
sc++;
readmap("map2.in");
sc++;
readmap("map3.in");
sc++;
readmap("map4.in");
sc++;
readmap("map5.in");
sc++;
readmap("map6.in");
sc = 1;
freopen("CON", "r", stdin);
cout << "文字游戏" << endl;
cout << "蒟蒻为您倾情献上qwq" << endl;
system("pause");
printmap();
while(1)
{
char s = getch();
if(s == 'w')
{
dir = 1;
if(px >= 2 && map[sc][px - 1][py] == "·") px--;
else continue;
printmap();
}
if(s == 's')
{
dir = 2;
if(px <= 24 && map[sc][px + 1][py] == "·") px++;
else continue;
printmap();
}
if(s == 'a')
{
dir = 3;
if(py >= 2 && map[sc][px][py - 1] == "·") py--;
else continue;
printmap();
}
if(s == 'd')
{
dir = 4;
if(py <= 24 && map[sc][px][py + 1] == "·") py++;
else continue;
printmap();
}
if(s >= '0' && s <= '9')
{
sc = s - '0';
printmap();
}
if(s == 'q')
{
string now = map[sc][px + dx[dir]][py + dy[dir]];
if(now == "门")
{
sc++;
px = 5;
py = 5;
}
if(now == "钥")
{
map[sc][px + dx[dir]][py + dy[dir]] = "·";
have[1] = true;
}
if(now == "锁")
{
if(have[1])
{
map[sc][px + dx[dir]][py + dy[dir]] = "·";
have[1] = false;
}
}
if(now == "锁")
{
if(have[1])
{
map[sc][px + dx[dir]][py + dy[dir]] = "·";
have[1] = false;
}
}
if(now == "关")
{
map[sc][px + dx[dir]][py + dy[dir]] = "开";
map[sc][door[sc][0]][door[sc][1]] = "门";
}
printmap();
}
}
return 0;
}
#include<iostream>
#include<stdio.h>
#include<string>
#include<conio.h>
#include<windows.h>
using namespace std;
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
string map[15][30][30];
int px = 5, py = 5;
int dir = 0, sc = 1;
const int dx[5] = {-1, -1, 1, 0, 0};
const int dy[5] = {-1, 0, 0, -1, 1};
// 1 上 2 下 3 左 4 右
bool have[25];
/*
1.key
*/
int door[25][2] = {{}, {}, {}, {3, 25}, {20, 1}};
void printmap()
{
system("cls");
for(int i = 1; i <= 25; i++)
{
for(int j = 1; j <= 25; j++)
{
if(i == px && j == py)
{
cout << "我";
}
else cout << map[sc][i][j];
}
cout << endl;
}
//cout << dir << " " << dx[dir] << " " << dy[dir] << endl;
}
void readmap(string file)
{
freopen(file.c_str(), "r", stdin);
for(int i = 1; i <= 25; i++)
{
for(int j = 1; j <= 25; j++)
{
cin >> map[sc][i][j];
}
}
}
string white[50] = {"-", "·", "石"}
void acc(string s)
{
for(int i = 1; i <= )
}
int main()
{
readmap("map1.in");
sc++;
readmap("map2.in");
sc++;
readmap("map3.in");
sc++;
readmap("map4.in");
sc++;
readmap("map5.in");
sc++;
readmap("map6.in");
sc = 1;
freopen("CON", "r", stdin);
cout << "文字游戏" << endl;
cout << "蒟蒻为您倾情献上qwq" << endl;
system("pause");
printmap();
while(1)
{
char s = getch();
if(s == 'w')
{
dir = 1;
if(px >= 2 && map[sc][px - 1][py] == "·") px--;
else continue;
printmap();
}
if(s == 's')
{
dir = 2;
if(px <= 24 && map[sc][px + 1][py] == "·") px++;
else continue;
printmap();
}
if(s == 'a')
{
dir = 3;
if(py >= 2 && map[sc][px][py - 1] == "·") py--;
else continue;
printmap();
}
if(s == 'd')
{
dir = 4;
if(py <= 24 && map[sc][px][py + 1] == "·") py++;
else continue;
printmap();
}
if(s >= '0' && s <= '9')
{
sc = s - '0';
printmap();
}
if(s == 'q')
{
string now = map[sc][px + dx[dir]][py + dy[dir]];
if(now == "门")
{
sc++;
px = 5;
py = 5;
}
if(now == "钥")
{
map[sc][px + dx[dir]][py + dy[dir]] = "·";
have[1] = true;
}
if(now == "锁")
{
if(have[1])
{
map[sc][px + dx[dir]][py + dy[dir]] = "·";
have[1] = false;
}
}
if(now == "锁")
{
if(have[1])
{
map[sc][px + dx[dir]][py + dy[dir]] = "·";
have[1] = false;
}
}
if(now == "关")
{
map[sc][px + dx[dir]][py + dy[dir]] = "开";
map[sc][door[sc][0]][door[sc][1]] = "门";
}
printmap();
}
}
return 0;
}