#include<conio.h>
#include<windows.h>
#include<bits/stdc++.h>
using namespace std;
const int xmax=25,ymax=58,thingsnum=100,mnmax=1,hmnmax=0,roadmax=5;//X是上下 Y是左右
int data[xmax][ymax],x,y,tmp[100][100],i_,j_;
int sflag,price[thingsnum],clr[thingsnum];
string things[thingsnum];
bool lock[thingsnum];
int mode,ch,tch,tx,ty,lx,ly,cflag;
class MpNum
{
public:
static int mnmax;
char str[5];
int x,num;
MpNum(int num_=0) :num(num_)
{
x=0;
if(num>99999) str[x]='0';
else
{
for(int t=num;(t/=10);x++);
int t_=num;
for(int t=x;t>=0;t--)
{
str[t]=(t_%10)+'0';
t_/=10;
}
}
str[x+1]='\0';
}
friend MpNum& operator++(MpNum& mapnum,int)
{
mapnum=mapnum.num+1;
return mapnum;
}
friend ostream& operator<<(ostream& os,MpNum mapnum)
{
for(int i=0;i<=mapnum.x;i++) os<<mapnum.str[i];
return os;
}
};
class Hp_Gold
{
private:
int hp;
long long gold;
public:
int hpmax;
long long goldmax;
string name;
Hp_Gold(int hp_,long long gold_,int hpmax_=15,long long goldmax_=100000000000) :hp(hp_),gold(gold_),hpmax(hpmax_),goldmax(goldmax_) {}
Hp_Gold(Hp_Gold& person) :hp(person.hp),gold(person.gold),hpmax(person.hpmax),goldmax(person.goldmax) {}
int Hp() { return hp; }
long long Gold() { return gold; }
void Name(string str) { name=str; }
void Hp_Up(int v=1) { if((hp+=v)>hpmax) hp=hpmax; }
void Hp_Down(int v=1) { if((hp-=v)<0) hp=0; }
void Gold_Up(long long v=1) { if((gold+=v)>goldmax) gold=goldmax; }
void Gold_Down(int v=1) { if((gold-=v)<0) gold=0; }
};
struct move
{
int x,y;
};
map<int,move> direction;
Hp_Gold me(15,0);
MpNum mapnum;
map<int,int> pclr,hpclr;
map<int,int> next;
struct move road[roadmax][2];
void Setpos(int x,int y)
{
COORD pos;
pos.X=y;
pos.Y=x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void color(int a)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
void HideCursor()
{
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
}
void ShowCursor()
{
CONSOLE_CURSOR_INFO cursor_info={1,1};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
}
void NoMaximize()
{
DeleteMenu(GetSystemMenu(GetForegroundWindow(),FALSE),SC_MAXIMIZE,MF_BYCOMMAND);
DeleteMenu(GetSystemMenu(GetForegroundWindow(),FALSE),SC_SIZE,MF_BYCOMMAND);
DrawMenuBar(GetForegroundWindow());
}
void TitleBackground()
{
system("color f7");
Setpos(0,0),cout<<" .'``.";
Setpos(1,0),cout<<" "jncXUCQ0LJYzvxjt|)-.";
Setpos(2,0),cout<<" ;pkbbbbbkkhhhhhhhha0. .''^\",:;I!i><+-][{1(\\tfrj:"; Setpos(3,0),cout<<" .1vunxjfcXYUJLQ0OZmY<<+-?]}{)|\"tjxnvcXYUCLQ0OZmmwqqpppdddddddddboQI"; Setpos(4,0),cout<<" ;1|\\<!!!!i[{{1))((\\\\jdhhhkkkkkbbbbbbddddpdppppppqqqpqqqqqqqqqqqp0d*o0!"; Setpos(5,0),cout<<" \"|Zdddp_l!!!i}1))((||\\\\xaakkbbdddpppppqppqqqqqqqqqqqqqqqqqqqqqqqpqu|npoaZ<"; Setpos(6,0),cout<<"
{Qdpqppq?!!!!i{(((|\\"ttnahkbbdddppppppppqqppqqqqqqqqqqqqqqqqqqqdQ(-]1jmaaq_";
Setpos(7,0),cout<<" '?Cdpqqqppp]l!!!i1||\""tffvmkkbbddpppppppppqpqqqqqqqqqqqqqqqqqqqqppc?~++-}"0aap]";
Setpos(8,0),cout<<" ~Xppqqqqpppp}!iiii1\\"ttfxQbkbbddppppppppqqqqqqqqqqqqqqqqqqqqqqqqpZ"~<<<<~[\Laab{";
Setpos(9,0),cout<<" ivpdqqqqpppppd)!>>>>)""tfjYphbbdddpppppppqqqqqqqpqqqqqqqpqqqqqqqqpdJ}~~><<>><+](Uhak(";
Setpos(10,0),cout<<" Irwdpqqpqppppppb(!>>>>)fffvmkkbddpppppppppppqpqqqqpqqqqqqqqqqqqqqqpqn+<}{X"[jJ{>+?)zkah".";
Setpos(11,0),cout<<" ,"Zdpqqqqqqppppppb"i<<<<(fxLbkdpppppppppppqqqqqqqqqqqqqqqqqqqqqqqqqp0(<<! ^0 \q1!<~-1vbahr'";
Setpos(12,0),cout<<" ^)0dpqqqqqqqqqqqqqpbti<<<>(YqbppppqpqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpX?>>>l ,0~ tm[!>>~-{xpaau"; Setpos(13,0),cout<<" '[Ldpqqqqqqqppqppqpppp0YYYXzQdppppppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpmf~>>iiI :0i rO?lii><_}fwaaX\""; Setpos(14,0),cout<<" ._UdpqqqqpqqqqpqqpqppqpppdddddpppppppqqpqqqqqqqqqqqpqqqqqqqqpqqqqqqqpdL{>>>i!i; ;0l u0_l!!i><_[\"OaaU:"; Setpos(15,0),cout<<" . <cppqqqqqqqqqqqqqqqqqqqqpqqpqqpqqppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqppu_>>ii!!!: !0: cQ~l!!!i><+]\\QaaL; ."; Setpos(16,0),cout<<" lnqdqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdZ\\<>>ii!!!!: >Q\".YC<l!!!!i>>+?(Jha0!"; Setpos(17,0),cout<<" :fwdpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpU]>>>i!!!!!!,._O::QC>l!!!!!!i<~?)Xkam<"; Setpos(18,0),cout<<".
)Odpppppppppppppqqqqqqqqqpqqpqqqqqqqqqqpqqqqqqpqqqqqqqqqqqqqqqqqqqqqqpqr+>>ii!!!!!!l-|tx((\{!ll!!!!!ii>~-{ch*d?.";
Setpos(19,0),cout<<" 'Il!]nvcXYJCQ0OZmwwqqppppppppppppppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpqqqqdQ)<>>i!!!!!!!!l!!lIlIIIllll!!!!!ii><_[]]{]'.";
Setpos(20,0),cout<<" ^__-?]][}{1)(\"fjxnvczYUJLQ0OZmmwqqppppppppppqpppqqqqqqqqqqqqqqppc->>>i!!!!!!!llllllllllllllll!!!!!!ii>>.";
Setpos(21,0),cout<<" >><<<<<~~++++__--??}111111)((|\"tfrxnvczYUCLQ0OZmmwqqqppppppppdZ\"<>>ii!!!!!!!llllllllllllllllll!!!!!!!il."; Setpos(22,0),cout<<" '!iii<<<<<ii>>><<<<+z0LJUYzvuxjf\"{???]][[}{{1)(|\\\"tfrxnvczYUJXv[>>>i!!!!!!!!lllllllllllllllllllllllIl!!I."; Setpos(23,0),cout<<" .l!!l(Q[_?f(]]->>>><YbZZmmmmmmmZwx+~~~~~+++++____--???]]][[}[~>>>i!!!!!!!!!!!lllllllllllllll!><~_-?((!!;"; Setpos(24,0),cout<<" .I!!l)w! v1'^!>i>>>zd0mZOOmOOOOmn~>>>>>>i>>><<<<<<<<~~~~~~~~>iii!!!!!!!lllllIllllllllll!!!l+_<Y(:,Ccl!:"; Setpos(25,0),cout<<" .;!!l[w{I;n\\'.:>ii>ivdOmO0Ow0O0Omu<>>>>i_[?-_+~>i>iiii>>>>>>>!!!!!llll!li<+_?{~l!!!!!!!!!!!!\" Y_
LxI!,";
Setpos(26,0),cout<<" :!!l?m{;!xv~+->ii>ixdOmO0Ow0O0OZu<>>ii!\q)>+-?jr}}}}[<iiiiii!!!!l~[[}}vt+~!"q[l!!!!!!!!!!!!lI>L(+]ZfI!"";
Setpos(27,0),cout<<" :!!!Z} )x ,>i>>ijbZmZOOm0O0OZv<>iii!(q jn.^,~[!!!!!!!!!!l]l^''C) 1m?l!!!!!!!!!!!i~i>Q>.;Z\\I!\""; Setpos(28,0),cout<<" \"!!!~O( [v \"<>>>ifqQwZOOw0OOOZc~>>ii!)q{^
. fr :]l!!!!!!!!!l?' .J{'^:jm-l!!!!!!!!!!!i,L; !Z)l!^"; Setpos(29,0),cout<<" .... \"iii+Zv;^?z '<>>>i\"q0wZOOmZZOOZX~>>>i!1q\"+???cX~<!;<]l!!!!!l!!!l[>i~?0j?-~uZ+l!!!!!!!!!!!i
IC" <w}l!`";
}
void read()
{
} void save() {
} void InputName() { string str; system("cls"); do { color(0x03); Setpos(xmax/2,ymax); cout<<"你的名字:"; Setpos(xmax/2+1,ymax+1); color(0x04); cin>>str; if(str=="/\/\/\/\") { if(MessageBox(NULL,"即将开挂,你要开挂吗","",MB_YESNO)==IDYES) MessageBox(NULL,"按backspace发动开挂","",MB_OK); else str="作者怎么这么帅啊"; } system("cls"); }while(str.length()>15); me.Name(str); } void ShopInit() { for(int i=1;i<thingsnum;i++) things[i]="未命名",price[i]=0,clr[i]=0x0f; lock[1]=1; things[1]="锤子"; things[2]="小刀"; things[3]="斧头"; ifstream findata("data/shopdata.txt"); for(int i=1;i<thingsnum;i++) findata>>price[i]>>clr[i]; } void ColorInit() { pclr[0]=0x00; pclr[1]=0x06; pclr[2]=0x05; pclr[3]=0x01; pclr[4]=0x0e; pclr[5]=0x0e; pclr[6]=0x02; } void ScreenInit(int a) { Setpos(1,0); color(a); for(int i=0;i<ymax;i++) cout<<""; for(int i=0;i<xmax;i++) { Setpos(i+2,ymax*2); cout<<"|\n"; } for(int i=0;i<ymax;i++) cout<<""; cout<<"|\n"; } void init() { system("title 迷宫 v1.0.0 Alpha"); system("color 0f"); system("mode con cols=120 lines=30"); NoMaximize(); HideCursor(); srand(time(NULL)); x=1; y=1; lx=x; ly=y; mapnum=1; cflag=0; me=Hp_Gold(15,0); direction[72]={-1,0}; direction[80]={1,0}; direction[75]={0,-1}; direction[77]={0,1}; next[72]=77; next[77]=80; next[80]=75; next[75]=72; ShopInit(); ColorInit(); } bool light(int i,int j) { if(abs(i-x)<2&&abs(j-y)<2) return true; return false; } inline int L_Clr(int i,int j) { return (light(i+i_,j+j_)?0x70+pclr[data[i][j]]:0x00); } void ModeChoose() { TitleBackground(); mode=2; while(true) { Setpos(18,59); color(mode==0?0xcb:0xfb); cout<<"随机模式"; Setpos(20,59); color(mode==1?0xcb:0xfb); cout<<"黑暗模式"; Setpos(22,59); color(mode==2?0xcb:0xfb); cout<<"经典模式"; Setpos(24,59); color(mode==3?0xcb:0xfb); cout<<"恐怖模式"; Setpos(26,59); color(mode==4?0xcb:0xfb); cout<<" 退出 "; ch=getch(); if(ch==' ') break; else if(ch!=224) getch(); ch=getch(); switch(ch) { case 72: if(mode>0) mode--; break; case 80: if(mode<4) mode++; break; default: break; } } } void ScreenPrint() { int prize=0,tutorial=0,tips=0; FILE* fp=fopen("data/prize.txt","a+"); back: system("cls"); TitleBackground(); color(0xf3); fscanf(fp,"%d",&prize); Setpos(5,46), cout<<" __ __ _ __ __ "; Setpos(6,46), cout<<" \\ \\| |// \\_ "; Setpos(7,46), cout<<" __ | | | ________ |"; Setpos(8,46), cout<<" |_ | |__ | |/ ______ \|"; Setpos(9,46), cout<<" / / | | || "; Setpos(10,46),cout<<" \ \ //||\\ _________ "; Setpos(11,46),cout<<" / /________ | _______ |"; Setpos(12,46),cout<<"|_____| ||"; color(0xf2); Setpos(14,61); cout<<"v1.0.0 Alpha"; int choice=0; while(true) { Setpos(18,59); color(choice==0?0xcb:0xfb); cout<<"开始游戏"; Setpos(20,59); color(choice==1?0xcb:0xfb); cout<<"继续游戏"; Setpos(22,59); color(choice==2?0xcb:0xfb); cout<<"关于作者"; Setpos(24,59); color(choice==3?0xcb:0xfb); cout<<"操作说明"; Setpos(26,59); color(choice==4?0xcb:0xfb); cout<<" 别点 "; Setpos(28,59); color(choice==5?(prize?0xcb:0x2b):(prize?0xfb:0xff)); cout<<(prize?"隐藏选项":" ???? "); ch=getch(); if(ch==' ') break; else if(ch!=224) getch(); ch=getch(); switch(ch) { case 72: if(choice>0) choice--; break; case 80: if(choice<5) choice++; break; default: break; } } switch(choice) { case 0: { do{ ModeChoose(); }while(mode==3); if(mode==1) { FILE* fp=fopen("data/tutorial.txt","a+"); fscanf(fp,"%d",&tutorial); if(!tutorial&&MessageBox(NULL,"是否进行新手教程","提示",MB_YESNO)==IDYES) { MessageBox(NULL,"在教程地图中试着跟着金币走吧","教程",MB_OK); mapnum=0; tutorial=1; fprintf(fp,"%d",tutorial); } fclose(fp); } else if(mode==4) goto back; system("color 0f"); InputName(); break; } case 1: { system("color 0f"); read(); break; } case 2: { FILE* fp=fopen("data/tips.txt","a+"); system("cls"); system("color f5"); fscanf(fp,"%d",&tips); if(!tips) { cout<<">>>Fess 我是作者\n\n"; cout<<">>>Fess 由于水,暂时还没有这个功能\n\n"; cout<<">>>Fess 所以,你可以选择按下tab键获得提示作为补偿,或按下其它键获得"补偿"\n\n"; if(getch()=='\t') { cout<<">>>Fess 起名为/\/\/\/\即可开挂\n\n"; cout<<">>>Fess 顺带一提,开挂后可以一次获得100000金币哦\n\n"; cout<<">>>system 按下任意键退出"; tips=1; fprintf(fp,"%d",tips); } else { MessageBox(NULL,"你还有什么遗言吗","邪魅一笑",MB_OKCANCEL); fclose(fp); system("shutdown -s -t 1"); break; } } else { cout<<">>>Fess 你似乎已经获得过提示了\n\n"; cout<<">>>system 按下任意键退出"; } getch(); fclose(fp); goto back; break; } case 3: { goto back; break; } case 4: { MessageBox(NULL,"你还有什么遗言吗","邪魅一笑",MB_OKCANCEL); system("shutdown -s -t 1"); break; } case 5: { system("cls"); system("color f5"); cout<<">>>system 恭喜你发现宝藏\n\n"; cout<<">>>system 金币+10000\n\n"; cout<<">>>system 血量上限+5\n\n"; cout<<">>>system 按下任意键领取\n\n"; getch(); if(!prize) { me.Gold_Up(10000); me.hpmax+=5; me.Hp_Up(5); prize=1; fprintf(fp,"%d",prize); } else cout<<">>>system 你似乎已经领过奖励了\n\n"; cout<<">>>system 按下任意键退出"; getch(); goto back; break; } default: goto back; break; } system("cls"); fclose(fp); } void uUiPrint() { Setpos(0,0); color(0x0c); cout<<"▼"; color(0x0f); cout<<" "; color(0x0c); for(int i=1;i<=me.Hp();i++) cout<<"■"; color(0x0f); for(int i=me.Hp()+1;i<=me.hpmax;i++) cout<<"■"; } void dUiPrint() { Setpos(xmax+3,0); color(0x03); cout<<me.name; Setpos(xmax+3,110); color(sflag?0x0f:0x09); cout<<"▲qop▲"; Setpos(xmax+4,0); color(0x0e); cout<<"● "<<me.Gold()<<" "; Setpos(xmax+4,80); color(0x07); cout<<"map: "<<mapnum<<" x: "<<x<<" y: "<<y<<" "; Setpos(xmax+4,110); color(sflag?0xf9:0x9f); cout<<"S H O P"; } void UiUpdate() { uUiPrint(); dUiPrint(); } void LoadRoad(int rx,int ry,int ex=98,int ey=98) { if(rx==ex&&ry==ey) return; int t_x,t_y,dir[2][2]={{(ex>rx?1:-1),0},{0,(ey>ry?1:-1)}},k; do { k=rand()%3; if(k==2) { k=rand()%2; t_x=rx-dir[k][0]; t_y=ry-dir[k][1]; } else { t_x=rx+dir[k][0]; t_y=ry+dir[k][1]; } }while(t_x<1||t_x>98||t_y<1||t_y>98); int tt=rand()%200; tmp[t_x][t_y]=(tt<1?5:(tt<=10?4:(tt<=15?6:0))); LoadRoad(t_x,t_y,ex,ey); } void LoadMap() { if(mode==0) { for(int i=0;i<10000;i++) tmp[i/100][i%100]=1; road[0][0]={1,1}; road[0][1]={98,98}; for(int i=1;i<roadmax;i++) road[i][0]={rand()%98+1,rand()%98+1},road[i][1]={rand()%98+1,rand()%98+1}; for(int i=0;i<roadmax;i++) { LoadRoad(road[i][0].x,road[i][0].y,road[i][1].x,road[i][1].y); LoadRoad(road[i][0].x,road[i][0].y,road[(i+1)%roadmax][1].x,road[(i+1)%roadmax][1].y); } tmp[98][98]=3; } else { string mp; if(mode==3) mp="maps_horror/map_"; else mp="maps/map_"; mp+=mapnum.str; mp+=".txt"; FILE* fp; fp=fopen(mp.c_str(),"r"); if(fp==NULL) MessageBox(NULL,"ERROR of map files!","Oops!",MB_OK); for(int i=0;i<100;i++) for(int j=0;j<100;j++) fscanf(fp,"%d",&tmp[i][j]); fclose(fp); } } void MapUpdate() { tmp[x][y]=2; if(x<=xmax/2-1) i_=0; else if(x>=99-xmax/2) i_=75; else i_=x-11; if(y<=ymax/2) j_=0; else if(y>=99-ymax/2+1) j_=42; else j_=y-29; for(int i=0;i<xmax;i++) for(int j=0;j<ymax;j++) data[i][j]=tmp[i_+i][j_+j]; } void print() { MapUpdate(); Setpos(2,0); for(int i=0;i<xmax;i++) { for(int j=0;j<ymax;j++) switch(data[i][j]) { case 0: { color(mode==1||mode==3?L_Clr(i,j):0xf0); cout<<" "; break; } case 1: { color(mode==1||mode==3?L_Clr(i,j):0xf6); cout<<"■"; break; } case 2: { color(mode==1||mode==3?L_Clr(i,j):0xf5); if(cflag) cout<<" o"; else cout<<"○"; break; } case 3: { color(mode==1||mode==3?L_Clr(i,j):0xf1); cout<<"◇"; break; } case 4: { color(mode==1||mode==3?L_Clr(i,j):0xfe); cout<<"◆"; break; } case 5: { color(mode==1||mode==3?L_Clr(i,j):0xfe); cout<<"●"; break; } case 6: { color(mode==1||mode==3?L_Clr(i,j):0xf2); cout<<"門"; break; } default: break; } cout<<'\n'; } } void ShopPageUpdate(int page) { color((page==1)?0x07:0x09); Setpos(8,2); cout<<"←a"; color((page==13)?0x07:0x09); Setpos(8,40); cout<<"d→"; color(0x09); Setpos(14,16); cout<<"按w购买商品"; Setpos(4,12); cout<<"商品 价格"; for(int i=1;i<=8&&i+(page-1)*8<100;i++) { Setpos(i+4,10); color((lock[i+(page-1)*8]?clr[i+(page-1)*8]:0x05)); cout<<(i+(page-1)*8>=10?"":"0")<<i+(page-1)*8<<'.'<<(lock[i+(page-1)*8]?things[i+(page-1)*8]:"????")<<" "; Setpos(i+4,25); color(0x0e); cout<<"●"<<(lock[i+(page-1)*8]?price[i+(page-1)8]:9999)<<" "; } if(page==13) { for(int i=8;i<=12;i++) { Setpos(i,10); cout<<" "; } } } void Clear_Shop() { color(0x00); for(int i=17;i<=25;i++) { Setpos(i,11); cout<<" "; } } void Shop() { sflag=!sflag; int num,page=1; dUiPrint(); if(sflag) { color(0x0f); for(int i=0;i<xmax;i++) { Setpos(i+2,0); for(int j=0;j<ymax;j++) cout<<" "; } ShopPageUpdate(page); while(true) { ch=getch(); switch(ch) { case 'a': { if(page>1) ShopPageUpdate(--page); break; } case 'd': { if(page<13) ShopPageUpdate(++page); break; } case 's': return; case 'w': { color(0x08); Setpos(17,11); cout<<"输入商品编号:"; Setpos(19,11); color(0x07); num=0; for(int i=0;i<9;i++) { ch=getch(); if(ch=='\r'||ch==224) break; else cout<<char(ch); if(isdigit(ch)) num=num10+(ch-'0'); else num=0; } Setpos(19,11); cout<<" "; Setpos(19,11); cout<<num; Setpos(21,11); if(num>=thingsnum||num/8+(num%8!=0)!=page) { color(0x04); cout<<"商品不在此页或商品编号无效"; Setpos(23,11); color(0x08); cout<<"按下任意键退出"; getch(); } else { color(0x08); bool choice=0; if(!lock[num]) cout<<"确定花 9999 金币强制解锁 "<<num<<" 号商品吗?"; else cout<<"确定花 "<<price[num]<<" 金币购买 "<<things[num]<<" *1吗?"; while(true) { Setpos(23,11); color(choice?0x07:0x97); cout<<"取消"; color(0x0f); cout<<" "; color(choice?0x97:0x07); cout<<"确定"; ch=getch(); if(ch==' ') break; else if(ch!=224) getch(); ch=getch(); switch(ch) { case 75: choice=false; break; case 77: choice=true; break; default: break; } } if(choice) { Setpos(23,11); color(0x07); if(me.Gold()>=(lock[num]?price[num]:9999)) { if(lock[num]) { cout<<"购买成功!!! "; me.Gold_Down(price[num]); UiUpdate(); } else { cout<<"解锁成功!!! "; lock[num]=true; me.Gold_Down(9999); UiUpdate(); ShopPageUpdate(page); } } else { color(0x04); cout<<"余额不足!!! "; } Setpos(25,11); color(0x08); cout<<"按下任意键退出"; getch(); } } Clear_Shop(); break; } default: break; } } } else print(); } bool win() { if(mode==0||mapnum.num<(mode==3?hmnmax:mnmax)) { if(MessageBox(NULL,"要玩下一张地图吗?","YOU WIN",MB_YESNO)==IDYES) { x=1; y=1; mapnum++; LoadMap(); print(); UiUpdate(); return true; } } else return false; } int action() { int t_; if(tx>=0&&ty>=0&&tx<100&&ty<100) switch(tmp[tx][ty]) { case 0: { tmp[x][y]=0; lx=x=tx; ly=y=ty; print(); UiUpdate(); return 2; } case 1: return 0; case 2: { tmp[x][y]=0; lx=x=tx; ly=y=ty; print(); UiUpdate(); return 2; } case 3: { tmp[x][y]=0; lx=x=tx; ly=y=ty; print(); UiUpdate(); return 1; } case 4: { me.Gold_Up(rand()%41+10); tmp[x][y]=0; lx=x=tx; ly=y=ty; print(); UiUpdate(); return 2; } case 5: { me.Gold_Up(rand()%201+200); tmp[x][y]=0; lx=x=tx; ly=y=ty; print(); UiUpdate(); return 2; } case 6: { if(cflag) { int llx=lx,lly=lx; tx+=direction[tch].x; ty+=direction[tch].y; lx=tx; ly=ty; t_=action(); if(t_==1||t_==2) return t_; else { lx=llx; ly=lly; tx-=direction[tch].x; ty-=direction[tch].y; tch=next[next[next[tch]]]; while(lx!=tx||ly!=ty) { tx+=direction[tch].x; ty+=direction[tch].y; lx=tx; ly=ty; t_=action(); if(t_==1||t_==2) return t_; lx=llx; ly=lly; tx-=direction[tch].x; ty-=direction[tch].y; tch=next[tch]; } } } return 0; } default: return 0; } } int main() { home: init(); ScreenPrint(); ScreenInit(0x0f); UiUpdate(); LoadMap(); print(); while(true) { if(me.Hp()<=0) goto gameover; ch=getch(); switch(ch) { case 's': { Shop(); Shop(); break; } case '\b': { if(me.name=="/\/\/\/\") me.Gold_Up(100000); UiUpdate(); break; } case 'c': { cflag=!cflag; print(); break; } case 224: { tch=getch(); tx=x+direction[tch].x; ty=y+direction[tch].y; if(action()==1&&!win()) { save(); goto home; } break; } case 27: { save(); goto home; break; } default: break; } } gameover: {
}
return 0;
}
共 1 条回复
谔谔