Hey everyone=) my name is grux and I've got something of a problem.... First off, let me say that this is NOT for a class, I am simply trying to follow some online tutorials so I can be prepared for college this fall. I'm new to C++ (having only worked with FreeBASIC, LibertyBASIC, and VRML before) and don't understand functions very well. To try and add value to my code (purely a psychological thing for me to understand the point of the code), I act as if I'm programming a Pokemon game.
That being said, I'm getting several error messages when I try to compile this bit of code. What I'm trying to accomplish is to make a function that calculates how much experience your Pokemon gained in the battle it just won, whether it gained a level or not, and if so, is it going to evolve? Anyway, here's the code:
#include <iostream>
#include <cstdlib>
using namespace std;
void battleXpCalc ( int oppLevel, int oppAtk, int oppDef, int oppHp, int myLvl, int myXp, int battleXp, char battlePoke(20), int neededXp, int evoLvl, char evo(3) );
int battleXpCalc ( int oppLevel, int oppAtk, int oppDef, int oppHp, int myLvl, int myXp, int battleXp, char battlePoke(20), int neededXp, int evoLvl, char evo(3) ); {
battleXp = oppLevel + oppAtk + oppDef + oppHp / myLvl;
myXp = myXp + battleXp;
cout<< "You just gained "<< battleXp <<" xp! Your "<<battlePoke<<" now";
cout<< "has "<< myXp <<" !";
if ( myXp >= neededXp ) {
myLvl = myLvl + 1;
cout<< "Congratualtions! Your "<< battlePoke <<" gained a level!";
neededXp = myXp - battleXp + myLvl;
}
if ( evo = "off" ) {
evoLvl = myLvl + 1;
}
if ( myLvl >= evoLvl ) {
cout<< "What? "<< battlePoke <<" is trying to evolve! He seems determined";
cout<< "There's no stopping him now!";
}
return 0;
}
int main()
{
int oppLevel, oppAtk, oppDef, oppHp, myLvl, neededXp, evoLvl;
char battlePoke(20), evo(3);
oppLevel = 36;
oppAtk = 78;
oppDef = 84;
oppHp = 78;
myLvl = 35;
neededXp = 100;
evoLvl = 36;
battlePoke = "Wartortle";
evo = "on";
battleXpCalc();
cin.get();
}
my error messages returned are:
6-- expected 'or' before '(' token
6-- ambiguates old declaration `void battleXpCalc(int, int, int, int, int, int, int, char)'
8-- expected 'or' before '(' token
8-- new declaration 'int battleXpCalc(int, int, int, int, int, int, int, char)'
8-- expected unqualified-id before '{' token
8-- expected `,' or `;' before '{' token
~~~~~~~~~~~~~~~~~~~C:\Dev-Cpp\love.cpp In function `int main()':~~~~~~~~~~~~
39-- non-lvalue in assignment
40-- non-lvalue in assignment
8-- too few arguments to function `int battleXpCalc(int, int, int, int, int, int, int, char)'
41-- at this point in file
By the way, I'm using the Bloodshed Dev C++ IDE
Any help would be greatly appreciated=) Thank-you