#include<iostream> //□■□□ □□■□ □□□□
#include<windows.h> //■■□□ □□■■ □■□□
#define w 12 //□■□□ □□■□ ■■□□
#define h 10 //□□□□ □□□□ □■□□
#include<conio.h>
int map[w*h]={};
char* S[]={"□","■","※"};
int px = 1 ;
int py = 1 ;
bool want = false;
void draw()
{
int Tmap[w*h]={};
memcpy(Tmap,map,w*h*4);
Tmap[px+py*w] = 2 ;
for(int y = 0 ;y < h ;++y)
{
for(int x = 0; x < w ;++x)
{
std::cout<<S[Tmap[x+y*w]];
}
std::cout<<std::endl;
}
}
void run()
{
int g = _getch();
if((g == 'W' || g == 'w')&& py>0)py--;
if((g == 'S' || g == 's')&& py<h-1)py++;
if((g == 'A' || g == 'a')&& px>0)px--;
if((g == 'D' || g == 'd')&& px<w-1)px++;
if(g == ' ')
{
map[px+py*w] = 1;
}
if(g == 'H' || g == 'h')
{
want = true;
}
}
void drawX(int a)
{
int D_map[w*h]={};
if(a == 1)
{
memcpy(D_map,map,w*h*4);
}
else if(a == 2)
{
for(int y = 0 ;y < h ;++y)
{
for(int x = 0; x < w ;++x)
{
D_map[x + y*w] = map[w-1-x + y*w];
}
}
}
else if(a == 3)
{
for(int y = 0 ;y < h ;++y)
{
for(int x = 0; x < w ;++x)
{
D_map[x + y*w] = map[x + (h-1-y)*w];
}
}
}
else if(a == 4)
{
for(int y = 0 ;y < h ;++y)
{
for(int x = 0; x < w ;++x)
{
D_map[x + y*w] = map[w-1-x + (h-1-y)*w];
}
}
}
else if(a == 5)
{
return ;
}
for(int y = 0 ;y < h ;++y)
{
for(int x = 0; x < w ;++x)
{
std::cout<<S[D_map[x+y*w]];
}
std::cout<<std::endl;
}
}
void main()
{
while(1)
{
system("cls");
std::cout<<"请用空格设置地图,w、s、a、d方向\n";
draw();
run();
if(want)
{
system("cls");
std::cout<<"1:正常显示\n";
std::cout<<"2:左右镜像\n";
std::cout<<"3:上下镜像\n";
std::cout<<"4:左右上下镜像\n";
std::cout<<"5:退出\n";
std::cout<<"请选择:";
int hh;
std::cin>>hh;
drawX(hh);
system("pause");
}
}
system("pause");
}