public void act() { time = time + 1; if (time <= 150 ){ move(0); } else { setLocation (Greenfoot.getRandomNumber(),getY()+dy); if (getY() >= getWorld().getHeight() - 1){ dy = -5 ; Greenfoot.playSound("button-14.wav"); } if (getX() >= getWorld().getWidth() - 1){ Greenfoot.setWorld ( new space()); } if (getY() <= 20){ dy = 5; Greenfoot.playSound("button-14.wav"); } if (getX() <= 20){ Greenfoot.setWorld ( new space()); } if (isTouching(P1.class)){ dx = -dx; dy = dy-1; Greenfoot.playSound("button-3.wav"); } if (isTouching(P2.class)){ dx = -dx; dy = dy-1; Greenfoot.playSound("button-9.wav"); } } } }