So for awhile I have been working on this little game of mine which is definitely no where near completion but I am at a standstill. For whatever reason, I am getting these compiler errors for things that I cannot find. I have searched over the code countlessly and I have yet to find the error. Ignore the errors that aren't being recognized by the compiler because I am working on those. They arent compiler errors but personal errors. Anyway, here is the code and the errors. If someone could help me that would be great.
CODE:
#include "stdafx.h"
#include <iostream>
using namespace std;
int healthamount2 = 100;
int strength = 50;
class Player//*****************************DECLARATION OF CLASS "PLAYER"***********************************************************
{
public:
Player(int z, int c);//start strength and starthealth
void Fireball(int healthamount2);
void Lightningbolt(int healthamount2);
void Whirlwind(int health);
void heal1(int healthamount1);
void gainEXP(int EXP);
int HP;
int EXP;
int healthamount1;
};
class Ogre//*************DECLARATION OF CLASS "OGRE"*********************************************************************************
{
public:
Ogre(int x, int y);//startHealth and startStrength
void attack();
void heal(int healthamount2);
public:
int strength;
int healthamount2;
};
int main()//****************MAIN FUNCTION********************************************************************************************
{
Ogre abe(100, 50);
abe.attack();
abe.heal(10);
//PLAYER CLASS
Player mage (100, 100);
mage.Fireball(healthamount2);
mage.Lightningbolt(healthamount2);
mage.Whirlwind(healthamount2);
mage.heal1(10);
mage.gainEXP(20);
char f;
cin >> f;
return 0;
}
Ogre::Ogre(int startHealthamount2, int startStrength)://**********USE OF FUNCTIONS**********************************************************
strength(startStrength), healthamount2(startHealthamount2)
{
}
void Ogre::attack()
{
cout << "Get ready to eat my gosh damn dust!" << "::Stength = ::" << strength << endl;
}
void Ogre::heal(int health)
{
cout << "Ogre has healed himself!" << "::Current health = ::" << healthamount2 + 10 << endl;
}
Player::Player(int startHealthamount1, int startEXP)://************USE OF FUNCTIONS OF PLAYER CLASS*******************************************
EXP(startEXP), healthamount1(startHealthamount1)
{
}
void Player::Fireball(int healthamount2)
{
cout << "Player has attacked Ogre with Fireball! Ogre's Current health = " << healthamount2 - 25 << endl;
}
void Player::Lightningbolt(int healthamount2)
{
cout << "Player has attacked Ogre with Lightningbolt! Ogre's Current health = " << healthamount2 - 30 << endl;
}
void Player::Whirlwind(int healthamount2)
{
cout << "Player has attacked Ogre with Whirlwind! Ogre's Current health = " << healthamount2 - 5 << endl;
}
void Player::gainEXP(int EXP)
{
if(healthamount2 = 0)
cout << "Player has gained EXP! Current EXP = " << EXP + 20 << endl;
else
cout << "Player has gained NO EXP! Sowwy, better luck next time :(" << endl;
}
void Player::heal1(int health1)
{
cout << "Player has healed himself! Current health = " << healthamount1 + 10 << endl;
}
//*****************************************************************************************************************END**************
//************************************MADE ENTIRELEY FROM MEMORY OF SOUPER HAXXOR :)***************************************************
END OF CODE
ERRORS:
1>------ Build started: Project: Practice, Configuration: Debug Win32 ------
1> Player.cpp
1>c:\users\ethan's muchacho\desktop\c+++\practice\practice\player.cpp(33): error C2059: syntax error : ')'
1>c:\users\ethan's muchacho\desktop\c+++\practice\practice\player.cpp(40): error C2597: illegal reference to non-static member 'Player::healthamount'
1>c:\users\ethan's muchacho\desktop\c+++\practice\practice\player.cpp(41): error C2761: 'void Player::Fireball(void)' : member function redeclaration not allowed
1>c:\users\ethan's muchacho\desktop\c+++\practice\practice\player.cpp(41): fatal error C1004: unexpected end-of-file found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
*******************************END OF ERRORS******************
So yeah... I don't know what's going on so could someone help me? Thanks
CODE:
#include "stdafx.h"
#include <iostream>
using namespace std;
int healthamount2 = 100;
int strength = 50;
class Player//*****************************DECLARATION OF CLASS "PLAYER"***********************************************************
{
public:
Player(int z, int c);//start strength and starthealth
void Fireball(int healthamount2);
void Lightningbolt(int healthamount2);
void Whirlwind(int health);
void heal1(int healthamount1);
void gainEXP(int EXP);
int HP;
int EXP;
int healthamount1;
};
class Ogre//*************DECLARATION OF CLASS "OGRE"*********************************************************************************
{
public:
Ogre(int x, int y);//startHealth and startStrength
void attack();
void heal(int healthamount2);
public:
int strength;
int healthamount2;
};
int main()//****************MAIN FUNCTION********************************************************************************************
{
Ogre abe(100, 50);
abe.attack();
abe.heal(10);
//PLAYER CLASS
Player mage (100, 100);
mage.Fireball(healthamount2);
mage.Lightningbolt(healthamount2);
mage.Whirlwind(healthamount2);
mage.heal1(10);
mage.gainEXP(20);
char f;
cin >> f;
return 0;
}
Ogre::Ogre(int startHealthamount2, int startStrength)://**********USE OF FUNCTIONS**********************************************************
strength(startStrength), healthamount2(startHealthamount2)
{
}
void Ogre::attack()
{
cout << "Get ready to eat my gosh damn dust!" << "::Stength = ::" << strength << endl;
}
void Ogre::heal(int health)
{
cout << "Ogre has healed himself!" << "::Current health = ::" << healthamount2 + 10 << endl;
}
Player::Player(int startHealthamount1, int startEXP)://************USE OF FUNCTIONS OF PLAYER CLASS*******************************************
EXP(startEXP), healthamount1(startHealthamount1)
{
}
void Player::Fireball(int healthamount2)
{
cout << "Player has attacked Ogre with Fireball! Ogre's Current health = " << healthamount2 - 25 << endl;
}
void Player::Lightningbolt(int healthamount2)
{
cout << "Player has attacked Ogre with Lightningbolt! Ogre's Current health = " << healthamount2 - 30 << endl;
}
void Player::Whirlwind(int healthamount2)
{
cout << "Player has attacked Ogre with Whirlwind! Ogre's Current health = " << healthamount2 - 5 << endl;
}
void Player::gainEXP(int EXP)
{
if(healthamount2 = 0)
cout << "Player has gained EXP! Current EXP = " << EXP + 20 << endl;
else
cout << "Player has gained NO EXP! Sowwy, better luck next time :(" << endl;
}
void Player::heal1(int health1)
{
cout << "Player has healed himself! Current health = " << healthamount1 + 10 << endl;
}
//*****************************************************************************************************************END**************
//************************************MADE ENTIRELEY FROM MEMORY OF SOUPER HAXXOR :)***************************************************
END OF CODE
ERRORS:
1>------ Build started: Project: Practice, Configuration: Debug Win32 ------
1> Player.cpp
1>c:\users\ethan's muchacho\desktop\c+++\practice\practice\player.cpp(33): error C2059: syntax error : ')'
1>c:\users\ethan's muchacho\desktop\c+++\practice\practice\player.cpp(40): error C2597: illegal reference to non-static member 'Player::healthamount'
1>c:\users\ethan's muchacho\desktop\c+++\practice\practice\player.cpp(41): error C2761: 'void Player::Fireball(void)' : member function redeclaration not allowed
1>c:\users\ethan's muchacho\desktop\c+++\practice\practice\player.cpp(41): fatal error C1004: unexpected end-of-file found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
*******************************END OF ERRORS******************
So yeah... I don't know what's going on so could someone help me? Thanks
Aucun commentaire:
Enregistrer un commentaire