I'm trying to make a game similar to the Bloons Tower Defense games, i'm having trouble as I need to make it so that each balloon can only be shot by one tower, I'm trying to make it so that when the balloon is in the range the variable "marked" to true and only shoot at it if "marked" = false. Here is my code
:
public boolean isBalloonInRange()
{
return !getObjectsInRange(100, Balloon.class).isEmpty();
}
public void shoot()
{
if(isBalloonInRange()&&cooldown<1&&active==true){
Actor balloon = (Actor) getObjectsInRange(100, Balloon.class).get(0);
getWorld().addObject(new Bullet(balloon), getX(), getY());
balloon.marked=true;
cooldown=30;
}
cooldown--;
}
