Evaluate my C++ console dungeon crawl idea?

Hey guys, I am doing a comprehensive test of my fundamental C++ skills by writing a huge console dungeon crawl just for fun. I wanted to see if you had any suggestions on how to make the code more efficient. My idea is that I run parts of the game in separate functions in order to be able to call those functions at will without having to worry about typing massive switch case statements and stuff. So, I'm just using everything I know about C++ to make this thing work. This is just the outline with a few elements started, nothing special, just need some guidance.

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
#include <iostream>
#include <string>

using namespace std;

//Player ints
int health = 100;
int magic = 50;
int points = 0;

//Print to screen player ints
void playerStats() {
	cout << "Player Status: " << endl;
	cout << "Health-" << health << endl;
	cout << "Magic-" << magic << endl; 
	cout << "Points-" << points << endl;
	
	
} 

//Below is the main code of the game
void mainGame(){
        
        string name;
        cout << "Enter a name " << endl;
        cin >> name;
        
	
	cout << name << ", you were separated from your friends after\nthe battle with that horrid dark beast." << endl;
	cout << "Do not fret, to your left is a passageway\nthat begins the long climb to the surface." << endl;
	cout << "Good luck.(Press enter to continue)" << endl;
	cin.get(); 

	
	
}

//Below is the game introduction
int main() {
	
	cout << "Welcome to Dungeoneer!" << endl;
	cout << "Programmed by Xha" << endl;
	cout << "Open source, free to distribute!" << endl;
	
	cout << "\nPress enter to begin the game." << endl; 
	cin.get();
	mainGame();
	
	cin.ignore();
	return 0;
}


One thing I need help on is programming the main loop as well as strings. I know how a string works, but it returns an error('name' undeclared in this scope) as is because of the code on line 26 for some reason. Any idea why? Any more suggestions as to how to complete this project? Notice any coding problems or bad practices?
Last edited on
Notice any coding problems or bad practices?
Global variables. Use classes to make your life easier. Also move all text outside in resource files (like GameText.txt) that way you can fix mistakes without nedd to recompile your code.

Do you want to make something like text adventure with occasional fights or something like, err..., well... Dungeon Crawl?
Topic archived. No new replies allowed.