I need some help with game math.
What I am using:
I am using java awt library.
What I am trying to do:
I am trying to build enemy health bar, which will display as an rectangle. I am display two rectangles. First one is black rectange and it will act as in base container. 2nd one is red rectangle and it will act as helath bar.
now the max size of enemy health bar will be enemy.getWidth(). I need some help with 2nd red rectangle width. how can I set up so that it dependents on enemy.getHealth() and max is enemy.getWidth.?
and enemy.getHealth() will be 4.
g.setColor(Color.black); g.fillRect(enemy.getX(), enemy.getY(), enemy.getWidth(), 5); g.setColor(Color.red); g.fillRect(enemy.getX(), enemy.getY(), enemy.getHealth() * 4, 5);