Game code

I need some help with my game:

here is Main.cpp code:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "Library.h"

;void main();
{
	
	
		// Generic welcome screen.

		cout << "\n\nWelcome to WRATH LANDS\n";
		cout << "Programmed by Timothy Thompson\n\n";

		cout << "An evil demon creature known as the wraith lord has taken control of the\nworld.  He controls a vast army of evil creatures who kill people for fun.\nYou must rise against the wraith lord and kill all his minions.\n\n";

		Wait();

		Crossroads();

		cout << "\n\nThank you for WRATH LANDS!  Please play again soon.\n\n";
	
	return 0;
}

This has this error:


1>c:\documents and settings\timbo\my documents\visual studio 2008\projects\game\game\main.cpp(4) : error C2447: '{' : missing function header (old-style formal list?)


This is Crossroads.cpp:

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
#include "Library.h"

//CROSSROADS

//GLOBAL VARIABLES

;bool glcomplete = false;
bool fcomplete = false;
bool scomplete = false;
bool gcomplete = false;
bool ccomplete = false;

bool Crossroads()
{
	int choice = 0;

	while (choice !=10)
	{
		cout << "You stand at the center of several roads going off in many directions.\n\n";
		cout << "There is a small town behind you full of shops and people.\n\n";

		cout << "Which path do you choose?\n";
		cout << "1 : Town\n";
		cout << "2 : Summoning Portal\n";
	
		if (!glcomplete)
			cout << "3 : Grasslands (QUEST)\n";

		if (glcomplete && !fcomplete)
			cout << "4 : Forest Road (QUEST)\n";

		if (fcomplete && !scomplete)
			cout << "5 : Swamp Road (QUEST)\n";

		if (scomplete && !gcomplete)
			cout << "6 : Graveyard Road (QUEST)\n";

		if (gcomplete && !ccomplete)
			cout << "7 : Castle Road (QUEST)\n";

		cout << "10 : Exit Game\n";

		cout << ">";
	
		cin >> choice;
		switch (choice)
	
		{
		case 1:
			{
				Town();
				break;
			}
		case 2:
			{
				//SummonPortal();
				break;
			}
		case 3:
			{
				//if (!glcomplete)
				//Grasslands();
				break;
			}
		case 4:
			{
				//if (glcomplete && !fcomplete)
					//Forest();
				break;
			}
		case 5:
			{
				//if (fcomplete && !scomplete)
				//Swamp();
				break;
			}
		case 6:
			{
				//if (scomplete && !gcomplete)
				//Graveyard();
				break;
			}
		case 7:
			{
			//if (gcomplete && !ccomplete)
				//Castle();
				break;
			}
		default: break;
	}

	return true;
}

I get this error:

1>c:\documents and settings\timbo\my documents\visual studio 2008\projects\game\game\crossroads.cpp(94) : fatal error C1075: end of file found before the left brace '{' at 'c:\documents and settings\timbo\my documents\visual studio 2008\projects\game\game\crossroads.cpp(14)' was matched



This is helper.cpp:
1
2
3
4
5
6
7
8
9
#include "Library.h"

//HELPER FUNCTIONS

void Wait();
{
	cout << "Press Enter to Continue.\n";
	cin.ignore(1);
}

with this error:

1>c:\documents and settings\timbo\my documents\visual studio 2008\projects\game\game\helper.cpp(6) : error C2447: '{' : missing function header (old-style formal list?)
Start by getting rid of all those out-of-place semicolons as follows-

Main.cpp
;void main(); // unwanted semi-colon at start and end of line

Crossroads.cpp
;bool glcomplete = false; // unwanted semi-colon at start of line

Helper.cpp
void Wait(); // unwanted semi-colon at end of line

We'll see what errors come up after you have removed those.
That fixed helper.cpp

the Main.cpp code is this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "Library.h"

;void main()
{
	
	
		// Generic welcome screen.

		cout << "\n\nWelcome to WRATH LANDS\n";
		cout << "Programmed by Timothy Thompson\n\n";

		cout << "An evil demon creature known as the wraith lord has taken control of the\nworld.  He controls a vast army of evil creatures who kill people for fun.\nYou must rise against the wraith lord and kill all his minions.\n\n";

		Wait();

		Crossroads();

		cout << "\n\nThank you for WRATH LANDS!  Please play again soon.\n\n";
	
	return 0;
}


I get this error

1>c:\documents and settings\timbo\my documents\visual studio 2008\projects\game\game\main.cpp(20) : error C2562: 'main' : 'void' function returning a value

and this error

1> c:\documents and settings\timbo\my documents\visual studio 2008\projects\game\game\main.cpp(3) : see declaration of 'main'

Here is my crossroads code

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
#include "Library.h"

//CROSSROADS

//GLOBAL VARIABLES

bool glcomplete = false;
bool fcomplete = false;
bool scomplete = false;
bool gcomplete = false;
bool ccomplete = false;

bool Crossroads()
{
	int choice = 0;

	while (choice !=10)
	{
		cout << "You stand at the center of several roads going off in many directions.\n\n";
		cout << "There is a small town behind you full of shops and people.\n\n";

		cout << "Which path do you choose?\n";
		cout << "1 : Town\n";
		cout << "2 : Summoning Portal\n";
	
		if (!glcomplete)
			cout << "3 : Grasslands (QUEST)\n";

		if (glcomplete && !fcomplete)
			cout << "4 : Forest Road (QUEST)\n";

		if (fcomplete && !scomplete)
			cout << "5 : Swamp Road (QUEST)\n";

		if (scomplete && !gcomplete)
			cout << "6 : Graveyard Road (QUEST)\n";

		if (gcomplete && !ccomplete)
			cout << "7 : Castle Road (QUEST)\n";

		cout << "10 : Exit Game\n";

		cout << ">";
	
		cin >> choice;
		switch (choice)
	
		{
		case 1:
			{
				Town();
				break;
			}
		case 2:
			{
				//SummonPortal();
				break;
			}
		case 3:
			{
				//if (!glcomplete)
				//Grasslands();
				break;
			}
		case 4:
			{
				//if (glcomplete && !fcomplete)
					//Forest();
				break;
			}
		case 5:
			{
				//if (fcomplete && !scomplete)
				//Swamp();
				break;
			}
		case 6:
			{
				//if (scomplete && !gcomplete)
				//Graveyard();
				break;
			}
		case 7:
			{
			//if (gcomplete && !ccomplete)
				//Castle();
				break;
			}
		default: break;
	}

	return true;
}


Here is the error I get

1>c:\documents and settings\timbo\my documents\visual studio 2008\projects\game\game\crossroads.cpp(94) : fatal error C1075: end of file found before the left brace '{' at 'c:\documents and settings\timbo\my documents\visual studio 2008\projects\game\game\crossroads.cpp(14)' was matched
When a function has it's return type as void, it means that
it does not return a value.
Therefore to say return 0 in the main function is an error. You are returning an integer value
You should change to int main() and keep the return statement.

In crossroads.cpp you are missing the } for the switch statement - so you have three { but only two }.

1
2
3
4
5
6
7
8
9
		
case 7:
{
     //if (gcomplete && !ccomplete)
     //Castle();
     break;
}
default: break;
} // <----   this end of switch  brace is missing 


Last edited on
Topic archived. No new replies allowed.