Maze game

closed account (iNU7ko23)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include <iostream>
#include <ctime>
using namespace std;




int linput;
int see( int path2);
int moi();


int main()
{
srand ( time(NULL) );

int life = 30;
int linput;
int dog = 5;
int progress = 0;
int path;
int trolllevel;

	cout << "You are venturing out on a journey to save the princess.\n";
	cout << "You come across a huge maze of doom!\n";
	cout << "Inside the maze are deadly trolls in ten levels.\n";
	cout << "Rumours of the directions are engraved on the wall.\n";
	cout << "Luckly left is a gamblers game. You could get by easily or bump into a level 10 troll.\n";
	cout << "Whether ravaged right is generally a safe bet. You will find medium trolls here but rarely have luck.\n";
	cout << "You have 30 life points.\n";
	cout << "In combat with trolls you can either run away(losing random life) or...\n";
	cout << "you can kill the troll and take the damage of the troll's level\n";
	
	
	
	for(progress = 0; progress <= 10; progress++)
	{
int bin;
if(life <= 0)
{
goto end;
}

 path = 0;

	cout << "You can turn left or right. What do you choose? 1) left 2) right.\n";
	

cin >> path;
	
	
trolllevel = see(path);

	if(path == 1)
	{

if(trolllevel > 10)
{
cout << "Looks like you didn't bump into a troll luckily!\n";

continue;
}

cout << "There is a level " << trolllevel << " troll.\n";

cout << "Do you want to 1) sprint away or 2) kill the Troll?\n";
cin >> linput;
switch(linput)
{
case 1:
	
bin = moi()	;
	cout << " You get away with " << bin << " damage.\n";
	life = life - bin;
	
cout << "\nYour life is now..." << life << "\n";
break;
case 2:
	cout << " You get away with " << trolllevel << " damage.\n";
life = life - trolllevel;

cout << "\nYour life is now..." << life << "\n";
	
	
	}
	}
	 if(path == 2)
	{

if(trolllevel > 8)
{
cout << "Looks like you didn't bump into a troll luckily!\n";

continue;
}
cout << "There is a level " << trolllevel << " troll.\n";
int linput;

cout << "Do you want to 1) sprint away or 2) kill the Troll?\n";

cin >> linput;
switch(linput)
{
case 1:
	bin = moi();
	
	cout << " You get away with " << bin << " damage.\n";
	life = life - moi();
	
cout << "\nYour life is now..." << life << "\n";
break;
case 2:
	cout << " You get away with " << trolllevel << " damage.\n";
life = life - trolllevel;
cout << "\nYour life is now..." << life << "\n";
};






		
}


	
}

end:
   if(life == 0 || life < 0)
   {
cout << "You died in the maze and so will the princess.\n";
   }
   else
   {
	   cout << "Congratulations you saved the day and probably the princess!\n";
   }
char ran;
cout << "Say goodbye!";
   cin >> ran;
	return 0;
}



int moi()
{
int obssesive = rand() % 10 + 1;
return obssesive;



}


int see(int path2)
{
	int rand2;
	
	switch(path2)
	{
	case 1: 
rand2 = rand() % 12 + 1;
return rand2;
			
		break;

	case 2:
rand2 = rand() %  9 + 3;
return rand2;
		break;
	};
return 0;
}





Hi! I just finished this game so am putting it on line. Compile it if you want and tell me if there's anything I could have done better.
See if you can remove the goto statement from your program, a simple google search would explain to you why you should avoid using them if possible.
Topic archived. No new replies allowed.