So I am making this game in which you have 25 bullets, however, I do not know how to stop the game when I am out of bullets. With what I have the Bullets just start going into the negatives.
bulletCount = bulletCount - 1; // after a line something like this if (bulletCount == 0) Greenfoot.stop(); // add something like this line
if(Greenfoot.isKeyDown("space") && !shooting)
{
getWorld().addObject(new Bullet(), getX(), getY());
bulletsLeft.add(-1);
bulletCount = bulletCount - 1;
if(bulletCount == 0) Greenfoot.stop();
Space space = (Space)getWorld();//casting
Greenfoot.playSound("EnergyGun.wav");
shooting = true;
}