Hi, I'm relatively new to programming and I seem to be having a weird interval delay with some of my methods. The method affected is the one that makes the character in my game shoot and every now and then when i try tapping the button to shoot (l or v) it wont immediately fire and ill have to press it again. One thing I have noticed is changing the value of act() line 5 in the if statement makes the delay either larger or smaller, but is there anyway to get rid of it entirely?
public void act()
{
count++;
move();
if(count > 20)
{
shoot();
count = 0;
}
}
public void shoot()
{
if(Greenfoot.isKeyDown("l") && ammo > 0 && isPlayer1)
{
bullet c = new bullet(false);
getWorld().addObject(c, getX(), getY());
c.setRotation(getRotation()-90);
ammo--;
}
if(Greenfoot.isKeyDown("v") && ammo > 0 && !isPlayer1)
{
bullet c = new bullet(true);
getWorld().addObject(c, getX(), getY());
c.setRotation(getRotation()-90);
ammo--;
}
}

