I need help with a game ive made, basically i need to make it so that when i hold down the mouse i fire except i cant figure it out aha, any help? heres my code:
public class AssaultClass extends Character
{
private int counter = 0;
private int counter1 = 0;
private int counter2 = 10;
private int shoot1 = 0;
private int health = 60;
private int health1 = 0;
private int reload = 0;
/**
* Act - do whatever the Survivor wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
shoot();
reload();
move();
Menu();
Helper();
Healer();
shooter();
HealthKit();
ZombieHit();
SurvivorZombieHit();
checkHealth();
onGround();
MouseInfo m = Greenfoot.getMouseInfo();
if(m != null)
turnTowards(m.getX(), m.getY());
}
private void bumpCounter2(int amount)
{
ZombieLand world;
world = (ZombieLand)getWorld();
Counter2 counter;
counter = (Counter2)world.getObjects(Counter2.class).get(0);
counter.add(amount);
}
public void shoot()
{
counter1++;
if (Greenfoot.mousePressed(null) && (shoot1 == 0) && (counter1 > 5) )
{
getWorld().addObject(new Bullet(getRotation()), getX(), getY());
reload++;
bumpCounter2(-1);
counter1 = 0
}
}
public void reload()
{
if (reload == 30)
{
shoot1++;
getWorld().addObject(new Reloading(), 91, 785);
}
if (shoot1 == 300)
{
getWorld().removeObjects(getWorld().getObjects(Reloading.class));
shoot1 = 0;
reload = 0;
bumpCounter2(30);
}
}
