I am trying to add several objects to my world at random but want to make sure none of them overlap.
With the last if statement, I would expect it to make sure that the location is empty however I sometimes experience them overlapping..
//in double for loop addObject(new square(),offsetX,offsetY); isEmpty[x][y]=true;
//getting the random starting points startX=rand.nextInt(size); startY=rand.nextInt(size);
Actor carrier1= new carrier1(); carrier1.turn(rotation); addObject(carrier1, startXcoordinatescarrier, startYcoordinatescarrier); isEmpty[startXcarrier][startYcarrier]=false;
if (isEmpty[startXbattleship][startbattleship]==true)
{
Actor battleship1= new battleship1();
battleship1.turn(rotation);
addObject(battleship1, startXcoordinatesbattleship, startYcoordinatesbattleship);
isEmpty[startXbattleship][startYbattleship]=false;
}

