Hello im back again and my code still wont work!

Thanks for the help i got it to work not sure what i did but it works so well here it is
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
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int audrey=0;
    int cupboard=0;
	cout << "everything is so dark....." << endl;
	cin.get();
	cout << "\"HEY WAKE UP\"" << endl;
	cin.get();
    cout << "You open your eyes" << endl;
    cin.get();
	cout << "You find youself in a dark room" << endl;
    cin.get();
    cout << "You try to locate the voice but cant seem to find it.....";
    cin.get();
    cout << "\"ON THE CUPBOARD\"";
    cin.get();
    cout << "upon a quick look you realize that the voice is coming from a walkie talkie on" << endl << "the cupboard";
    cin.get();
    cout << "You pick up the walkie talkie" << endl;
    cin.get();
    cout << "smashing now what your name?";
    cout << "(press enter and Choose name)";
    cin.get();
    string Charname;
    cin >> Charname;
    cout << "well splendid " << Charname<< " " << endl;
    cin.get();
    cout << "ok now here's the deal" << endl;
    cin.get();
    cout << "well you see " << Charname << " this room is your prison" << endl;
    cin.get();
    cout << "and no there will be no food" << endl;
    cin.get();
    cout << "You can however escape from here" << endl;
    cin.get();
    cout << "find the key, get out good luck";
    cin.get();
    cout << "You start looking around the room,and see 3 places worth" << endl << "searching" << endl;
    cout << "there is" << endl;
    int Pindus;
    teleport:
    cout << "1 - a bed" << endl;
    cout << "2 - a closet" << endl;
    cout << "3 - a cupboard" << endl;
    cin >> Pindus;
    
    switch (Pindus)
    {
    case 1:
    cout << "the bed look kinda comfy but really dusty" << endl << endl << endl;
    goto teleport;
    
    
    
    case 2:
    cout << "you open the closet and find a cute little plant" << endl;
    cin.get();
    cout << "you examine the plant when it suddenly starts to talk!"<< endl;
    cin.get();
    cout << "Feed me " << Charname << " and i'll give you whatever you whant";
    cin.get();
    cout << "you toss a bucket of fish you had in your backpocket"<<endl << "the plant spat it out furiously knocking you over and closing the door" << endl;
    cin.get();
    cout << "you landed on top of the rug and felt something hard under the rug!";
    cin.get();
    cout << "with a sigh of relief you find the key under the rug and put it in" << endl << "your pocket" << endl;
    cin.get();
    audrey=1;
    cout << endl << endl << endl;
    break;
    
    case 3:
    cout << "This was a nice cupboard you might take it if you get out of here" << endl;
    cin.get();
    if (audrey==0)
    {
    cupboard=1;	
    }
    goto teleport;
    cout << endl << endl << endl;
    break;
    }
    if (audrey==1 && cupboard==1)
    {
    	cout << "you take the cupboard and shove it in your backpocket" << endl;
    	cin.get();
    	cout << "you run for the door filled with joy!" << endl;
    	cin.get();
    	cout << "you turn the key in the lock and feel how the door slowly opens" << endl;
    	cin.get();
    	cout << "you've escaped congratulations!";
    	cin.get();
    	return 0;
    }
    if(audrey ==1 && cupboard==0)
    {
    cout << "You run for the door filled with joy!" << endl;
    cout << "You turn the key in the lock and feel how the door slowly opens" << endl;
    cout << "but suddenly the door slams shut and you hear a voice from the closet" << endl << "\"\"" << Charname << "\"\"" << endl;
    cout << "You did not escape..........";
    cout << "Game over";
    return 0;
    }
}
Last edited on
audrey and cupboard are ints. Use if (audrey==1 && cupboard== 1) and if (audrey==1 && cupboard==0) instead for checking. Also, remove the terminating semi-colons you have at the end of the if(aud...) lines.
On lines 87 and lines 99 you have:
if (condition);

This is a blank statement. That means, if the condition is true, excecute the statement before the semi-colon. But there's nothing there so nothing will be excecuted.

Then the code in the {...} will be executed regardless of the condition in the if statement as it is unrelated.

As for your issue with selecting 1 or 2, I see some gotos in there. I'm not going to get involved in anything like that. I suggest replacing that stuff with some structured programming using loops.

Also, I think lines 84 and 85 are unreachable.
Last edited on
Topic archived. No new replies allowed.