Program ends at second while in function z1

I am very confused!
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#include "stdafx.h"
#include "Main.h"
#pragma warning(disable : 4996)

using namespace std;
random_device rd;

//VARIABLES
string input;
int facing;
int z5location;
bool z1first = true;
int Wood;
int Cloth;
int Hydration = 100;
bool Flag = false;
bool loop = true;

//FUNCTION DECLARATIONS
int z1();
int z2();
int z3();
int z4();
int z5();
int z6();
int z7();
int z8();
int z9();
int z10();
int z11();
int z12();
int z13();
int z14();
void convert();

//ZONES
int z1() {
	if (z1first = true) {
		cout << "Would you like to look around?" << endl;
		while (true) {
			cin >> input;
			if (input == "yes") {
				cout << "You are on a small beach with a large wrecked sailboat. You look towards land." << endl;
				Sleep(4000);
				cout << "To your left is a steeply sloping hill that forms cliffs that drop off into the water." << endl;
				Sleep(4100);
				cout << "Your right looks the same, but you see some sort of ruin at the top." << endl;
				Sleep(3500);
				cout << "In front of you, a couple hundred yards away is the end of an unusually large cove with very gentle waves lapping at the shore." << endl;
				Sleep(6750);
				break;
			}
			else if (input == "no") {
				break;
			}
			else {
				cout << "What was that?" << endl;
			}
		}
		cout << "What would you like to do?" << endl;
		while (true) {
			cin >> input;
			if (input == "go left" || "left") {
				system("CLS");
				facing = 4;
				break;
				Hydration -= 5;
				z2();
			}
			else if (input == "go forwards" || "go straight") {
				system("CLS");
				facing = 1;
				z5location = 5;
				Hydration -= 5;
				break;
				z5();
			}
			else if (input == "go right" || "right") {
				system("CLS");
				facing = 2;
				break;
				Hydration -= 5;
				z3();
			}
			else if (input == "search the wreck" || "search" || "search the boat") {
				system("CLS");
				cout << "You put yourself together, and walk over towards the wrecked sailboat." << endl;
				Sleep(3050);
				cout << "You climb in through the gaping hole on the port side, and begin looking for anything that could be useful." << endl;
				Sleep(4900);
				cout << "Inside, you find a piece of wood, a large backpack, and enough rations to keep you alive for months. But no water..." << endl;
				Sleep(6000);
				Wood = 1;
				cout << "You now have " << Wood << " piece(s) of wood." << endl;
				Sleep(3000);
				cout << "There is also a flag on the boat that you could fold up and take with you. Do you want to take it?" << endl;
				while (true) {
					cin >> input;
					if (input == "yes") {
						/*int random = rd() % 1 + 4;
						for (int i = 0; i < h.length(); i++) {
							h[i] = tolower(h[i]);
						}*/
					}
					else if (input == "no") {
						cout << "You decide that the flag isn't worth the effort, so you leave it behind." << endl;
						break;
					}
					else {
						cout << "What was that?" << endl;
					}
				}
			}
			else {
				cout << "You could type to go left, right, straight, or to search the wreck." << endl;
			}
		}
	}
	else {
		cout << "Would you like to look around?" << endl;
		cin >> input;
		while (true) {
			if (input == "yes") {
				cout << "You are on a small beach with a large wrecked sailboat. You look towards land." << endl;
				Sleep(4000);
				cout << "To your left is a steeply sloping hill that forms cliffs that drop off into the water." << endl;
				Sleep(4100);
				cout << "Your right looks the same, but you see some sort of ruin at the top." << endl;
				Sleep(3500);
				cout << "In front of you, a couple hundred yards away is the end of an unusually large cove with very gentle waves lapping at the shore." << endl;
				Sleep(6750);
				break;
			}
			else if (input == "no") {
				break;
			}
			else {
				cout << "What was that?" << endl;
			}
		}
		cout << "What would you like to do?" << endl;
		while (true) {
			cin >> input;
			if (input == "go left" || "left") {
				system("CLS");
				facing = 4;
				break;
				Hydration -= 5;
				z2();
			}
			else if (input == "go forwards" || "go straight") {
				system("CLS");
				facing = 1;
				z5location = 5;
				break;
				Hydration -= 5;
				z5();
			}
			else if (input == "go right" || "right") {
				system("CLS");
				facing = 2;
				break;
				Hydration -= 5;
				z3();
			}
			else {
				cout << "What was that?." << endl;
			}
		}
	}
	return 0;
}
int z2() {
	return 0;
}
int z3() {
	return 0;
}
int z4() {
	return 0;
}
int z5() {
	return 0;
}
int z6() {
	return 0;
}
int z7() {
	return 0;
}
int z8() {
	return 0;
}
int z9() {
	return 0;
}
int z10() {
	return 0;
}
int z11() {
	return 0;
}
int z12() {
	return 0;
}
int z13() {
	return 0;
}
int z14() {
	return 0;
}

//OTHER FUNCTIONS


int main() {

	CONSOLE_FONT_INFOEX cfi;
	cfi.cbSize = sizeof(cfi);
	cfi.nFont = 0;
	cfi.dwFontSize.X = 0;                   // Width of each character in the font
	cfi.dwFontSize.Y = 28;                  // Height
	cfi.FontFamily = FF_DONTCARE;
	cfi.FontWeight = FW_NORMAL;
	std::wcscpy(cfi.FaceName, L"DINPro-regular"); // Choose your font
	SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);

	/*cout << "CRASH!!!" << endl;
	Sleep(3000);
	system("CLS");
	Sleep(5000);
	cout << "*Seagulls squawk*" << endl;
	Sleep(3000);
	cout << "*Waves crashing*" << endl;
	Sleep(4000);
	cout << "'Uuuuh...'" << endl;
	Sleep(2000);
	cout << "'What happened?" << endl;
	Sleep(1400);
	cout << "'How did I get here?!'" << endl;
	Sleep(1200);
	system("CLS");
	cfi.cbSize = sizeof(cfi);
	cfi.nFont = 0;
	cfi.dwFontSize.X = 0;                   
	cfi.dwFontSize.Y = 45;                  
	cfi.FontFamily = FF_DONTCARE;
	cfi.FontWeight = FW_NORMAL;
	std::wcscpy(cfi.FaceName, L"DINPro-regular");
	SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
	cout << "W";
	Sleep(100);
	cout << "H";
	Sleep(100);
	cout << "O";
	Sleep(100);
	cout << " ";
	Sleep(100);
	cout << "A";
	Sleep(100);
	cout << "M";
	Sleep(100);
	cout << " ";
	Sleep(100);
	cout << "I";
	Sleep(100);
	cout << "?";
	Sleep(2500);
	system("CLS");
	cfi.cbSize = sizeof(cfi);
	cfi.nFont = 0;
	cfi.dwFontSize.X = 0;
	cfi.dwFontSize.Y = 28;
	cfi.FontFamily = FF_DONTCARE;
	cfi.FontWeight = FW_NORMAL;
	std::wcscpy(cfi.FaceName, L"DINPro-regular");
	SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
	cout << "You try to remember your name, and how you got here, but nothing comes to you..." << endl;
	Sleep(3800);
	cout << "Scared and tired, you pull yourself to your feet." << endl;
	Sleep(2300);
	*/
	z1();
    return 0;
}

Much is unfinished, and much is noted out so I could get to the problem area faster
Last edited on
Please edit your post to include code tags (the <> icon).
Line 38: you confuse = (assignment) with == (comparison for equality)
if (z1first = true) {
should be
if (z1first == true) {



In many places, line 63, 68, etc. you miswrite the logical or's: you will need a logical test (presumably input ==...) on both sides of the ||.
if (input == "go left" || "left") {
should be
if (input == "go left" || input == "left") {
with many similar cases.


You should build up code gradually, testing at each stage, not confront a wall of code at once. Also, do not use so many global variables and use more meaningful names for your functions than z1(), z2(), etc.
Last edited on
Topic archived. No new replies allowed.