1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public void shoot() { MouseInfo mouse = Greenfoot.getMouseInfo(); if (mouse != null ) { if (shootdelay >= 20 ) { Bullet b = new Bullet(); getWorld().addObject(b, getX(), getY()); //Adds bullet at the Players X and Y. b.turnTowards(mouse.getX(), mouse.getY()); //Turns the bullet towards the mouse. shootdelay = 0 ; //Resets the shootdelay back to 0. } } } |

