Hi all, I'm running into a problem with the health bar, currently I am drawing it through the draw Rect method, and I am currently using health/100 (which is my max health) x value to draw it, however since it's a int the diving has some problems, is there anyway to make it so that the healthbar doesn't drop in chunks?
I've tried casting it to double then back to int, but it still doesn't work, any help will be greatly appreciated.
public void drawHealth(){ //gets player info int myHealth = ((MyTank) getWorld().getObjects(MyTank.class).get(0)).getHealth(); //draws bar buffer++; if(buffer % 2 == 0){ GreenfootImage image = new GreenfootImage(601, 68); image.setColor(Color.BLACK); image.fillRect(72, 42, 601, 60); image.setColor(new Color(128, 255, 0)); image.fillRect(72, 42, myHealth/100*39, 59); } }