One of my first programs, I want criticism. (Text Adventure)

I started making this text adventure. It very very short currently. I am new to programming and this is my first go at an actual program. I am open to critisism about my code, organization, style, etc...

Here is the download link to the exe.

https://mega.nz/#!PM4hGCrD!n2g2vMXWElMNDIUx3kuM0QaQibkkAaOn-1nzJHytGrI


I will also provide the code below.

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
// Text Adventure

#include <iostream>
#include <string>


using namespace std;



int main()
{
//Variables--------------------------------------------------------------------------------
	string charactersfirstname;
	string characterslastname;
	int chapter1;
	int chapter2;


//Intro
	cout << "Devyn's Text Adventure" << endl << endl;
	system("PAUSE");
	system("CLS");


//Get Players Name-------------------------------------------------------------------------
		cout << "Please enter your character's first name." << endl;
		cin >> charactersfirstname;
			system("CLS");

		cout << "Please enter your character's last name." << endl;
		cin >> characterslastname;
			system("CLS");

		cout << "Your characters name is " << charactersfirstname;
		cout <<" " << characterslastname << "." << endl;
			system("PAUSE");
			system("CLS");

//Get Players Gender------------------------------------------------------------------------
		chooseGender:
			system("CLS");

		string playersGender;
		cout << "What gender are you? Enter 'male' or 'female'." << endl;
		cin >> playersGender;
			system("CLS");

			if (playersGender == "male") {
				cout << "You chose male." << endl;
				system("PAUSE");
				system("CLS");
			}

			else if (playersGender == "female") {
				cout << "You chose female." << endl;
				system("PAUSE");
				system("CLS");
			}

			else {
				cout << "You must enter either 'male' or 'female'." << endl;
				system("PAUSE");
				goto chooseGender;
			}


//Select Chapter To Play
			int getchaptertoplay;

		selectchapter:
			system("PAUSE");
			system("CLS");

			cout << "Please Select the chapter you would like to play by entering the chapter number." << endl << endl;
			cout << "Chapter 1 (Nameless)             Chapter 2 (Comming Soon)" << endl;
				cin >> getchaptertoplay;

				if (getchaptertoplay == 1) {
					system("CLS");
					goto chapteroneplay;
					}

				else if (getchaptertoplay == 2) {
					system("CLS");
					cout << "Chapter 2 is coming soon. Please select a different chapter." << endl;
					system("PAUSE");
					goto selectchapter;
				}

				else {
					system("CLS");
					cout << "Please select a valid chapter." << endl;
					system("PAUSE");
					goto selectchapter;
				}


//Chapter 1
			chapteroneplay:
				system("CLS");

				cout << "You chose chapter one." << endl;
				cout << "Lets get started..." << endl;
				system("PAUSE");
					goto dialog_1_start;

	//Dialog 1__________________________________________________________________________________________________________________
	dialog_1_start:
			string dialog1;

			system("CLS");
			
				cout << "You wake up. You feel exausted, along with a major head rush." << endl << "Choices:" << endl;
				cout << "A) Stand up quickly.    B) Stand up slowly." << endl << endl;

				cin >> dialog1;
		//Dialog 1 Choice A
				if (dialog1 == "a") {
					system("CLS");

					cout << "You stand up quickly, but not before callapsing straight onto the cold metal floor.   *Clank!*" << endl << endl;
					cout << "You slowly get back to your feet and glance at your surroundings." << endl;
					cout << "The room is dark, with your eyes not quite adjusting to the darkness." << endl << endl << endl;
						system("PAUSE");
						system("CLS");
					cout << "*BLEEP*..*BLEEP*..*BLEEP*..." << endl << endl;
						system("PAUSE");
						system("CLS");
					cout << "*BLEEP*..*BLEEP*..*BLEEP*..." << endl << endl;
						system("PAUSE");
						system("CLS");
					cout << "The noise is coming from across the room. You walk to the area the noise is echoing from." << endl;
					cout << "There is a desk cluttered with papers, with a keyboard buried underneath them." << endl << endl;
						system("PAUSE");

				

				//	goto dialog_1_a;
					}

		//Dialog 1 Choice B
				else if (dialog1 == "b") {
							system("CLS");
						cout << "You take your time getting up. The head rush goes away and your vision is clear." << endl;
						cout << "You notice its cold, and you feel alone in the dark, empty room." << endl;
						cout << "*BLEEP*..*BLEEP*..*BLEEP*..." << endl << endl;
							system("PAUSE");
							system("CLS");
						cout << "*BLEEP*..*BLEEP*..*BLEEP*..." << endl << endl;
							system("PAUSE");
							system("CLS");
						cout << "The noise is coming from across the room. You walk to the area the noise is echoing from." << endl;
						cout << "There is a desk cluttered with papers, with a keyboard buried underneath them." << endl;
						system("PAUSE");

				//	goto dialog_1_b;
				}
//Dialog 1 END____________________________________________________________________________________________________________________



	return 0;
}
Hi,

Don't use goto, learn how to use functions and loops instead. And the switch statement.
Last edited on
@TheIdeasMan
Could you elaborate on that a little bit more?
Last edited on
Hi,

Look at the tutorial on the upper left of this page. Look up functions loops and switch.
1. Inconsistent variable naming.
2. goto
3. Code identation.
4. Split to functions for example for each room or choice.. (or probably classes)
Topic archived. No new replies allowed.