Anda di halaman 1dari 3

// Adventure Island.

CPP
#include <iostream>
#include <conio.h>
#include <process.h>
using namespace std;
int main()
{
char dr='a';
int x=10,y=10,h=100;
int drag_hp=50;
int cmnd;
int wpn;
cout<<"**********-----ISLAND ADVENTURE----**********"<<endl;
do
{
cout<<"Your Location Is: "<<x<<", "<<y;
cout<<"\nYour Health is: "<<h;
cout<<"\nEnter Direction: (n,s,e,w)";
cin>>dr;
switch(dr)
{
case 'n':
y++;
break;
case 's':
y--;
break;
case 'e':
x++;
break;
case 'w':
x--;
break;
}
if(x==7 && y==11)
{cout<<"Treasure. Health+10"<<endl;
h=h+10;
}
if(x%3==0 && y%3==0)
{cout<<"Mushroom. Health +30"<<endl;
h=h+30;
}
if(y<=2 || y>=20)
{cout<<"Out of Boundries. 0 Helth Remaining!"<<endl;
h=h-h;
}
if(x%2==1 && y%3==1)
{
cout<<"\nPitfall Trap. Health - 15"<<endl;
h=h-15;
}
if(h>150)
{cout<<"\nMax Health is 150"<<endl;
h=150;
}
if(x<=5 || x>=15)


{
cout<<"\nDragons Appear"<<endl;
cout<<"\nPress 1 to fight and 2 to run away'"<<endl;
cin>>cmnd;
switch(cmnd)
{
case 1:
cout<<"\nYou choose to fight"<<endl;
do
{
cout<<"\nYour Health: "<<h;
cout<<"\nDragon Health: "<<drag_hp;
cout<<"\nChoose Weapon."<<endl;
cout<<"\nSword=1, Axe=2, Spear=3."<<endl;
do
{
cin>>wpn;
switch(wpn)
{
case 1:
cout<<"\nYou Attack Dragon with sword. And do 20 damage"<<endl;
cout<<"\nDragon does 5 damage to you."<<endl;
drag_hp=drag_hp-20;
h=h-5;
cout<<"\nYour Health: "<<h;
cout<<"\nDragon Health: "<<drag_hp;
cout<<"\nChoose Weapon."<<endl;
cout<<"\nSword=1, Axe=2, Spear=3."<<endl;
break;
case 2:
cout<<"\nYou Attack Dragon with axe. And do 10 damage"<<endl;
cout<<"\nDragon does 10 damage to you."<<endl;
drag_hp=drag_hp-10;
h=h-10;
cout<<"\nYour Health: "<<h;
cout<<"\nDragon Health: "<<drag_hp;
cout<<"\nChoose Weapon."<<endl;
cout<<"\nSword=1, Axe=2, Spear=3."<<endl;
break;
case 3:
cout<<"\nYou Attack Dragon with spear. And do 15 damage"<<endl;
cout<<"\nDragon does 5 damage to you."<<endl;
drag_hp=drag_hp-15;
h=h-5;
cout<<"\nYour Health: "<<h;
cout<<"\nDragon Health: "<<drag_hp;
cout<<"\nChoose Weapon."<<endl;
cout<<"\nSword=1, Axe=2, Spear=3."<<endl;
break;
}
}
while(drag_hp>0 && h>0);
}
while(drag_hp>0 && h>0);
break;

case 2:
cout<<"\nYou run away. Dragon does 10 damage to you"<<endl;
h=h-10;
break;
}
}
}
while(h!=0);
system("pause");
return 0;
}

Anda mungkin juga menyukai