/** * Loops through room, checking each tile to see if it has enough ground and empty * If so, placeEnemy() is called. **/ public void genEnemies() { for (int x = 1; x < room.getCellsRows() - 1; x++) //we start at 1 higher and end at 1 lower to not go out of bounds when doing below adjacency checks { for (int y = 0; y < room.getCellsCols() - 1; y++) //similar here (0 higher and 1 lower) { if (room.hasGround(x, y) && room.hasGround(x + 1, y) && room.hasGround(x - 1, y)) //check for 3 tiles of ground { if (room.hasCellOfType(x, y + 1, CellType.Empty) && room.hasCellOfType(x + 1, y + 1, CellType.Empty) && room.hasCellOfType(x - 1, y + 1, CellType.Empty)) //check 3 tiles of empty { placeEnemy(x, y); } } } } }