I can only shoot one bullet at a time and I cannot shoot another bullet until the last bullet disappears from the world when it hits the edge.
public class Player extends Actor
{
/**
* Act - do whatever the Player wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(Greenfoot.isKeyDown("up"))
{
setRotation(-90);
setLocation(getX(), getY()-1);
}
else if(Greenfoot.isKeyDown("down"))
{
setRotation(90);
setLocation(getX(), getY()+1);
}
if (Greenfoot.isKeyDown("right"))
{
Actor x = (Actor)getWorld().getObjects(Player.class).get(0);
getWorld().addObject(new Delayer(), x.getX()+25, x.getY());
}
else
setRotation(0);
Actor lobs = getOneIntersectingObject(Lobstrosity.class);
if(lobs != null)
{
getWorld().removeObject(this);
gameOver();
}
}
public void gameOver()
{
Greenfoot.stop();
}
}public class Delayer extends Actor
{
/**
* Act - do whatever the Lobstrosity wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(1);
int rightedge = getWorld().getWidth();
if (this.getX()+10 == rightedge)
{
getWorld().removeObject(this);
}
}
}public class Lobstrosity extends Actor
{
/**
* Act - do whatever the Lobstrosity wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
setRotation(180);
setLocation(getX()-1, getY());
Actor lobMonster = getOneIntersectingObject(Delayer.class);
if(lobMonster != null)
{
this.move(-1);
}
int edge = getWorld().getWidth()-750;
if (this.getX() == edge)
{
getWorld().addObject(new Lobstrosity(), 490 + Greenfoot.getRandomNumber(740), Greenfoot.getRandomNumber(getWorld().getHeight()));
getWorld().addObject(new Lobstrosity(), 490 + Greenfoot.getRandomNumber(740), Greenfoot.getRandomNumber(getWorld().getHeight()));
getWorld().removeObject(this);
}
}
}if (Greenfoot.isKeyDown("right") && getWorld().getObjects(Delayer.class).isEmpty())