#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
#include <iostream>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0) //用来检测按键的点击事件
POINT p;
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
HWND h=GetForegroundWindow();
CONSOLE_FONT_INFO consoleCurrentFont;
using namespace std;
void S(int x,int y)
{
COORD pos;
pos.X=y,pos.Y=x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void H() {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
cciCursor.bVisible = FALSE;
SetConsoleCursorInfo(hStdOut, &cciCursor);
}
}
void C(int wr,int wg,int wb,int br,int bg,int bb) {
printf("\033[38;2;%d;%d;%dm\033[48;2;%d;%d;%dm",wr,wg,wb,br,bg,bb);
}
struct ss{
int x,y;
};
int gs=5;
ss f[5]={{27,2},{27,2},{27,2},{27,2},{27,2}};
ss portal[5]={{0,0},{0,0},{0,0},{0,0},{13,28}};
char ma[5][33][104]={
{
{"####################################################################################################"},
{"# #"},
{"# #"},
{"# #"},
{"# [] #"},
{"# ######################### #"},
{"# #"},
{"# #"},
{"# ################ #"},
{"# #"},
{"# 第一关: ☆ #"},
{"# ############# #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# !! #"},
{"# ##################### #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# ############### #"},
{"# #"},
{"# #"},
{"# #"},
{"# !! #"},
{"####################################################################################################"}
},
{
{"####################################################################################################"},
{"# | #"},
{"# | #"},
{"# | #"},
{"# | #"},
{"# 第二关:☆☆ | #"},
{"# | #"},
{"# | #"},
{"# | #"},
{"# | []#"},
{"# ######################## ########### #######"},
{"# ########### # #"},
{"# # #"},
{"# # o !!!!!!#"},
{"# ######################################################"},
{"# #"},
{"# ################# #"},
{"# #"},
{"# #"},
{"# ################ #"},
{"# #"},
{"# #"},
{"# ################## #"},
{"# #"},
{"# #"},
{"# ################### #"},
{"# #"},
{"# #"},
{"# #"},
{"################################### #"}
},
{
{"####################################################################################################"},
{"# | #"},
{"# | #"},
{"# | #"},
{"# | #"},
{"# | ######################### #"},
{"# [] | #"},
{"############### #"},
{"# ################ ######################## #"},
{"# #"},
{"# #"},
{"# ############ #"},
{"# #"},
{"# ####################### #"},
{"# o #"},
{"# ############### ###### ######"},
{"# #"},
{"# !! #"},
{"# ##################### #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# 第三关:☆☆☆☆ #"},
{"# ############ #"},
{"# #"},
{"# #"},
{"# #"},
{"# !! #"},
{"####################################################################################################"}
},
{
{"####################################################################################################"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# 第四关:☆☆☆ #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# #"},
{"# ####### #"},
{"# # #"},
{"# # #"},
{"# # #"},
{"# ######## ######################################################## #"},
{"# # # #"},
{"# # ################################################# # #"},
{"# # # | # # #"},
{"# # # [] | # # #"},
{"# # ############################################## # # #"},
{"# ## # # # # #"},
{"# # # ############################################## # #"},
{"# # # o !! #"},
{"### ######## ######################################################## ############################"}
},
{
{"####################################################################################################"},
{"# | #"},
{"# | #"},
{"# | # ! #"},
{"# | # [] ! #"},
{"# |{} # ! #"},
{"############## ############## !!!!!!! 第五关:o ☆☆☆☆ #"},
{"# # #"},
{"# #################### # #"},
{"# !!!!!!!!!!!!!!!!!!!!!!! # #"},
{"# # #"},
{"# ############################## #"},
{"# # ########################## #"},
{"# ---# # #"},
{"################################ # #"},
{"# # #"},
{"# # #"},
{"# # #"},
{"# # # # # # #"},
{"# # #"},
{"# !!!!!!!!!!!!!!!!?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # #"},
{"# # #"},
{"# # #"},
{"# ##################### # #"},
{"# # #"},
{"# # #"},
{"# ############## #"},
{"# # #"},
{"# # --- #"},
{"####################################################################################################"}
}
};
int bou=0;
bool bou2;
char con;
bool tg=0;
int main(){
H();
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dwInMode, dwOutMode;
GetConsoleMode(hIn, &dwInMode);
GetConsoleMode(hOut, &dwOutMode);
dwInMode |= 0x0200;
dwOutMode |= 0x0004;
SetConsoleMode(hIn, dwInMode);
SetConsoleMode(hOut, dwOutMode);
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
DWORD mode;
GetConsoleMode(hStdin, &mode);
mode &= ~ENABLE_QUICK_EDIT_MODE;
SetConsoleMode(hStdin, mode);
while(1){
for(int g=0;g<gs;g++){
if(tg==1){
cout<<"是否跳过第"<<g+1<<"关? A.是 B.否";
char ph;
ph=getch();
system("cls");
if(ph=='A')continue;
}
bool an;
for(int i=0;i<30;i++){
for(int j=0;j<104;j++){
if(ma[g][i][j]=='!'){
C(255,0,0,255,0,0);
cout<<' ';
C(255,255,255,0,0,0);
continue;
}
cout<<ma[g][i][j];
}
cout<<endl;
}
bou=0;
bou2=0;
int x,y;
x=f[g].x;
y=f[g].y;
while(ma[g][x][y]!='['&&ma[g][x][y]!=']'){
if(x>30){
g-=1;
break;
}
if(ma[g][x][y]=='o'){
an=1;
}
if(ma[g][x][y]=='-'){
S(x,y);
cout<<' ';
x=portal[g].x;y=portal[g].y;
}
if(_kbhit()){
con=getch();
}
else con=' ';
S(x,y);
cout<<' ';
if(ma[g][x][y]=='!'){
system("cls");
x=f[g].x;
y=f[g].y;
for(int i=0;i<30;i++){
for(int j=0;j<104;j++){
if(ma[g][i][j]=='!'){
C(255,0,0,255,0,0);
cout<<' ';
C(255,255,255,0,0,0);
continue;
}
if(ma[g][i][j]=='o'&&an==1){
cout<<' ';
}
else cout<<ma[g][i][j];
}
cout<<endl;
}
}
if(con=='w'&&bou==0&&bou2==0){
bou2=1;
}
if(bou2&&bou<9){
if(ma[g][x-1][y]=='#'){
bou=0;
bou2=0;
}
else{
bou++;
x--;
}
}
else {
bou2=0;
bou=0;
}
if(bou2==0&&ma[g][x+1][y]!='#'){
bou=1;
x++;
}
if(con=='a'&&ma[g][x][y-1]!='#'&&ma[g][x][y-1]!='|'){
y--;
}
if(con=='a'&&ma[g][x][y-1]=='|'&&an==1){
y--;
}
if(con=='d'&&ma[g][x][y+1]!='#'&&ma[g][x][y+1]!='|'){
y++;
}
if(con=='d'&&ma[g][x][y+1]=='|'&&an==1){
y++;
}
S(x,y);
cout<<'A';
Sleep(50);
S(31,0);
}
an=0;
system("cls");
}
tg=1;
system("cls");
}
return 0;
}
代码不是我写的,有一个好处是
地图能自己改,有用,好玩,本人改了改,加入惯性,给个关注吧在玩吧