This site requires JavaScript, please enable it in your browser!
Greenfoot back
Jeeshan
Jeeshan wrote ...

2021/4/25

How to flip a fuelbar by 180 degrees

Jeeshan Jeeshan

2021/4/25

#
I made a fuel bar that is supposed to be vertical and slowly decreasing. But the issue here is that it decreases from bottom to top. How do I go about flipping that
Jeeshan Jeeshan

2021/4/25

#
import greenfoot.*;  
public class FuelAmount extends Actor
{
    private static int fuelcounter=5;
    private static int fuelwidth=10;
    private static int fuelheight=100;
    private static int pixelperfuel=(int)fuelheight/fuelcounter;
    
    public FuelAmount()
    {
        update();
    }
    public void act() 
    {
        update();
        //setImage(new GreenfootImage("Fuel Tank:"+getfuel(),32,Color.RED,new Color(0,0,0,0)));
    }  
    public void update()
    {
        setImage(new GreenfootImage(fuelwidth,fuelheight));
        GreenfootImage myImage=getImage();
        myImage.setColor(Color.WHITE);
        myImage.drawRect(0,0,fuelwidth+1,fuelheight+1);
        myImage.setColor(Color.RED);
        myImage.fillRect(1,1,fuelwidth,fuelcounter*pixelperfuel);
    }
    public static int getfuel(){
        return fuelcounter;
    }
    public static void setfuel(int fc){
        fuelcounter=fc;
    }
    
    
}
Risen Risen

2021/4/25

#
public FuelAmount()
    {
turn(180);
       update();
    }
You need to login to post a reply.