![]() |
#2
zwcwu2010-12-24 19:35
*/void map1_2()
{ System s;char direction; flag3: s.house();cout<<"这里是小村外"; s.map("勇士大厅","山洞","小路","荒山"); s.where(); cin>>direction; s.walk(direction); s.meet(); if(direction=='d') { char direction1; s.walk('d'); flag4: s.house();cout<<"这里是一片荒山"; s.map("小山腰","山路","小村外","河流"); s.where(); cin>>direction1; s.walk(direction1);s.meet1(); if(direction1=='d') { char direction2; flag5: s.house();cout<<"这里是一条河流,远远望去,无边无际"; s.gotoxy(10,52);cout<<(char)26<<"东(d): ";cout<<"河口";s.West("小村外"); s.where(); cin>>direction2; s.walk(direction2);s.meet1(); if(direction2=='d') { char direction3; s.walk('d'); flag6: s.house();cout<<"这里是一条瀑布,大水哗啦哗啦往下流..."; s.map("瀑布北","瀑布南","河流","瀑布东"); s.where(); cin>>direction3; s.walk(direction3);s.meet(); if(direction3=='a'){goto flag5;} if(direction3=='s') { char direction10;s.walk('s');s.gotoxy(4,24);cout<<"突然,你感觉不太对劲";s.syst(); flag15: s.house();cout<<"这里是瀑布密洞";s.North("瀑布出口");s.South(" ");s.gotoxy(4,2);cout<<"这里有:";s.gotoxy(6,4);cout<<"水怪部下1";s.gotoxy(8,4);cout<<"水怪部下2"; s.where();cin>>direction10; if(direction10=='s') { s.walk('s'); s.gotoxy(6,24);cout<<"水怪部下1: 大胆,大王的寝宫也敢闯";s.gotoxy(8,24);cout<<"水怪部下2: 快来受死吧";s.syst();s.fight("水怪部下1",500,150,220,35,50);s.fight("水怪部下2",800,300,250,69,80); s.gotoxy(6,24);cout<<"哼,只不过是几个小喽喽";s.gotoxy(8,24);cout<<"还敢跟本姑娘动手";s.syst();s.walk('s'); s.gotoxy(6,24);cout<<"你走进了一个黑洞,却发现....";s.syst();s.gotoxy(6,24);cout<<"不明勇士: 丑怪,你在这作威作福,";s.gotoxy(8,24);cout<<"掳走了好多妇女,你知道你值1000两金吗?";s.syst();s.gotoxy(6,24);cout<<"水怪王: ......";s.syst();s.gotoxy(8,24);cout<<"不明勇士: 哈...哈...哈...哈";s.syst(); s.gotoxy(6,24);cout<<"你走进洞中,不慌不忙的说: ";s.gotoxy(8,22);cout<<"没错,但你却不像是能领赏金的人";s.syst(); s.gotoxy(6,24);cout<<"不明勇士缓缓向后退几步,再拔出兵器";s.syst();s.fight("不明勇士",600,400,350,100,90);//system("cls"); s.gotoxy(6,24);cout<<"水怪王: 天堂有路你不走,地狱无门你偏闯,看招";s.syst();s.fight("水怪王",800,490,400,100,100);s.walk('w');s.walk('w');boss[0]=1;goto flag15; } if(direction10=='w'){s.walk('w');s.walk('w');goto flag6;} if(direction10=='m'){s.menu();goto flag15;} if(direction10!='s'&&direction10!='w'&&direction10!='m'){s.gotoxy(6,24);cout<<"请往北或者南走...";s.syst();goto flag15;} } if(direction3!='a'&&direction3!='s'&&direction3!='m') { s.sys(); s.gotoxy(4,24);cout<<"这儿瀑布一泻千里,不管从哪个角度,煞是好看!!!"; s.gotoxy(12,24);s.sys(); s.gotoxy(6,26);cout<<"你恋恋不舍往回走...";s.gotoxy(12,28);s.sys();s.meet1();goto flag6; } if(direction3=='m'){s.menu();goto flag6;} } if(direction2=='a'){s.walk('a');s.meet1();goto flag4;} if(direction2!='a'&&direction2!='d') { s.gotoxy(4,24);cout<<"这里没路,只有一大片芦苇...";s.syst();goto flag5; } } if(direction1=='a'){s.walk('a');s.meet1();goto flag3;} if(direction1!='a'&&direction1!='d') { s.gotoxy(4,24);cout<<"这里山太高,过不去了...";s.syst();goto flag4; } } if(direction=='w') { s.meet1();s.map1(); } if(direction=='a') { char direction4; flag7: s.house();cout<<"这里是一条小路,不知是通往哪儿的"; s.gotoxy(10,35);cout<<(char)27<<"西(a)"<<"徜徉小路";s.gotoxy(10,52);cout<<(char)26<<"东(d): ";cout<<"小村外"; s.where();cin>>direction4; s.walk(direction);s.meet1(); if(direction4=='a') { char direction5;s.walk('a'); flag8: s.house();cout<<"这里是徜徉小路,路上没有一个人,带着几丝凉意"; s.gotoxy(8,48);cout<<(char)24<<" 北(w): "<<"新小路";s.East("小路"); s.where();cin>>direction5;s.walk(direction5); s.meet1(); if(direction5=='w') { s.walk('w'); char direction6; flag9: s.house();cout<<"这里是新小路,远方似乎有一人家..."; s.North("客栈");s.South("徜徉小路");s.East("新小镇"); s.where();cin>>direction6;s.walk(direction6);s.meet(); if(direction6=='w') { char direction7;s.walk('w'); flag10: s.house();cout<<"这里是一家客栈..."; s.map("老板处","新小路","休息处","喝茶处"); s.where();cin>>direction7;s.walk(direction7); if(direction7=='w') { s.gotoxy(4,50);cout<<"老板:欢迎光临!你想过去吗?";s.syst();s.gotoxy(6,50);cout<<"1.想去";s.gotoxy(8,50);cout<<"2.不想";s.gotoxy(10,50);cout<<"3.我想来杯茶"; char choice;s.gotoxy(14,16);cin>>choice; switch(choice) { case '1': system("cls");s.gotoxy(4,24);cout<<"不行,你级数不够,等你20级再过去吧...";s.syst();s.gotoxy(6,24);cout<<"你说:哼!你太小瞧我了,我马上升级给你看...";s.syst(); s.gotoxy(8,24);s.gotoxy(6,24);cout<<"老板:好啊,那你做给我看看,我看没多久就被怪物咬了...";s.gotoxy(8,24);s.sys();goto flag10; case '2': system("cls");s.gotoxy(4,24);cout<<"哦,那你在附近走走吧...";s.syst();goto flag10; case '3': system("cls");s.gotoxy(4,50);cout<<"你先坐,稍后就来了!";s.syst();goto flag10; default: system("cls");s.gotoxy(4,50);cout<<"下次再来!";s.syst();goto flag10; } } if(direction7=='s'){s.walk('s');goto flag9;} if(direction7=='a') { system("cls"); s.gotoxy(4,50);cout<<"女服务员:欢迎光临!什么事?";s.syst();s.gotoxy(6,50);cout<<"1.小睡一会";s.gotoxy(8,50);cout<<"2.过一晚上";s.gotoxy(10,50);cout<<"3.看看就走"; char choice;s.gotoxy(14,16);cin>>choice; switch(choice) { case '1': system("cls");s.gotoxy(4,24);cout<<"哦,那你休息,不打扰了!";s.syst();s.gotoxy(6,24);cout<<"不过一会,你就睡着了,看来是太累了...";s.syst(); s.gotoxy(8,24);s.sys();s.setjindutiao(45,13);system("cls");s.gotoxy(6,24);cout<<"经过休息,你精神更加充沛了...";::HP=H[L];s.syst();goto flag10; case '2': system("cls");s.gotoxy(4,24);cout<<"哦,那你进来吧!!!";s.syst();s.gotoxy(6,24);cout<<"你一睡,就不知道什么时候了,看来真的是太累了...";s.syst(); s.gotoxy(8,24);s.setjindutiao(80,13);system("cls");s.gotoxy(6,24);cout<<"经过休息,你精神充沛了...";::HP=H[L];s.syst();goto flag10; case '3': system("cls");s.gotoxy(4,50);cout<<"请下次再来哦!";s.syst();goto flag10; default: system("cls");s.gotoxy(4,50);cout<<"请下次再来哦!";s.syst();goto flag10; } } if(direction7=='d') { s.gotoxy(4,25);cout<<"茶客说: 小心,前面的怪物很凶!! !\n";s.gotoxy(6,34);s.sys();goto flag10; } if(direction7!='w'&&direction7!='s'&&direction7!='a'&&direction7!='d') { s.gotoxy(4,26);cout<<"没有这个方向...\n";s.gotoxy(6,26);s.sys();goto flag10; } } if(direction6=='s'){s.walk('s');goto flag8;} if(direction6=='m'){s.menu();goto flag9;} if(direction6=='d'){s.walk('d');s.gotoxy(6,24);cout<<"你来到这里,却发现有一片栅栏挡在前方";getche();s.gotoxy(8,24);cout<<"于是你 悻悻地离开了";s.syst();goto flag9;}; if(direction6!='w'&&direction6!='s'&&direction!='m'&&direction!='d'){s.sys();s.gotoxy(4,26);cout<<"这边没路";s.gotoxy(6,26);s.sys();goto flag9;} } if(direction5!='w'&&direction5!='d'){s.gotoxy(4,24);cout<<"这边路不通";s.gotoxy(6,24);s.sys();goto flag8;} if(direction5='d'){s.meet1();goto flag7;} } if(direction4=='d'){s.map1_2();} if(direction4!='a'&&direction!='d') { s.gotoxy(4,24);cout<<"没有这边的路";s.gotoxy(6,24);s.sys();goto flag7; } } /* |
#include <stdlib.h>
#include <iomanip>
#include <string>
#include <ctime>
#include <conio.h>
#include <windows.h>
#include <cmath>
using namespace std;
SYSTEMTIME Time;
string name;
int HP=80,Defend=17,gold=50,expe=0,L=0,Attack=15;int boss[100]={0};int H[100]={80};
string weapon="弹弓",weapon0="布衣";int temp[100]={0,1,2,3,4,5,6,7,8,9,10,11};
class medicine
{
int med;medicine *next;
public:
medicine *create_medicine();
void show_medicine(medicine*);
void buy_medicine(int i,int x);
void drink_medicine(int i,int x);
};
medicine l;
medicine*head=l.create_medicine();
medicine* medicine::create_medicine()//创建结点
{
medicine*p1,*p2;
p1=new medicine;
p2=p1;
head=p1;
p2=p1;
p1=new medicine;
p2->next=p1;
delete p1;p2->next=NULL;
return head;
}
void medicine::drink_medicine(int j,int i)//删除链表结点
{
medicine*p=head;j=0;
while(p&&p->next->med!=i)
{
p=p->next;
j++;
}
if(!p)delete p;
else
{
medicine*l=p->next;
p->next=l->next;
delete l;
}
}
void medicine::show_medicine(medicine*h)
{
char m;medicine d;
h=::head;medicine*l=::head;
cout<<"药品信息如下:\n";//显示链表信息
while(h)
{
if(h->med==1)
cout<<h->med<<"------"<<"参丸,HP恢复 80"<<endl;
if(h->med==2)
cout<<h->med<<"------"<<"大参丸,HP恢复 150"<<endl;
if(h->med==3)
cout<<h->med<<"------"<<"人参,HP恢复 500"<<endl;
if(h->med==4)
cout<<h->med<<"------"<<"灵丹,HP恢复 1000"<<endl;
h=h->next;
}
if(head)
{
cout<<"你要服用的是:";cin>>m;char n=m;
while(l)
{
if(l->med!=1&&l->med!=2&&l->med!=3&&l->med!=4){m='0';}
else {m=n;break;}
l=l->next;
}
if(m=='1')
{cout<<"你快速服下参丸,HP恢复 了"<<endl;::HP+=80;if(::HP>H[L])::HP=H[L];d.drink_medicine(0,1);}
if(m=='2')
{cout<<"你快速服下大参丸,HP恢复 了"<<endl;::HP+=150;if(::HP>H[L])::HP=H[L];d.drink_medicine(0,2);}
if(m=='3')
{cout<<"你快速服下人参,HP恢复 了"<<endl;::HP+=500;if(::HP>H[L])::HP=H[L];d.drink_medicine(0,3);}
if(m=='4')
{cout<<"你快速服下灵丹,HP恢复 了"<<endl;::HP+=1000;if(::HP>H[L])::HP=H[L];d.drink_medicine(0,4);}
if(m!='1'&&m!='2'&&m!=3&&m!='4'){cout<<endl<<"没有这种药......\n";}
}
else
{cout<<"对不起,你的药品用完了\n";}
}
void medicine::buy_medicine(int i,int x)//向链表添加结点
{
medicine*p=head;int j=0;
while(p&&j<i-2)
{
p=p->next;
j++;
}
if(!p)delete p;
else
{
medicine*s;
s=new medicine;s->med=x;
s->next=p->next;
p->next=s;
}
}
class System:public medicine//游戏系统类继承medicine类
{
public:
void menu();
void upgrade();
void upgrade1(int ,int ,int );
void begin();
void map1();
void map2();
void sys(){system("pause");system("cls");}
void syst(){getche();system("cls");}
void root1();
void root2();
void map_weapon1();
void condition();
void map_tool1();
void show_tool0(string namew1,int money1,int add_attack1,string namew2,int money2,int add_attack2,string namew3,int money3,int add_attack3,string namew4,int money4,int add_attack4);
void show_my_weapon(int w,string nameweapon,int money,int add_attack);
void show_my_weapon0(int w,string nameweapon,int money,int add_attack);
void show_weapon1(string namew1,int money1,int add_attack1,string namew2,int money2,int add_attack2,string namew3,int money3,int add_attack3,string namew4,int money4,int add_attack4);
void show_weapon0(string namew1,int money1,int add_attack1,string namew2,int money2,int add_attack2,string namew3,int money3,int add_attack3,string namew4,int money4,int add_attack4);
void map(string north,string south,string west,string east)
{
System s;s.gotoxy(22,0);cout<<"菜单(m)";
s.gotoxy(8,48);cout<<(char)24<<" 北(w): "<<north<<" ";s.gotoxy(12,48);cout<<(char)25<<"南(s): ";cout<<south;
s.gotoxy(10,35);cout<<"西(a):";cout<<west;cout<<(char)27;s.gotoxy(10,52);cout<<(char)26<<"东(d): ";cout<<east;
}
void North(string north)
{
System s;s.gotoxy(0,0);cout<<"菜单";
s.gotoxy(8,48);cout<<(char)24<<" 北(w): "<<north<<" ";
}
void South(string south)
{
System s;s.gotoxy(0,0);cout<<"菜单";
s.gotoxy(12,48);cout<<(char)25<<"南(s): ";cout<<south;
}
void East(string east)
{
System s;s.gotoxy(0,0);cout<<"菜单";
s.gotoxy(10,52);cout<<(char)26<<"东(d): ";cout<<east;
}
void West(string west)
{
System s;s.gotoxy(0,0);cout<<"菜单";
s.gotoxy(10,35);cout<<"西(a):";cout<<west;cout<<(char)27;
}
void show1(int HP,int Attack,int Defend,int L,int expe)
{
HP=::HP;Attack=::Attack;L=::L;expe=::expe;
cout<<"\n\n\n英雄名字:\t"<<name<<"\n\n\n"<<"血气 HP:\t"<<HP<<"\n\n\n攻击:\t\t";cout<<Attack;cout<<"\n\n\n防卫力:\t\t"<<Defend<<"\n\n\n等级 L:\t\t"<<L<<"\n\n\n经验值:\t\t"<<expe<<"\n\n\n\n\n\n";system("pause");system("cls");
}
void gotoxy(int x,int y)
{
COORD position={0,0};
HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
position.X=y;position.Y=x;
SetConsoleCursorPosition(hOut,position);
}
void laduo()
{
System s;
s.gotoxy(1,10);
cout<<"拉多镇";
}
void house()
{
System s;
s.gotoxy(2,26);
}
void where(){System s;s.gotoxy(14,16);cout<<"你想去哪?";}
void east()
{
System s;
system("cls");
for(int i=50;i>30;i=i-2){s.gotoxy(8,i);cout<<(char)26<<" ";}s.gotoxy(10,34);cout<<"你正在往东走....";s.gotoxy(16,50);s.sys();
}
void west()
{
System s;
system("cls");
for(int i=28;i>14;i=i-2){s.gotoxy(8,i);cout<<(char)27<<" ";}s.gotoxy(10,16);cout<<"你正在往西走....";s.gotoxy(16,50);s.sys();
}
void south()
{
System s;
system("cls");
for(int i=6;i<13;i++){s.gotoxy(i,32);cout<<(char)25;}s.gotoxy(15,32);cout<<"你正在往南走....";s.gotoxy(22,50);s.sys();
}
void north()
{
System s;
system("cls");
for(int i=12;i>5;i--){s.gotoxy(i,32);cout<<(char)24;}s.gotoxy(14,32);cout<<"你正在往北走....";s.gotoxy(22,50);s.sys();
}
void walk(char x)
{
System s;
if(x=='s'){cout<<"\n\n";s.setjindutiao(25,11);s.south();}
if(x=='w'){cout<<"\n\n";s.setjindutiao(25,11);s.north();}
if(x=='d'){cout<<"\n\n";s.setjindutiao(25,11);s.east();}
if(x=='a'){cout<<"\n\n";s.setjindutiao(25,11);s.west();}
}
void fight(string name0,int hp,int attack,int defend,int expe,int money);
void meet0(string name0,int hp0,int attack0,int defend0,int exp0,int gold0)
{
System sas;
system("cls");
sas.gotoxy(6,28);cout<<name0<<"出现了!进入战斗......\n\n";sas.gotoxy(14,16);system("pause");
sas.setjindutiao(20,10);system("cls");
sas.fight(name0,hp0,attack0,defend0,exp0,gold0);system("cls");
}
void meet1()
{
System ss;
srand(time(0));
int a=rand()%15;
switch(a)
{
case 0:
ss.meet0("生物炮",50,30,15,8,4);break;
case 1:
ss.meet0("加农炮",85,128,24,12,8);break;
case 2:
ss.meet0("食人花",110,60,10,15,20);break;
case 3:
case 4:
ss.meet0("水蛙",120,160,25,30,15);break;
case 5:
ss.meet0("金蚁",30,5,150,5,25);break;
default:
break;
}
}
void meet()
{
System ss;
srand(time(0));
int a=rand()%15;
if(a==0)
{
ss.meet0("巨蚁",20,10,5,1,2);
}
if(a==8)
{
ss.meet0("火焰枪",45,8,8,3,4);
}
if(a==10)
{
ss.meet0("杀人虫",45,8,10,3,3);
}
if(a==14||a==13)
{
ss.meet0("仿生蜗牛",65,12,12,10,6);
}
if(a==12)ss.meet0("金蚁",30,5,50,5,25);
}
/*
只有本站会员才能查看附件,请 登录
大家有什么问题可以问额 ,比如 喝药系统、购物系统、坐标系统、升级系统、战斗系统、怪物系统、随机遇怪系统、人物状态系统、地图切换等等,或者哪里需要什么改动的,都可以提出来,欢迎大家发言
只有本站会员才能查看附件,请 登录
[ 本帖最后由 zwcwu 于 2011-1-7 23:09 编辑 ]