starmap.js
// block in which cells the planets will go into
block in which cells the planets will go into
block in which cells the planets will go into
function findEmptyCells() {
	var empty_cells = getEmptyCells();
	while (planet_cells.length < PLANET_AMOUNT_MAX && empty_cells != null && empty_cells.length > 0)
	{
		for (var i = 0; i < planet_cells.length; i++)
		{
			cell = planet_cells[i];
			if (cell.x > 0 && cell.y > 0)
				cells[cell.x - 1][cell.y - 1].color = CELL_LOCKED;
			if (cell.x < columns - 1 && cell.y > 0)
				cells[cell.x + 1][cell.y - 1].color = CELL_LOCKED;
			if (cell.x < columns - 1 && cell.y < rows - 1)
				cells[cell.x + 1][cell.y + 1].color = CELL_LOCKED;
			if (cell.x > 0 && cell.y < rows - 1)
				cells[cell.x - 1][cell.y + 1].color = CELL_LOCKED;
			if (cell.y > 0)
				cells[cell.x][cell.y - 1].color = CELL_LOCKED;
			if (cell.x < columns - 1)
				cells[cell.x + 1][cell.y].color = CELL_LOCKED;
			if (cell.y < rows - 1)
				cells[cell.x][cell.y + 1].color = CELL_LOCKED;
			if (cell.x > 0)
				cells[cell.x - 1][cell.y].color = CELL_LOCKED;
			if (options.largeCells)
			{
				if (cell.y > 1)
					cells[cell.x][cell.y - 2].color = CELL_LOCKED;
				if (cell.x < columns - 2)
					cells[cell.x + 2][cell.y].color = CELL_LOCKED;
				if (cell.y < rows - 2)
					cells[cell.x][cell.y + 2].color = CELL_LOCKED;
				if (cell.x > 1)
					cells[cell.x - 2][cell.y].color = CELL_LOCKED;
			}
		}
		empty_cells = getEmptyCells();
		if (empty_cells.length > 0)
		{
			var index = Math.floor(Math.random() * empty_cells.length);
			cells[empty_cells[index].x][empty_cells[index].y].color = CELL_OCCUPIED;
			planet_cells.push(empty_cells[index]);
			empty_cells.splice(index, 1);
		}
	}
}
function findEmptyCells ( ) { var empty_cells = getEmptyCells ( ) ; while ( planet_cells . length < PLANET_AMOUNT_MAX && empty_cells != null && empty_cells . length > 0 ) { for ( var i = 0 ; i < planet_cells . length ; i ++ ) { cell = planet_cells [ i ] ; if ( cell . x > 0 && cell . y > 0 ) cells [ cell . x - 1 ] [ cell . y - 1 ] . color = CELL_LOCKED ; if ( cell . x < columns - 1 && cell . y > 0 ) cells [ cell . x + 1 ] [ cell . y - 1 ] . color = CELL_LOCKED ; if ( cell . x < columns - 1 && cell . y < rows - 1 ) cells [ cell . x + 1 ] [ cell . y + 1 ] . color = CELL_LOCKED ; if ( cell . x > 0 && cell . y < rows - 1 ) cells [ cell . x - 1 ] [ cell . y + 1 ] . color = CELL_LOCKED ; if ( cell . y > 0 ) cells [ cell . x ] [ cell . y - 1 ] . color = CELL_LOCKED ; if ( cell . x < columns - 1 ) cells [ cell . x + 1 ] [ cell . y ] . color = CELL_LOCKED ; if ( cell . y < rows - 1 ) cells [ cell . x ] [ cell . y + 1 ] . color = CELL_LOCKED ; if ( cell . x > 0 ) cells [ cell . x - 1 ] [ cell . y ] . color = CELL_LOCKED ; if ( options . largeCells ) { if ( cell . y > 1 ) cells [ cell . x ] [ cell . y - 2 ] . color = CELL_LOCKED ; if ( cell . x < columns - 2 ) cells [ cell . x + 2 ] [ cell . y ] . color = CELL_LOCKED ; if ( cell . y < rows - 2 ) cells [ cell . x ] [ cell . y + 2 ] . color = CELL_LOCKED ; if ( cell . x > 1 ) cells [ cell . x - 2 ] [ cell . y ] . color = CELL_LOCKED ; } } empty_cells = getEmptyCells ( ) ; if ( empty_cells . length > 0 ) { var index = Math . floor ( Math . random ( ) * empty_cells . length ) ; cells [ empty_cells [ index ] . x ] [ empty_cells [ index ] . y ] . color = CELL_OCCUPIED ; planet_cells . push ( empty_cells [ index ] ) ; empty_cells . splice ( index , 1 ) ; } } }
block in which cells the planets will go into
block in which cells the planets will go into
// block the cells we can't use // top left // top right // bottom right // bottom left // top // right // bottom // left // top // right // bottom // left