I am trying to make a bar that slowly fills up while a delay goes down.
I have made a class for a part of the bar.
Now in a different class, LittleRedCapGun, I want to set up how and when to place one of those blocks.
in the act() I have put a delay:
when the delay is smaller than 1, you are able to shoot with this code, resetting it to 133
Now I want to make a method in LittleRedCapGun using a loop to place more bulletblocks when the delay gets smaller, but I am unsure how to make that loop. Can anyone help me with this?
public class BulletBlock extends Actor
{
/**
* Act - do whatever the BulletBlock wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
public BulletBlock()
{
drawBulletBlock();
}
public void drawBulletBlock()
{
GreenfootImage bulletblock = new GreenfootImage(3, 40);
Color color = new Color (10, 10, 250, 200);
bulletblock.setColor(color);
bulletblock.fillRect(0,0,3,40);
setImage(bulletblock);
}
}public void act()
{
keys(3);
shotDelay--;
shootGun();
}public void shootGun()
{
if (Greenfoot.isKeyDown("e") && shotDelay<1) {
if (direction==1)
{
shoot(270);
}
if (direction==2)
{
shoot(0);
}
if (direction==3)
{
shoot(90);
}
if (direction==4)
{
shoot(180);
}
shotDelay=shotDelayStart;
}
}
