NEED HELP

Okay. So I am sorta intermediate to the world of C++ and I am working on my first text based video game. But I keep getting these errors when everything seems fine! I don't understand why!? And even if I get the errors fixed, I can't test out the program without it closing after I type something, press enter, type something again, and press enter again. If someone could help with this that would be amazing! Anyway, happy coding!

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

using namespace std;


class PlayerStruct
{
	public:

		int EXP;
		int Health;
};

class Mage:public PlayerStruct
{
	

public:

	Mage(int y, int x);//starting health amount and starting EXP

	void Fireball(int Health2, int Health3, int Health4);
	void Lightningbolt(int Health2, int Health3, int Health4);
	void Whirlwind(int Health2, int Health3, int Health);
	void Heal(int Health);

	int EXP;
	int Health;
};

class Dragon
{
public:
	
	Dragon(int h);

	void Firebreath(int Health);
	void Icebreath(int Health);
	void Chomp(int Health);

	int Health4;
};

class Cyclops
{
public:

	Cyclops(int u);

	void Charge(int Health);
	void Smash(int Health);
	void Punch(int Health);

	int Health2;
};

class Eagle
{
public:

	Eagle(int g);

	void Swoop(int Health);
	void Claw(int Health);
	void Peck(int Health);

	int Health3;
};


int main()
{
	Mage Player(100, 100);
	Cyclops Boss(100);
	Eagle Boss2(100);
	Dragon Boss3(100);

	cout << "Welcome to Souper's First Text Based C++ Game!\n";
	cout << "Choose one of the numbers presented below by pressing the corresponding number\n";
	cout << " 1.\n 2.\n 3.\n";

	char a;
	char b;

	cin >> a;

	if(a == '1')
		{
			cout << "You have selected the first boss, The Cyclops!\n";
			Boss.Charge(Health);
			cout << "It is now your turn to attack! 'h' is fireball, 'j' is lightningbolt, 'k' is whirlwind, and 'L' is heal!" << endl;

			cin >> b;

			if(b == 'h')
				Player.Fireball(int Health2, int Health3, int Health4);
			else
				if(b == 'j')
					Player.Lightningbolt(int Health2, int Health3, int Health4);
				else
					if(b == 'k')
						Player.Whirlwind(int Health2, int Health3, int Health4);
					else
						if(b == 'l')
							Player.Heal(int Health);
	}
	
		if(a == '2')
		{
			cout << "You have selected the second boss, The Eagle!\n";
		}
		else
			if(a == '3')
			{
				cout << "You have selected the third boss, The Dragon!\n";
			}

			


	char f;
	cin >> f;
	return 0;
}

Mage::Mage(int starthealth, int startEXP)://****************************************************MAGE STRUCTURE**********************************************
Health(starthealth), EXP(startEXP)
{
}

void Mage::Fireball(int Health2, int Health3, int Health4)
{
	cout << "Mage has used Fireball! Fireball has dealt 25 damage! Current health of enemy = " << Health2 - 25 << endl;
}

void Mage::Lightningbolt(int Health2, int Health3, int Health4))
{
	cout << "Mage has used Lightningbolt! Lightningbolt has dealt 30 damage! Current health of enemy = " << Health2 - 30 << endl;
}

void Mage::Whirlwind(int Health2, int Health3, int Health4))
{
	cout << "Mage has used Whirlwind! Whirlwind has dealt 5 damage! Current health of enemy = " << Health2 - 30 << endl;
}

void Mage::Heal(int Health)
{
	if(Health == 100)
		cout << "You are already at full health! Current health = 100!" << endl;
	else
		cout << "Mage has healed himself! Current health of mage = " << Health + 10 << endl;
}

Cyclops::Cyclops(int starthealth2)://********************************************CYCLOPS STRUCTURE**************************************************************
Health2(starthealth2)
{
}



void Cyclops::Charge(int Health)
{ 
	cout << "Cyclops has used Charge! Current health of Mage = " << Health - 20 << endl;
}

void Cyclops::Smash(int Health)
{
	cout << "Cyclops has used Smash! Current health of Mage - " << Health - 30 << endl;
}

void Cyclops::Punch(int Health)
{
	cout << "Cyclops has used Punch! Current health of Mage = " << Health - 10 << endl;
}


Eagle::Eagle(int starthealth3)://*****************************EAGLE STRUCTURE*************************************************************************************
Health3(starthealth3)
{
}

void Eagle::Claw(int Health)
{
	cout << "Eagle has Struck you with Claw! Current health of mage = " << Health - 15 << endl;
}

void Eagle::Peck(int Health)
{
	cout << "Eagle has Pecked you! Current health of Mage = " << Health - 40 << endl;
}

void Eagle::Swoop(int Health)
{
	cout << "Eagle has swooped down in furry! Current health of Mage = " << Health - 30 << endl;
}

Dragon::Dragon(int starthealth4)://*******************************DRAGON STRUCT*************************************************************************************
Health4(starthealth4)
{
}

void Dragon::Chomp(int Health)
{
	cout << "Dragon has bitten you using Chomp! Current health of mage = " << Health - 10 << endl;
}

void Dragon::Firebreath(int Health)
{
	cout << "Dragon has burned you using Firebreath! Current health of mage = " << Health - 40 << endl;
}

void Dragon::Icebreath(int Health)
{
	cout << "Dragon has frozen you using Icebreath! Current health of mage = " << Health - 10 << endl;
}

//*****************************************************************************************************************END****************


 


[ERRORS]
1>------ Build started: Project: Game, Configuration: Debug Win32 ------
1> Game.cpp
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(91): error C2065: 'Health' : undeclared identifier
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(97): error C2144: syntax error : 'int' should be preceded by ')'
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(97): error C2660: 'Mage::Fireball' : function does not take 0 arguments
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(97): error C2059: syntax error : ')'
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(100): error C2144: syntax error : 'int' should be preceded by ')'
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(100): error C2660: 'Mage::Lightningbolt' : function does not take 0 arguments
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(100): error C2059: syntax error : ')'
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(103): error C2144: syntax error : 'int' should be preceded by ')'
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(103): error C2660: 'Mage::Whirlwind' : function does not take 0 arguments
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(103): error C2059: syntax error : ')'
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(106): error C2144: syntax error : 'int' should be preceded by ')'
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(106): error C2660: 'Mage::Heal' : function does not take 0 arguments
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(106): error C2059: syntax error : ')'
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(137): error C2059: syntax error : ')'
1>c:\users\ethan's muchacho\desktop\c+++\game\game\game.cpp(142): error C2059: syntax error : ')'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
[ERRORS]


-FrankMcDonald
Last edited on
Line 91: You did not declared Health varyable anywhere. What is it? What is it equals to?

Line 97 & others: You should not preceed your variable names by type when calling functions. Remove those ints. And your Health2 etc variables are not declared too
@MiiNiPaa Thank you so much! But where do I declare them? Inside of the class or outside of the scope? Becuase when I try to declare it like so:

Health == 100;
Health2 == 100;
Health3 == 150;
Health4 == 175;

It just doesn't work. It says that t expected a ';' before '==' but I tried that too and it's not working.
Last edited on
Boss.Charge(Health);What Health means here? What should it be equal to? At what moment in you code you will you know that?

Answer these questions and you should understand where to declare it.
@MiiNiPaa Okay, so I have finally got it to work but I can't test out the whole game because it only lets me type in two things and then it closes?
Topic archived. No new replies allowed.