1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | { /** * Act - do whatever the Gammal wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move( 10 ); //check upper right corner if (getX() >= getWorld() .getWidth()- 50 && getY() <= 50 ) { turn( 135 ); } //check lower right corner if (getX() >= getWorld() .getWidth()- 50 && getY() >= getWorld() .getHeight()- 50 ) { turn (- 135 ); } //check lower left corner if (getX() <= 50 && getY() >= getWorld() .getHeight()- 50 ) { turn (- 135 ); } //check upper left corner if (getX() <= 50 && getY() <= 50 ) { turn ( 135 ); } } } |

