Hey all
I want to fire more than one bullet at a time. can anyone help me?
Many Thanks


1 2 3 4 5 6 7 8 9 | public void fireOnCommand() { if (Greenfoot.isKeyDown( "f" )) { World myWorld = getWorld(); myWorld.addObject(laser, 0 , 0 ); laser.setLocation(getX(),getY()); laser.setRotation(getRotation()); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // 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 ); |