as of right now my firing is one after another and ive tried alot of different code to fix it and none works
Shooter(gun)
Bullet code
HELP!
public class Shooter extends Actor
{
public void act()
{
if(Greenfoot.isKeyDown("space") )
{
getWorld().addObject(new bullet(getRotation()), getX(), getY());
}
if (Greenfoot.isKeyDown ("w"))
{
move(3);
}
if (Greenfoot.isKeyDown ("s"))
{
move(-3);
}
if (Greenfoot.isKeyDown ("d"))
{
turn(4);
}
if (Greenfoot.isKeyDown ("a"))
{
turn (-4);
}
}
}
public class bullet extends Shooter
{
private int direction, speed;
public bullet(int dir)
{
direction = dir;
}
int time=10;
public boolean atWorldEdge()
{
if(getX() < 10 || getX() > getWorld().getWidth() - 10)
return true;
if(getY() < 10 || getY() > getWorld().getHeight() - 10)
return true;
else
return false;
}
/**
* Act - do whatever the bullet wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setRotation(direction);
move(speed);
destroyEnemies ();
move(17);
kill();
if (this.atWorldEdge())
{
getWorld().removeObject(this);
}
}
public bullet()
{
GreenfootImage image=getImage();
image.scale(40,6);
setImage(image);
}
public void destroyEnemies()
{
//"Enemy" can be any class that you want the bullet to destroy.
Actor enemy = getOneIntersectingObject(Enemy.class);
if(enemy != null)
{
World myWorld = getWorld();
getWorld().removeObject(enemy);
}
}
public void kill()
{
//"Enemy" can be any class that you want the bullet to destroy.
Actor blueenemy = getOneIntersectingObject(Enemy.class);
if(blueenemy != null)
{
getWorld().removeObject(blueenemy);
}
}
}

