Hi,
this is my code:
it thows a NullPointerException for line 29
what im trying to do is to look if an object at is surrounded by other objects. if its not, print test.
I cant figure out what is worng.
thx ind advance
public static final int ABSTAND=30;
public static final int GROESSE=3;
public static final int HOEHE=GROESSE*2;
public Settings sett = new Settings();
int count =0;
int einzeln=0;
public Level1()
{
super(320, 480, 1);
addObject(sett, 240,450);
drawBoard();
sett.setImage(new GreenfootImage("Score: 0",18,Color.BLACK, Color.WHITE));
}
public void drawBoard(){
Random rand = new Random();
Field[][] board = new Field[HOEHE][];
for(int i =0; i<HOEHE;i++){
board[i] = new Field[GROESSE];
for(int k =0; k<GROESSE;k++){
if(rand.nextInt(11)>=5){
board[i][k]= new Free();
addObject(board[i][k], k*ABSTAND+30, i*ABSTAND+30);
count++;
}
if(i>=1 && k>=1 && k<GROESSE-1 && i<HOEHE-1){
if(board[i][k-1]==null && board[i][k+1]==null && board[i+1][k]==null && board[i-1][k]==null){
System.out.println("test");
}
}
}
}



