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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Stone here. * * @author (your name) * @version (a version number or a date) */ public class Stone extends Enemy { private int relocation; public Stone() { turn( 90 ); } public void act() { move( 3 ); removing(); colision(); } public void colision() { if (isTouching(Blast. class )) { removeTouching(Blast. class ); getWorld().removeObject( this ); } } public void removing() { if (isAtEdge() & relocation <= 1 ) { setLocation( 50 + Greenfoot.getRandomNumber( 550 ), 1 ); relocation ++; } if (relocation == 3 ) { getWorld().removeObject( this ); } } } |

