#include<iostream>
#include<conio.h>
#include<cmath>
#include<Windows.h>
#include<ctime>
#include<cstdlib>
#include<stack>
#include<string>
void color(int a)//颜色函数
{
HANDLE hConsole = GetStdHandle((STD_OUTPUT_HANDLE)) ;
SetConsoleTextAttribute(hConsole,a) ;
}
using namespace std;
int cnt__;
bool redface;
bool gstj;
int tam[1000];
string dd=" ";
int money=0;
bool skf[1000];
string sk="♀";
int xk[1001];
int yk[1001];
int t[10010];
bool key[100];
char maps[100][12][12];
int step;
int allstep;
void pg() {
system("cls");
}
int clr;
int x;
int y;
int xe;
int ye;
/*●■*/
void setmap(int level){
for(int i=0;i<12;++i){
for(int j=0;j<12;++j){
if(i==x&&j==y)maps[level][i][j]='p';
else if(i==xe&&j==ye){
maps[level][i][j]='e';
}
else if(i==xk[level]&&j==yk[level]){
maps[level][i][j]='f';
}
else if(i==0||i==11||j==0||j==11){
maps[level][i][j]='w';
}
else maps[level][i][j]='.';
}
}
}
void new_(int level){
for(int i=0;i<12;++i){
for(int j=0;j<12;++j){
if(i==x&&j==y)maps[level][i][j]='p';
else if(i==xe&&j==ye){
maps[level][i][j]='e';
}
else if(i==xk[level]&&j==yk[level]){
maps[level][i][j]='f';
}
}
}
}
void fillwall(int x1,int y1,int x2,int y2,int level){
if(y1==y2){
for(int i=x1;i<x2;i++){
maps[level][i][y1]='w';
}
}
if(x1==x2){
for(int i=y1;i<y2;i++){
maps[level][x1][i]='w';
}
}
}
void debug(int level){
cout<<"\n";
for(int i=0;i<12;++i){
for(int j=0;j<12;++j){
cout<<maps[level][i][j];
}
cout<<"\n";
}
}
void putnum(int start , int end, int amt){
for(int i=start;i<end;i++){
t[i]=amt;
}
}
void print(string s,bool flg,char a,int point){
for(int i=0;i<s.length();++i){
cout<<s[i];
if(flg){
system("color a0");
system("color 0a");
}
Sleep(t[point]);
point++;
}
cout<<a;
}
char see(){
while(kbhit()){
return getch();
}
}
void fillbox(int as,int bs,int ae,int be,int n){
int cx=as;
int cy=be;
int dx=ae;
int dy=bs;
fillwall(as,bs,cx,cy,n);
fillwall(as,bs,dx,dy,n);
fillwall(ae,be,cx,cy,n);
fillwall(ae,be,dx,dy,n);
}
void fills(int a,int b,int c,int d,int n,char ch){
for(int i=a;i<=c;i++){
for(int j=b;j<=d;j++){
maps[n][i][j]=ch;
}
}
}
void clears(){
for(int i=0;i<100;++i){
xk[i]=100;
yk[i]=100;
}
}
void fillair(int a,int b,int n){
maps[n][a][b]='.';
}
void getmap(int level){
pg();
for(int i=0;i<12;++i){
for(int j=0;j<12;++j){
if(maps[level][i][j]=='w'){
cout<<"■";
}
if(maps[level][i][j]=='f'){
HANDLE hConsole = GetStdHandle((STD_OUTPUT_HANDLE)) ;
SetConsoleTextAttribute(hConsole,4);
cout<<"●";
color(10);
}
if(maps[level][i][j]=='e'){
color(6);
cout<<"╳ ";
color(10);
}
if(maps[level][i][j]=='p'){
if(!redface){
color(11);
cout<<sk;
color(10);
}
else{
color(4);
cout<<sk;
color(10);
for(int i=x-1;i<=x+1;i++){
for(int j=y-1;j<=y+1;j++){
if(maps[level][i][j]=='w'&&i<11&&i>0&&j<11&&j>0)
maps[level][i][j]='.';
}
}
cnt__++;
if(cnt__==5){
redface= false;
cnt__=0;
}
}
}
if(maps[level][i][j]=='.')cout<<dd; //□
}
cout<<"\n";
}
cout<<"click 1:GHOST JUMP ,("<<tam[1]<<")\n";
cout<<"click 2:RED FACE ,("<<tam[2]<<")\n";
cout<<"Step count: "<<step<<"\n";
}
void strt(){
// tam[1]=1000;
// tam[2]=1000;
// money=100000;
allstep=0;
clr=1;
system("cls");
// load out all the maps
// map 1
clears();
key[1]=true;
x=1;
y=1;
xe=1;
ye=1;
setmap(1);
// map 2
key[2]=true;
setmap(2);
fillwall(2,9,11,9,2);
fillwall(1,7,10,7,2);
fillwall(2,5,11,5,2);
fillwall(1,3,10,3,2);
// map 3
setmap(3);
key[3]=false;
xk[3]=3;
yk[3]=4;
fillwall(5,5,5,5,3);
fillbox(2,2,8,8,3);
fillbox(4,4,6,6,3);
fillbox(9,9,1,5,3);
fillbox(7,2,7,4,3);
fillwall(2,2,4,2,3);
// map 4
setmap(4);
key[4]=false;
xk[4]=5;
yk[4]=5;
fills(2,2,9,9,4,'w');
fills(3,3,8,8,4,'.');
fills(4,4,7,7,4,'w');
fills(5,5,6,6,4,'.');
fillair(5,2,4);
fillair(6,7,4);
// map 5
setmap(5);
key[5]=false;
fills(1,4,8,10,5,'w');
fills(1,5,7,10,5,'.');
fills(1,6,6,10,5,'w');
fills(1,7,5,10,5,'.');
fills(1,8,4,10,5,'w');
fills(1,9,3,10,5,'.');
xk[5]=3;
yk[5]=9;
fills(2,9,2,9,5,'w');
fillair(1,8,5);
fillair(6,10,5);
fillair(1,4,5);
fills(2,1,2,2,5,'w');
fills(4,2,4,3,5,'w');
fills(6,1,6,2,5,'w');
fills(8,3,8,4,5,'w');
// map 6
setmap(6);
key[6]=false;
xk[6]=8;
yk[6]=9;
fills(2,2,9,9,6,'w');
fills(2,3,9,3,6,'.');
fills(2,5,9,5,6,'.');
fills(2,7,9,7,6,'.');
fills(2,10,9,10,6,'w');
fills(2,9,9,9,6,'.');
fills(2,1,2,9,6,'w');
fills(9,1,9,9,6,'w');
fillair(2,1,6);
fillair(8,2,6);
fillair(3,4,6);
fillair(8,6,6);
fillair(3,8,6);
fillair(9,1,6);
// map 7
setmap(7);
key[7]=false;
xk[7]=2;
yk[7]=10;
fills(1,2,10,9,7,'w');
fills(2,1,10,1,7,'w');
fills(1,10,9,10,7,'w');
fills(2,1,6,1,7,'.');
fills(6,2,6,3,7,'.');
fills(1,3,5,3,7,'.');
fills(3,4,3,5,7,'.');
fills(1,4,1,6,7,'.');
fills(2,6,2,8,7,'.');
fills(1,8,1,9,7,'.');
fills(3,8,3,9,7,'.');
fills(2,10,3,10,7,'.');
fillair(7,3,7);
fills(8,1,8,3,7,'.');
fillair(9,1,7);
fills(10,1,10,8,7,'.');
fills(5,5,9,5,7,'.');
fillair(9,9,7);
fills(5,6,5,10,7,'.');
fills(6,10,7,10,7,'.');
fills(5,7,7,7,7,'.');
fills(8,7,8,10,7,'.');
fillair(9,10,7);
fills(8,9,8,9,7,'w');
}
int main(){
again:
strt();
int stage=1;
if(clr==0||clr==1){
system("color 0a");
}
else if(clr==2){
system("color fa");
}
else if(clr==3){
system("color 4a");
}
else if(clr==4){
system("color ca");
}
else if(clr==6){
system("color ba");
}
else if(clr==7){
system("color 2a");
}
else if(clr==5){
system("color 5a");
}
// putnum(0,3,50);
// putnum(3,7,200);
// putnum(7,10,50);
putnum(0,27,10);
string s[100]={" -=<[MAZE]>=-","+>----------------==MENU==----------------<+","|CLICK A TO START CLICK B FOR INFO|","|CLICK C FOR SETTINGS CLICK D TO QUIT|","|CLICK E TO BUY SKINS CLICK F TO BUY TOOL|","+>----------------========----------------<+"};//16,24,
int pin=0;
print(s[0],0,'\n',0);
pin=0;
putnum(0,10,50);
c:
cout<<"\n";
putnum(0,160,10);
for(int i=1;i<=5;++i){
print(s[i],0,'\n',pin);
}
bool start=false;
while(1){
switch(see()){
case 'a':
start=true;
break;
case 'b':
goto a;
break;
case 'c':
goto b;
break;
case 'd':
return 0;
case 'e':
goto skin;
case 'f':
goto tool;
default:
continue;
}
if(start==true){
goto stt;
}
}
stt:
step=1;
if(stage==8){
cout<<"CONGRATULATIONS, YOU FINISHED ALL THE LEVELS!\nYOU FINISH ALL THE LEVELS WITH "<<allstep<<" STEPS!\nCLICK 'A' TO TRY AGAIN\nCLICK 'B' TO QUIT.\n";
money+=(allstep+100)/3*2+10+(allstep/100);
cout<<"YOU GOT "<<(allstep+100)/3*2+10+(allstep/100)<<" MONEYS, YOU HAVE "<<money<<" MONEYS.\n";
Sleep(100);
while(1){
switch(see()){
case 'a':
goto again;
case 'b':
return 0;
default:
continue;
}
}
}
pg();
if(stage==3){
cout<<"HINT:STEP ON THE CIRCLE FIRST, AND THEN GO TO THE END POINT\n";
}
x=1;
y=1;
xe=10;
ye=10;
new_(stage);
getmap(stage);
while(1){
// getmap(stage);
res:
switch(see()){
case 'w':
if(gstj){
if(maps[stage][x-2][y]!='w'&&x>=3){
maps[stage][x-2][y]=='p';
maps[stage][x][y]='.';
x-=2;
new_(stage);
getmap(stage);
step+=10;
// debug(stage);
gstj=false;
}
}
else if(maps[stage][x-1][y]!='w'){
maps[stage][x-1][y]=='p';
maps[stage][x][y]='.';
x--;
new_(stage);
getmap(stage);
step++;
// debug(stage);
}
break;
case 's':
if(gstj){
if(maps[stage][x+2][y]!='w'&&x<=8){
maps[stage][x+2][y]=='p';
maps[stage][x][y]='.';
x+=2;
new_(stage);
getmap(stage);
step+=10;
// debug(stage);
gstj=false;
}
}
else if(maps[stage][x+1][y]!='w'){
maps[stage][x+1][y]=='p';
maps[stage][x][y]='.';
x++;
new_(stage);
getmap(stage);
step++;
// debug(stage);
}
break;
case 'a':
if(gstj){
if(maps[stage][x][y-2]!='w'&&y>=3){
maps[stage][x][y-2]=='p';
maps[stage][x][y-2]='.';
y-=2;
new_(stage);
getmap(stage);
step+=10;
// debug(stage);
gstj=false;
}
}
else if(maps[stage][x][y-1]!='w'){
maps[stage][x][y-1]=='p';
maps[stage][x][y]='.';
y--;
new_(stage);
getmap(stage);
step++;
// debug(stage);
}
break;
case 'd':
if(gstj){
if(maps[stage][x][y+2]!='w'&&y<=8){
maps[stage][x][y+2]=='p';
maps[stage][x][y+2]='.';
y+=2;
new_(stage);
getmap(stage);
step+=10;
// debug(stage);
gstj=false;
}
}
else if(maps[stage][x][y+1]!='w'){
maps[stage][x][y+1]=='p';
maps[stage][x][y]='.';
y++;
new_(stage);
getmap(stage);
step++;
// debug(stage);
}
break;
case 'p':
pg();
cout<<"+>-----=PAUSED=-----<+\n";
cout<<"|CLICK M TO END GAME |\n";
cout<<"|CLICK R TO RESUME |\n";
cout<<"+>-----========-----<+\n";
while(1){
switch(see()){
case 'm':
pg();
goto c;
case 'r':
new_(stage);
getmap(stage);
goto res;
}
}
case 'o':
if(dd==" ")dd="□";
else dd=" ";
new_(stage);
getmap(stage);
default:
break;
case '1':
if(tam[1]!=0){
tam[1]--;
cout<<"G H O S T J U M P ! ! ! \n";
gstj=true;
}
break;
case '2':
if(tam[2]!=0){
tam[2]--;
cout<<"R E D F A C E ! ! !\n";
redface=true;
for(int i=x-1;i<=x+1;i++){
for(int j=y-1;j<=y+1;j++){
if(maps[stage][i][j]=='w'&&i<11&&i>0&&j<11&&j>0)
maps[stage][i][j]='.';
}
}
}
break;
}
if(x==xk[stage]&&y==yk[stage]){
key[stage]=true;
}
if(x==xe&&y==ye&&key[stage]==true){
stage++;
cout<<"\nLEVEL COMPLETE!";
Sleep(1000);
pg();
pg();
allstep+=step;
step=0;
goto stt;
}
}
a:
pg();
cout<<"+------------==INFO==------------+\n";
cout<<"|CLICK A TO GO LEFT |\n";
cout<<"|CLICK D TO GO RIGHT |\n";
cout<<"|CLICK W TO GO UP |\n";
cout<<"|CLICK S TO GO DOWN |\n";
cout<<"|CLICK P TO PAUSE |\n";
cout<<"|MOVE TO THE END POINT 'X' TO WIN|\n";
cout<<"|EAT THE DOT TO GET KEY |\n";
cout<<"|CLICK O TO SWITCH MODE |\n";
cout<<"+------------========------------+\n";
goto c;
b:
if(clr==0||clr==1){
system("color 0a");
}
else if(clr==2){
system("color fa");
}
else if(clr==3){
system("color 4a");
}
else if(clr==4){
system("color ca");
}
else if(clr==6){
system("color ba");
}
else if(clr==7){
system("color 2a");
}
else if(clr==5){
system("color 5a");
}
pg();
printf("+------==========SETTING==========------+\n");
printf("|CLICK B TO BACK |\n");
printf("|START AT NO.%d STAGE |\n",stage);
printf("|click 'w' to add stage |\n");
printf("|click 's' to minute stage |\n");
printf("|click 1~7 to choose color |\n");
printf("|click d to add money |\n");
printf("+------===========================------+\n");
while(1){
switch(see()){
case 'b':
goto c;
case 'w':
if(stage<7){
stage++;
cout<<"add success";
Sleep(200);
goto b;
}
else{
cout<<"add failed, ("<<stage+1<<">7)";
system("color 04");
Sleep(500);
goto b;
}
case 's':
if(stage>1){
stage--;
cout<<"remove success";
Sleep(500);
goto b;
}
else{
cout<<"minute failed, ("<<stage-1<<"<1)";
system("color 04");
Sleep(500);
goto b;
}
case '1':
clr=1;
goto b;
case '2':
clr=2;
goto b;
case '3':
clr=3;
goto b;
case '4':
clr=4;
goto b;
case '5':
clr=5;
goto b;
case '6':
clr=6;
goto b;
case '7':
clr=7;
goto b;
case 'd':
cout<<"press the magic key.\n";
while(1){
if(see()=='r'){
cout<<"how many?\n";
int plus;
cin>>plus;
money+=plus;
goto b;
}
else if(see()!='\0'){
system("color 04");
cout<<"WRONG!";
Sleep(500);
goto b;
}
}
}
}
skin:
pg();
if(clr==0||clr==1){
system("color 0a");
}
else if(clr==2){
system("color fa");
}
else if(clr==3){
system("color 4a");
}
else if(clr==4){
system("color ca");
}
else if(clr==6){
system("color ba");
}
else if(clr==7){
system("color 2a");
}
else if(clr==5){
system("color 5a");
}
cout<<"WELCOME TO SKIN SHOP\n";
cout<<"MONEY LEFT:"<<money<<"\n";
cout<<"+----------------=SKIN==SHOP=----------------+\n";
cout<<"| ♀ ∮ ∞ √ ○ ▲ ¤|\n";
cout<<"| 0 500 700 400 500 800 900|\n";
cout<<"| / A B C D E F |\n";
cout<<"+----------------============----------------+\n";
cout<<"click z to back...\n";
while(1){
switch(see()){
case '/':
sk="♀";
goto skin;
case 'a':
if(skf[1]){
sk="∮";
goto skin;
}
if(money>=500){
money-=500;
sk="∮";
skf[1]=true;
cout<<"BOUGHT SUCCESS\n";
Sleep(1000);
pg();
goto skin;
}
system("color 04");
cout<<"\nBOUGHT FAILED(YOUR MONEY:"<<money<<" IS NOT ENOUGH)";
Sleep(500);
goto skin;
case 'b':
if(skf[2]){
sk="∞";
goto skin;
}
if(money>=700){
money-=700;
sk="∞";
skf[2]=true;
cout<<"BOUGHT SUCCESS\n";
Sleep(1000);
pg();
goto skin;
}
system("color 04");
cout<<"\nBOUGHT FAILED(YOUR MONEY:"<<money<<" IS NOT ENOUGH)";
Sleep(500);
goto skin;
case 'c':
if(skf[3]){
sk="√";
goto skin;
}
if(money>=400){
money-=400;
sk="√";
skf[3]=true;
cout<<"BOUGHT SUCCESS\n";
Sleep(1000);
pg();
goto skin;
}
system("color 04");
cout<<"\nBOUGHT FAILED(YOUR MONEY:"<<money<<" IS NOT ENOUGH)";
Sleep(500);
goto skin;
case 'd':
if(skf[4]){
sk="○";
goto skin;
}
if(money>=500){
money-=500;
sk="○";
skf[4]=true;
cout<<"BOUGHT SUCCESS\n";
Sleep(1000);
pg();
goto skin;
}
system("color 04");
cout<<"\nBOUGHT FAILED(YOUR MONEY:"<<money<<" IS NOT ENOUGH)";
Sleep(500);
goto skin;
case 'e':
if(skf[5]){
sk="▲";
goto skin;
}
if(money>=800){
money-=800;
sk="▲";
skf[5]=true;
cout<<"BOUGHT SUCCESS\n";
Sleep(1000);
pg();
goto skin;
}
system("color 04");
cout<<"\nBOUGHT FAILED(YOUR MONEY:"<<money<<" IS NOT ENOUGH)";
Sleep(500);
goto skin;
case 'f':
if(skf[6]){
sk="¤";
goto skin;
}
if(money>=900){
money-=900;
sk="¤";
skf[6]=true;
cout<<"BOUGHT SUCCESS\n";
Sleep(1000);
pg();
goto skin;
}
system("color 04");
cout<<"\nBOUGHT FAILED(YOUR MONEY:"<<money<<" IS NOT ENOUGH)";
Sleep(500);
goto skin;
case 'z':goto c;
}
}
tool:
pg();
if(clr==0||clr==1){
system("color 0a");
}
else if(clr==2){
system("color fa");
}
else if(clr==3){
system("color 4a");
}
else if(clr==4){
system("color ca");
}
else if(clr==6){
system("color ba");
}
else if(clr==7){
system("color 2a");
}
else if(clr==5){
system("color 5a");
}
cout<<"MONEY LEFT:"<<money<<"\n";
cout<<"+-----==========-----+\n";
cout<<"|1.GHOST JUMP 120$|\n";
cout<<"+-----==========-----+\n";
cout<<"+-----==========-----+\n";
cout<<"|2.RED FACE 150$|\n";
cout<<"+-----==========-----+\n";
cout<<"click 0 to back...\n";
while(1){
switch(see()){
case '0':
pg();
goto c;
case '1':
if(money>=120){
money-=120;
cout<<"BOUGHT SUCCESS!\n";
Sleep(500);
tam[1]++;
goto tool;
}
else{
system("color 04");
cout<<"\nBOUGHT FAILED(YOUR MONEY:"<<money<<" IS NOT ENOUGH)";
Sleep(500);
goto tool;
}
case '2':
if(money>=150){
money-=150;
cout<<"BOUGHT SUCCESS!\n";
Sleep(500);
tam[2]++;
goto tool;
}
else{
system("color 04");
cout<<"\nBOUGHT FAILED(YOUR MONEY:"<<money<<" IS NOT ENOUGH)";
Sleep(500);
goto tool;
}
}
}
return 0;
}
C++幽灵迷宫源码
最新推荐文章于 2024-07-25 23:49:52 发布