Added seed
This commit is contained in:
parent
4b8bb89110
commit
bd7b12e57d
|
@ -42,6 +42,7 @@
|
||||||
<a class="dropdown-item" id="random-option">Random Generator</a>
|
<a class="dropdown-item" id="random-option">Random Generator</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
<input class="form-control mr-sm-2" id="seed" type="search" placeholder="Seed" aria-label="Seed">
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -19,34 +19,41 @@ canvas.width = (CELL_SIZE + 1) * width + 1;
|
||||||
|
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
|
function get_seed() {
|
||||||
|
var seed_text = document.getElementById("seed").value;
|
||||||
|
if( seed_text.length > 0) {
|
||||||
|
return Number(seed_text);
|
||||||
|
}
|
||||||
|
return Date.now();
|
||||||
|
}
|
||||||
|
|
||||||
// Map generators
|
// Map generators
|
||||||
function newCellularAutomata() {
|
function newCellularAutomata() {
|
||||||
var seed = Date.now();
|
world = World.new_cellular_automata(width, height, get_seed());
|
||||||
world = World.new_cellular_automata(width, height, seed);
|
|
||||||
requestAnimationFrame(renderLoop);
|
requestAnimationFrame(renderLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newSimpleRooms() {
|
function newSimpleRooms() {
|
||||||
var seed = Date.now();
|
var seed = Date.now();
|
||||||
world = World.new_simple_rooms(width, height, seed);
|
world = World.new_simple_rooms(width, height, get_seed());
|
||||||
requestAnimationFrame(renderLoop);
|
requestAnimationFrame(renderLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newBspInterior() {
|
function newBspInterior() {
|
||||||
var seed = Date.now();
|
var seed = Date.now();
|
||||||
world = World.new_bsp_interior(width, height, seed);
|
world = World.new_bsp_interior(width, height, get_seed());
|
||||||
requestAnimationFrame(renderLoop);
|
requestAnimationFrame(renderLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newDrunkard() {
|
function newDrunkard() {
|
||||||
var seed = Date.now();
|
var seed = Date.now();
|
||||||
world = World.new_drunkard(width, height, seed);
|
world = World.new_drunkard(width, height, get_seed());
|
||||||
requestAnimationFrame(renderLoop);
|
requestAnimationFrame(renderLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newRandomGen() {
|
function newRandomGen() {
|
||||||
var seed = Date.now();
|
var seed = Date.now();
|
||||||
world = World.new_random(width, height, seed);
|
world = World.new_random(width, height, get_seed());
|
||||||
requestAnimationFrame(renderLoop);
|
requestAnimationFrame(renderLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user