public class Ship extends Animal { int speed = 300; int x, y; GreenfootImage rImg, lImg; public void act() { shoot(); addedToWorld(); speed(); setImage(); } public void setImage() { rImg = getImage(); lImg = new GreenfootImage(rImg); lImg.mirrorHorizontally(); setImage(speed > 0 ? rImg : lImg); } public void setXLoc(int x, int y) { setLocation(x/100, y/100); } public void speed() { if (x+speed > 3000 && x+speed< (getWorld().getWidth()-30)*100) x += speed; else speed = -speed; setXLoc(x, y); } public void addedToWorld() { x = getX()*100; y = getY()*100; } public void shoot() { { if (getWorld().getObjects(Rocket.class).size() == 0) { Rocket rackete = new Rocket(); CrabWorld welt = (CrabWorld)getWorld(); welt.addObject(rackete, getX(), getY()); rackete.setRotation(getRotation()); } } } }