hey guys, here's my problem.
im making a text based rpg and i want to show the player's HP in green whenever his current hp is larger than 50% of the max hp.
as well as showing it in yellow when his hp ranges from 49% to 26%.
and also showing it in red whenever it's lower than 25% of the max hp.
My code works fine whenever you have more than 50%, but it keeps showing it in green all the way down to 25%, it basically bypasses the yellow command and goes right to red.
here's my code, hope someone can help me.
(this isn't homework btw i'm doing this on my own)
the max hp is 40.
Code:
if (ok.player > 51% ok.maxhp)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("{0}/{1} HP", ok.player, ok.maxhp);
Console.ForegroundColor = ConsoleColor.White;
}
else
if ((ok.player >= 26% ok.maxhp) && (ok.player <= 50% ok.maxhp))
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("{0}/{1} HP", ok.player, ok.maxhp);
Console.ForegroundColor = ConsoleColor.White;
}
else
if (ok.player < 25% ok.maxhp)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("{0}/{1} HP", ok.player, ok.maxhp);
Console.ForegroundColor = ConsoleColor.White;
}