First: Mech
the mouse class has a Greenfoot default image, to hide it, add these:
and also the scenario is in pixel art, add some darkness is good, but it just lost it's own style, try to write the darkness class like below:
public Mouse()
{
setImage(new GreenfootImage(1,1));
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
public class Darkness extends All {
GreenfootImage GI_Darkness;
MechBody mb;
int width, height;
int gridSize = 14;
public Darkness(int width, int height) {
this.width = width;
this.height = height;
GI_Darkness = new GreenfootImage(width,height);
setImage(GI_Darkness);
GI_Darkness.fill();
}
public void act() {
UpdateImage();
}
private void UpdateImage() {
GI_Darkness.clear();
mb = (MechBody)getObjectsInRange(9999, MechBody.class).get(0);
double mb_X = (double)mb.getX() / (double)gridSize;
double mb_Y = (double)mb.getY() / (double)gridSize;
for(int i = 0; i < width / gridSize + 1; i++)
for(int j = 0; j < height / gridSize + 1; j++){
double dx = (i + 0.5) - mb_X;
double dy = (j + 0.5) - mb_Y;
double distance = Math.sqrt(dx * dx + dy * dy);
int transparency = Math.round(255 * (float)distance / 9);
transparency = Math.min(255, transparency);
transparency = Math.max(0, transparency);
GI_Darkness.setColor(new Color(0, 0, 0, transparency));
GI_Darkness.fillRect(i * gridSize, j * gridSize, gridSize, gridSize);
}
}

