Tuesday 7 July 2015

Hanging Garden Game C++ Code


#include <iostream.h>
#include<conio.h>

char s1[]={' '};
int i;
void input();
void main()

{
int status=0;
char a[]={'a','p','p','l','e'};
char b[]={'w','o','r','l','d'};
char c[]={'s','e','r','v','e'};
char t[]={'c','l','o','c','k'};
char r[]={'f','e','i','l','d'};
int d;
char choice=' ';
 cout <<"\t      Text Puzzle!    \n";
 cout<<"\n\n\t\t* UsAmA ImTiaZ"<<endl;
 cout<<endl;
 cout<<"Presented to:      Sir. Nadeem"<<endl;
 cout<<endl;
 getch();
 clrscr();
 char userName[100];
cout<<"\t        Text Puzzle!    \n"<<endl;
 cout <<"\nPlease enter your username: ";

 cin >>userName;

 cout <<"Hello, "<<userName<<"!\n\n";



 cout <<"Please pick your race: \n";

 cout <<"1 - Human\n";

 cout <<"2 - Comp\n";

 int pickRace;

 cout <<"Pick your race: ";

 cin >>pickRace;



 switch (pickRace)

 {

  case 1:

 cout <<"You picked the Human race.\n";

 break;

  case 2:

 cout <<"You picked the Comp race.\n";

 break;



 }




 int difficulty;

 cout <<"\nPick your level difficulty: \n";

 cout <<"1 - Easy\n";

 cout <<"2 - Medium\n";

 cout <<"3 - Hard\n";


 cout <<"Pick your level difficulty: ";

 cin >>difficulty;



 switch (difficulty)

 {

  case 1:

 cout <<"You picked Easy.\n\n";
break;


  case 2:

 cout <<"You picked Medium.\n\n";

break;

  case 3:

 cout <<"You picked Hard.\n\n";

 break;

  }
  getch();
        clrscr();
do
{
cout<<"\t    YOU HAVE ENTERED IN HANGING GARDEN"<<endl<<endl;
cout<<"\t    Beaware! it is Fetal to Play"<<endl<<endl;
cout<<"\t           Lets Start"<<endl<<endl;

cout<<"Press any key(1-5): ";
cin>>d;
cout<<endl<<endl;
if(d==1)
{
cout<<"ap-le"<<endl<<endl;
input();
if(s1[2]==a[2])
{
status=1;
}
else
{
status=0;
}
}
else if(d==2)
{
cout<<"wor-d"<<endl<<endl;;
input();
if(s1[3]==b[3])
{
status=1;
}
else
{
status=0;
}
}
else if(d==3)
{
cout<<"fei-d"<<endl<<endl;;
input();
if(s1[3]==r[3])
{
status=1;
}
else
{
status=0;
}
}
else if (d==4)
{
cout<<"clo-k"<<endl<<endl;;
input();
if(s1[3]==t[3])
{
status=1;
}
else
{
status=0;
}
}
else if(d==5)
{
cout<<"ser-e"<<endl<<endl;;
input();
if(s1[3]==c[3])
{
status=1;
}
else
{
status=0;
}
}
else
{
cout<<"you Entered invaid key"<<endl<<endl;
}
if(status==1)
{
cout<<"Congragulations! You Survive"<<endl<<endl;
}
else
{
cout<<"Opps! You are Hanged"<<endl<<endl;
cout<<"\t (' ')"<<endl;
cout<<"\t <| |>"<<endl;
cout<<"\t  / |"<<endl;
cout<<endl;
}

  cout<<"Do you want to continee...? (y/n)"<<endl;
  cin>>choice;
  choice=getche();
  clrscr();
  continue;
}while(choice=='y');
getch();
}

void input()
{
cout<<"Complete the Word"<<endl;
for(i=0;i<4;i++)
{
cin>>s1[i];
}
}

No comments:

Post a Comment