Hey all
I want to fire more than one bullet at a time. can anyone help me?
Many Thanks
public void fireOnCommand()
{
if(Greenfoot.isKeyDown("f")) {
World myWorld = getWorld();
myWorld.addObject(laser, 0, 0);
laser.setLocation(getX(),getY());
laser.setRotation(getRotation());
}
}// create multiple bullets Bullet bullet = new Bullet(); Bullet bullet2 = new Bullet(); // add bullets into world at location of spawner getWorld().addObject(bullet, getX(), getY()); getWorld().addObject(bullet2, getX(), getY()); // turn bullets toward left and right of spawner bullet.setRotation(this.getRotation()-90); bullet2.setRotation(this.getRotation()+90); // move bullets apart bullet.move(10); bullet2.move(10): // turn bullets toward front of spawner bullet.turn(90); bullet2.turn(-90); // move bullets to front of spawner bullet.move(20); bullet2.move(20);