Text Adventure Game

Hello. Recently we started studying programming at school, so I am a total noob, i have tried making a text adventure game with what we were taught so far, but it doesnt seem to work.It's probably very messy, sorry xD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include<iostream>
#include<string>
using namespace std;

int main()
{
 int n,ok,i,health=10,bucket=0,inventory=5,location=0,bckt=1,key=0,strenght=11,e=0;//0-sign 1-north 2-south 3-west 4-east
 //i declared all the strings here
<<endl;
 while(health!=0)
 {getline(cin,input);
  if(input==look&&location==0) {cout<<"You're surrounded by tall pine trees. In front of you there's a sign covered in blood: \"The beast heads north\""<<endl<<"What do you do?"<<endl;
                                      getline(cin,input);
                               }


   else if(input==north&&location==0)
    { cout<<"You see a 10 foot giant walking in front of you"<<endl<<"What do you do"<<endl;
      i=0;
      while(i==0)
       {location=1;
        getline(cin,input);
        if(input==south||input==back){cout<<"You've escaped the giant, you're back at the sign"<<endl<<"What do you do?"<<endl; location=0;i=1;}
          else if(input==attack||input==north&&strenght<10) {cout<<"Before you can get close to the giant it pulls out a huge bat and smashes your head in. You're dead...";
                                                            return 0;
                                                           }
           else if(input==attack||input==north&&strenght>=10) {cout<<"stuff"; 
                                                              health=health=4;
                                                              i++;
                                                             }
            else {cout<<"Not possible"<<endl; i=0;}

       }
       getline(cin, input);
    }

    else if(input==south&&location==0){location=2;
                                      if (bckt==1)
                                       {cout<<"You see a well. Do you look down it?(y/n)"<<endl;
                                        getline(cin,input);
                                        if(input==yes) {cout<<"As you lean forward, the bucket retracts at a magnificent speed and smashes you in the face. You are now injured"<<endl;
                                                        health--;
                                                       }
                                        cout<<"The bucket is still intact, do you pick it up?(y/n)"<<endl;
                                        getline(cin,input);
                                        if(input==yes) {cout<<"You are now carrying a bucket.There is nothing more to do here, you return to the sign"<<endl<<"What do you do?"<<endl;
                                                        bucket=1;
                                                        inventory--;
                                                        bckt=2;
                                                        location=0;
                                                       }
                                             else if(input==no) {location=0;
                                                                 cout<<"The well is the only interesting object here, there are no other paths, you return to the sign"<<endl<<"What do you do?";
                                                                }
                                               else {cout<<"The well is the only interesting object here, there are no other paths, you return to the sign"<<endl<<"What do you do?"<<endl;
                                                     getline(cin,input);
                                                     location=0;
                                                    }

                                        }
                                       else if(bckt=2)
                                        {cout<<"There is a bucket on the ground, do you pick it up?(y/n)"<<endl;
                                         getline(cin,input);
                                         if(input==yes) {cout<<"You are now carrying a bucket. What do you do?"<<endl;
                                                         bucket=1;
                                                         inventory--;

                                                        }
                                                 else if(input==no) {location=0;
                                                                     cout<<"The bucket is the only interesting object here, there are no other paths, you return to the sign"<<endl<<"What do you do?";
                                                                    }
                                       }
                                    }

     else if(input==east&&location==0)  {location=4;
                                        cout<<"You see a lake."<<endl<<"What do you do?"<<endl;
                                        getline(cin,input);
                                        if(input==west&&location==4) {cout<<"You are back at the sign. What do you do?"<<endl; location=0;}
                                         else if(input==fill&&bucket==1){cout<<"You now have a bucket of water, but it's pretty heavy"<<endl;
                                                                        inventory--;
                                                                        bucket=2;
                                                                        }
                                          else if(input==fill&&bucket==0) cout<<"You have nothing to fill"<<endl;
                                             else if(input==swim) cout<<"As you submerge into the water, you see a shimmer towards the bottom of the lake, it seems to be a chest."<<endl<<"Do you try and open it?(y/n)";
                                               getline(cin,input);
                                                if(input==yes) {cout<<"Inside the chest you find a key, but you are out of oxygen, you return to the surface"<<endl;
                                                                key=1;
                                                                inventory--;
                                                               }
                                                  else cout<<"You are back at the surface"<<endl;
                                        }
          else if(input==east&&location==3){location=0;
                                            cout<<"You are back at the sign. What do you do?"<<endl;
                                           }

  else if(input==west&&location==0)while(e==0)
                                    {location=3;
                                    cout<<"You see a house. In front of the house is a small tube. What do you do?"<<endl;
                                    getline(cin,input);
                                    if(input==open) cout<<"The door is locked"<<endl;
                                    if(input==pour&&bucket==2) cout<<"You pour the water down the pipe, and seconds later the door opens. What do you do?"<<endl;;
                                    getline(cin,input);
                                    if(input==in) cout<<"The house is mostly empty. The only living thing you'd ever find in here a spiders and rats, and the smell is horrendous"<<endl<<"There's a glass case on the wall next to the staircase. Inside of it you see a glorious sword, decorated with ruby and emeralds. What do you do?"<<endl;
                                    getline(cin, input);
                                    if(input==open) cout<<"It's locked"<<endl;
                                    cin >>input;
                                    if(input==unlock&&key==1) {cout<<"Case unlocked, you are now wielding a sword"<<endl;
                                                               strenght=10;
                                                               inventory--;
                                                              }
                                    else if(input==unlock&&key==0) cout<<"You don't have a key"<<endl;
                                     else cout<<"Not possible"<<endl;
                                   }
        else if(input==west&&location==4){location=0;
                                          cout<<"You're back at the sign. What do you do?"<<endl;
                                         }

getline(cin,input);
    }

if(health==0) cout<<"You are dead"<<endl;
}


   
Topic archived. No new replies allowed.