I've got a pistol and shotgun in my game. Unfortunately, the user, by holding the spacebar, can generate an infinite number of bullets. Since both weapons are intended to be semi-automatic, I've been trying to make use of a boolean to determine whether or not the code should generate a new Bullet actor. Code follows:
But this code, like the vast majority of my scenario, doesn't want to do what I want it to do. What am I doing wrong? I think it's the location of isShot (i.e. initializing it to "true" in the wrong place).
boolean isShot = false;
//code stuff that I've omitted b/c it's unnecessary
if(Greenfoot.isKeyDown("space")) //Shooting mechanism
{ isShot = true;
if(usingShotgun) //adds three bullets to the world for a shotgun-y effect
{
if(isShot = true)
{
getWorld().addObject(new Bullet(), this.getX(), this.getY()+30);
getWorld().addObject(new Bullet(), this.getX()-10, this.getY()+30);
getWorld().addObject(new Bullet(), this.getX()+10, this.getY()+30);
}


