Is this what you were talking about? it appears to work, but not sure if there is any bugs could you check it over, also should i move the array over to globals? How will this effect saving as i now have save/load in my game.
Code:
int ExperienceCalculator()
{
HANDLE hConsole; // Code for colored text
hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Code for colored text
// Array that stores the exp needed for each level
const int NextExperienceLevels[] = {0, 100, 225, 400, 925, 1400, 2425, 3650, 5675, 8150};
// Variables that store the experience for next level (Currently Unused - Guide Only)
const int NextExperienceUp2 = 100;
const int NextExperienceUp3 = 225;
const int NextExperienceUp4 = 400;
const int NextExperienceUp5 = 925;
const int NextExperienceUp6 = 1400;
const int NextExperienceUp7 = 2425;
const int NextExperienceUp8 = 3650;
const int NextExperienceUp9 = 5675;
const int NextExperienceUp10 = 8150;
// Variables that store the total exp at next level (Currently Unused - Guide Only)
const int NextExperience2 = 100;
const int NextExperience3 = 325;
const int NextExperience4 = 725;
const int NextExperience5 = 1650;
const int NextExperience6 = 3025;
const int NextExperience7 = 5475;
const int NextExperience8 = 7900;
const int NextExperience9 = 11550;
const int NextExperience10 = 19700;
// Variable that store new hit points value for next level (Base 20 + 5 per level)
const int PlayerHitPointsUp = 5;
// Variable that store new attack value for next level (Base 6 + 2 per level)
const int PlayerAttackUp = 2;
// Variable that store new defense value for next level (Base 3 + 3 per level)
const int PlayerDefenseUp = 3;
// Variable that stores new hitrate value for next level (Base 50% + 1% per level)
const int PlayerHitRateUp = 1;
{
SetConsoleTextAttribute(hConsole, 15); // Colored Text Red
}
cout << "\n[";
{
SetConsoleTextAttribute(hConsole, 12); // Colored Text Red
}
cout << " SYSTEM MESSAGE: ";
{
SetConsoleTextAttribute(hConsole, 15); // Colored Text Red
}
cout << "Experience Calculator ]\n";
cout << "\nChecking players level & experience stats.\n";
while ( PlayerExperience >= PlayerNextExperience)
if (PlayerExperience >= PlayerNextExperience)
{
cout << "Leveling up player.\n";
if (PlayerLevel < PlayerMaxLevel) PlayerNextExperience = NextExperienceLevels[PlayerLevel+1];
++PlayerLevel;
PlayerHitPoints = PlayerHitPoints + PlayerHitPointsUp;
PlayerMaxHitPoints = PlayerLevel * 5 + 15;
PlayerAttack = PlayerAttack + PlayerAttackUp;
PlayerDefense = PlayerDefense + PlayerDefenseUp;
PlayerHitRate = PlayerHitRate + PlayerHitRateUp;
}
else
{
cout << "\nPlayer does not need to be leveled up.\n";
cout << "Returning to game...\n\n";
}
cout << "Done leveling up player.\n";
cout << "Returning to game...\n\n";
return 0;
}