高级光能
#include<iostream>
#include<windows.h>
using namespace std;
bool flag,w;
int cnt,x,y,k,o,o1;
int r[105][5]={{0},{0,9,5},{0,14,2},{0,14,2},{0,3,2},{0,3,2},{0,3,2},{0,3,2},{0,14,2},{0,14,2},{0,14,2}};
int map[105][20][20]={{0},{{0},
{0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{0,1,0,3,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,0,1,1,0,0,1,0,0,0,0,0,0,0,1},
{0,1,0,0,1,1,0,1,0,0,0,0,0,0,0,1},
{0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,0,1,1,0,1,1,0,0,0,0,0,0,0,1},
{0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1},
{0,1,0,0,0,2,0,0,0,0,0,0,0,0,0,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,1,0,1,0,1,0,1,1,0,0,0,0,0,1},
{0,1,1,0,1,0,1,0,1,1,0,0,0,0,0,1},
{0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1},
{0,1,1,1,0,1,0,1,1,1,0,0,0,0,0,1},
{0,1,1,1,0,1,0,1,1,1,1,1,1,1,0,1},
},{{0},
{0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,1,0,1,0,0,1,0,0,1,0,0,0,0,1},
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1},
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
{0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1},
{0,1,1,0,0,1,0,0,0,0,0,0,0,1,0,1},
{0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,1},
{0,1,0,0,0,1,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0,0,0,0,0,0,0,0,0},
{0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
}
};
void cls(){
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coordScreen = { 0, 0 }; // home for the cursor
SetConsoleCursorPosition( hConsole, coordScreen );
}
void HideCursor(){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
CursorInfo.bVisible = false; //隐藏控制台光标
SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
}
bool KO(int cnt){
for(int i=1;i<=15;i++){
for(int j=1;j<=15;j++){
if(map[cnt][i][j]==3){
return false;
}
}
}
return true;
}
bool OK(int cnt){
for(int i=1;i<=15;i++){
for(int j=1;j<=15;j++){
if(map[cnt][i][j]==2){
return false;
}
}
}
return true;
}
int main(){
system("color 30");
HideCursor();
cnt=1;
while(cnt){
flag=false,k=1,w=false,o=0,o1=0;
while(true){
cout<<k<<endl;
k++;
for(int i=1;i<=15;i++){
for(int j=1;j<=15;j++){
if(map[cnt][i][j]==2){
cout<<"你";
x=i,y=j;
}else if(map[cnt][i][j]==0){
cout<<"□";
}else if(map[cnt][i][j]==1){
cout<<"■";
}else if(map[cnt][i][j]==3){
cout<<"旗";
}
}
cout<<endl;
}
if(OK(cnt)){
cout<<"你掉进了虚空!!!"<<endl;
Sleep(3000);
system("cls");
map[cnt][r[cnt][1]][r[cnt][2]]=2;
}
if(KO(cnt)){
cout<<"恭喜过关!!!"<<endl;
Sleep(3000);
system("cls");
break;
}
if(map[cnt][x+1][y]!=0||map[cnt][x][y+1]!=0||map[cnt][x][y-1]!=0){
w=true;
}
if(o1==5){
map[cnt][x][y]=0;
map[cnt][x+1][y]=2;
o1=0;
}
cls();
if(GetAsyncKeyState('W')){
int m=0;
if(map[cnt][x+1][y]!=0){
for(int i=1;i<=3;i++){
if(map[cnt][x-i][y]==0||map[cnt][x-i][y]==3){
m=i;
}else break;
}
map[cnt][x][y]=0;
map[cnt][x-m][y]=2;
Sleep(100);
continue;
}else if(w==true){
for(int i=1;i<=3;i++){
if(map[cnt][x-i][y]==0||map[cnt][x-i][y]==3){
m=i;
}else break;
}
map[cnt][x][y]=0;
map[cnt][x-m][y]=2;
Sleep(100);
w=false;
continue;
}
}
if(GetAsyncKeyState('S')&&(map[cnt][x+1][y]!=1||map[cnt][x+1][y]==3)){
map[cnt][x][y]=0;
//if(map[cnt][x+1][y]==3) flag=true;
map[cnt][x+1][y]=2;
Sleep(100);
continue;
}
if(GetAsyncKeyState('A')&&(map[cnt][x][y-1]!=1||map[cnt][x][y-1]==3)){
map[cnt][x][y]=0;
//if(map[cnt][x][y-1]==3) flag=true;
map[cnt][x][y-1]=2;
Sleep(100);
if(map[cnt][x+1][y-1]==0) o++;
if(o>=2){
if(map[cnt][x+1][y-1]==0){
map[cnt][x][y-1]=0;
map[cnt][x+1][y-1]=2;
}
o=0;
x++;
}
continue;
}
if(GetAsyncKeyState('D')&&(map[cnt][x][y+1]!=1||map[cnt][x][y+1]==3)){
map[cnt][x][y]=0;
//if(map[cnt][x][y+1]==3) flag=true;
map[cnt][x][y+1]=2;
Sleep(100);
if(map[cnt][x+1][y+1]==0) o++;
if(o>=2){
if(map[cnt][x+1][y+1]==0){
map[cnt][x][y+1]=0;
map[cnt][x+1][y+1]=2;
}
o=0;
x++;
}
continue;
}
if(map[cnt][x+1][y]==0){
if(map[cnt][x][y+1]==1||map[cnt][x][y-1]==1){
o1++;
}else{
map[cnt][x][y]=0;
//if(map[cnt][x+1][y]==3) flag=true;
map[cnt][x+1][y]=2;
Sleep(100);
}
}
}
cls();
cnt+=1;
}
return 0;
}