danpost wrote...
Move line 38 to before line 42 (before the 'return' statement).Super_Hippo wrote...
danpost wrote...
Move line 38 to before line 42 (before the 'return' statement).import greenfoot.*;
public class Iceball extends Actor
{
private int direction, speed;
public Iceball(int dir)
{
direction = 270;
speed = 7;
}
public void act()
{
setRotation(direction);
move(speed);
disappear();
}
public void disappear()
{
Actor BugEnemy;
BugEnemy = getOneObjectAtOffset(0, 0, BugEnemy.class);
Actor InsectEnemy;
InsectEnemy = getOneObjectAtOffset(0, 0, InsectEnemy.class);
Actor Bee;
Bee = getOneObjectAtOffset(0, 0, Bee.class);
Actor DarkPower;
DarkPower = getOneObjectAtOffset(0, 0, DarkPower.class);
if (BugEnemy != null)
{
World world;
world = getWorld();
MyGame2 mygame2= (MyGame2)world;
Counter2 counter2 = mygame2.getCounter2();
counter2.addScore();
int x = Greenfoot.getRandomNumber(halfWorldWidth);
if (getX() >= halfWorldWidth) x += halfWorldWidth;
BugEnemy.setLocation(x, Greenfoot.getRandomNumber(world.getHeight())) ;
world.removeObject(this);
int halfWorldWidth = world.getWidth()/2;
return;
}
if (InsectEnemy != null)
{
World world;
world = getWorld();
world.removeObject(InsectEnemy);
MyGame2 mygame2 = (MyGame2)world;
Counter2 counter2 = mygame2.getCounter2();
counter2.addScore();
int x = Greenfoot.getRandomNumber(halfWorldWidth);
if (getX() >= halfWorldWidth) x += halfWorldWidth;
InsectEnemy.setLocation(x, Greenfoot.getRandomNumber(world.getHeight()));
world.removeObject(this);
int halfWorldWidth = world.getWidth()/2;
return;
}
if (Bee != null)
{
World world;
world = getWorld();
world.removeObject(Bee);
MyGame2 mygame2 = (MyGame2)world;
Counter2 counter2 = mygame2.getCounter2();
counter2.addScore();
int x = Greenfoot.getRandomNumber(halfWorldWidth);
if (getX() >= halfWorldWidth) x += halfWorldWidth;
Bee.setLocation(x, Greenfoot.getRandomNumber(world.getHeight()));
world.removeObject(this);
int halfWorldWidth = world.getWidth()/2;
return;
}
if (DarkPower != null)
{
World world;
world = getWorld();
world.removeObject(DarkPower);
world.removeObject(this);
return;
} else {
if (getY()<=0)
{
getWorld().removeObject(this);
return;
}
}
}
}
