Hello! I am programming a Bomberman and I need to keep track of when I (BomberManP1) place a bomb (Bomb). I need this because I am making an upgrade system where crates drop that have upgrades, and the first upgrade I'm trying to implement is BombUp (Increase number of bombs I can place). I have it set up now so that, after I check if I can place a Bomb, I place one, and increase my "numOfBombs" int by 1. I need now to set up a way to decrease "numOfBombs" int by 1 after the Bomb explodes, without having a variable in my BomberManP1 class that just counts down the same amount of time I have my Bomb count down from. (Sorry if this is confusing, if you need clarification please tell me). Now, the code -
BomberManP1 act()
BomberManP1 updateSelf()
BomberManP1 bomb()
Currently the only thing in the Bomb class is it counting down from a set amount of times, progressively changing pictures to make it look as if it's on a fuse, then exploding and adding "DeadlyExplosions" class around it, which kills players and breakable blocks it touches.
public void act()
{
// Add your action code here.
updateSelf();
time++;
moveTimer--;
bombDelay--;
bomb();
move();
}public void updateSelf()
{
if(getWorld().getObjectsAt(getX(), getY(), DeadlyExplosion.class).size() != 0) // Ignore this bit, work in progress.
{
setImage("Bomberman Death P1.png");
setImage("Bomberman Death P2.png");
setImage("Bomberman Death P3.png");
setImage("Bomberman Death P4.png");
}
if(getWorld().getObjectsAt(getX(), getY(), BombUp.class).size() != 0 && bombCap < 5) // Don't ignore this bit
{
bombCap++;
getWorld().removeObjects(getWorld().getObjectsAt(getX(), getY(), BombUp.class));
}
}public void bomb()
{
if(Greenfoot.isKeyDown("space") && getWorld().getObjectsAt(getX(), getY(), Bomb.class).size() ==0 && bombDelay <= 0
&& numOfBombs < bombCap)
{
getWorld().addObject(new Bomb(), getX(), getY());
numOfBombs++;
bombDelay = BD_RESET;
System.out.println("bombCap : " + bombCap + " isBombCapped : " + isBombCapped + "numOfBombs" + numOfBombs);
}
}


