diff --git a/biome-ui.js b/biome-ui.js index 9f4d702..4290635 100644 --- a/biome-ui.js +++ b/biome-ui.js @@ -8,10 +8,12 @@ const DRAW_MIN = LIMIT_MIN - 10 const DRAW_MAX = LIMIT_MAX + 10 const GRID_STEP = 10 +let lastBiomeID = 0; let biomePoints = [ - {name: generateBiomeName(50, 50), heat:50, humidity:50, min_y: MIN_Y_DEFAULT, max_y: MAX_Y_DEFAULT}, + {id: 0, name: generateBiomeName(50, 50), heat:50, humidity:50, min_y: MIN_Y_DEFAULT, max_y: MAX_Y_DEFAULT}, ]; +lastBiomeID++; // FOREST-16 palette, plus black const pointColor = "#913636"; @@ -36,17 +38,21 @@ const cellColors = [ "#ecddba", ]; -// define an array and randomize it -function shuffleArray(values) { - let index = values.length, randomIndex; - // While there remain elements to shuffle - while (index != 0) { - // Pick a remaining element. - randomIndex = Math.floor(Math.random() * index); - index--; // And swap it with the current element. - [values[index], values[randomIndex]] = [values[randomIndex], values[index]]; +// returns the biome point by its given ID +// or null if it couldn't be found +function getBiomeByID(id) { + for(let b=0; b