Ok I fixed the potion bug with your suggestions (and I now understand why the bug was there)
I wrote that:
case '+': //Potion - adds 5 health
if ( Player.getHealth() +5 < Player.getMaxHealth() )
Player.setHealth( Player.getMaxHealth() );
By the way my
thing uses a signed short as a value, so you can also take away like
(in maths value +- 5, is the same as value - 5)
And I changed
to short instead of unsigned short (just to handle any possible errors)
... and finally
|If the player's health is 5 or 0, suddenly maxhealth becomes 200 instead of 20.|
|From the code you posted here, I don't know how you know this|
Ummm... maybe because I can see that on the screen, when the program is running? (the exact same code I posted, well... with the potion fix)
You have to compile the code for yourself, so you can see (or possibly, it's due to my computer?)
|I don't see where max health is being set|
It's set to 20 in the constructor.
I know that there's no code that affects maxhealth, so it still confuses me, must be a leak or something somewhere. And I changed the line where the health is displayed to
std::cout << "Health: " << Player.getHealth() << "/" << Player.getMaxHealth() << std::endl;
but that didn't help, maxhealth still becomes 200 when the player's health is 5 or 0.
So there's one more bug to go!