please format code with </> button * homework policy * asking questions Making a game of my computer studies class and i’m struggling to make a health system with just variables and if statement (that 's all were allowed to use).
code looks kinda like this…
float Ehp = 200; //enemy health
fill (0); //enemy health
rect (575, 500, 200, 40);
fill (0, 255, 0);
rect (575, 500, Ehp, 40);
if (y > 55 && y < 220)//yellow (does 50 damage)
{
Ehp = 200 - 50;
}
if (y > 55 && y < 220 && Ehp == 150)//yellow - yellow
{
Ehp = 200 - 100;
}
if (y > 90 && y < 187)//orange (does 100 damage)
{
Ehp = 200 - 100;
}
if (y > 120 && y < 159)//red (does 150 damage)
{
Ehp = 200 - 150;
}
if (y > 135 && y < 145)//black (does 200 damage)
{
Ehp = 200 - 200;
}
Everything works except for when I want to shoot the enemy again yellow - yellow one won’t work because as soon as enemy’s health = 150, it instantly changes it to 100. I only want it to change to 100 after another shot is fired.