updated demo

This commit is contained in:
klangner 2020-11-19 21:00:36 +01:00
parent 2e4fba61e4
commit 128c8104b2
8 changed files with 25 additions and 5 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "mapgen"
version = "0.4.1"
version = "0.4.2"
authors = ["Krzysztof Langner <klangner@gmail.com>"]
description = "Map generator for games (dungeons, worlds etc.)"
keywords = ["game", "map", "map-generator"]

View File

@ -110,6 +110,17 @@ impl World {
World::new(width, height, map)
}
pub fn new_voronoi(width: u32, height: u32, seed: u32) -> World {
World::print_map_info(format!("Voronoi Hive with the seed: {}", seed));
let mut rng = StdRng::seed_from_u64(seed as u64);
let map = MapBuilder::new(width as usize, height as usize)
.with(VoronoiHive::new())
.with(AreaStartingPosition::new(XStart::LEFT, YStart::TOP))
.with(DistantExit::new())
.build_with_rng(&mut rng);
World::new(width, height, map)
}
pub fn new_random(width: u32, height: u32, seed: u32) -> World {
let mut rng = rand::thread_rng();
let px = rng.gen::<f32>();

View File

@ -42,6 +42,7 @@
<a class="dropdown-item" id="bsp-interior-option">BSP Interior</a>
<a class="dropdown-item" id="drunkard-option">Drunkard Walk</a>
<a class="dropdown-item" id="maze-option">Maze</a>
<a class="dropdown-item" id="voronoi-option">Voronoi Hive</a>
<a class="dropdown-item" id="random-option">Random Generator</a>
</div>
</li>

View File

@ -66,6 +66,12 @@ function newMaze() {
requestAnimationFrame(renderLoop);
}
function newVoronoi() {
var seed = Date.now();
world = World.new_voronoi(GRID_COLS, GRID_ROWS, get_seed());
requestAnimationFrame(renderLoop);
}
function newRandomGen() {
var seed = Date.now();
world = World.new_random(GRID_COLS, GRID_ROWS, get_seed());
@ -163,4 +169,5 @@ document.getElementById('bsp-rooms-option').addEventListener('click', newBspRoom
document.getElementById('drunkard-option').addEventListener('click', newDrunkard);
document.getElementById('bsp-interior-option').addEventListener('click', newBspInterior);
document.getElementById('maze-option').addEventListener('click', newMaze);
document.getElementById('voronoi-option').addEventListener('click', newVoronoi);
document.getElementById('random-option').addEventListener('click', newRandomGen);

File diff suppressed because one or more lines are too long

2
docs/bootstrap.js vendored
View File

@ -222,7 +222,7 @@
/******/ promises.push(installedWasmModuleData);
/******/ else {
/******/ var importObject = wasmImportObjects[wasmModuleId]();
/******/ var req = fetch(__webpack_require__.p + "" + {"../pkg/mapgen_demo_bg.wasm":"fa6c9d72e1d9a518ed31"}[wasmModuleId] + ".module.wasm");
/******/ var req = fetch(__webpack_require__.p + "" + {"../pkg/mapgen_demo_bg.wasm":"f22182091a16774e383e"}[wasmModuleId] + ".module.wasm");
/******/ var promise;
/******/ if(importObject instanceof Promise && typeof WebAssembly.compileStreaming === 'function') {
/******/ promise = Promise.all([WebAssembly.compileStreaming(req), importObject]).then(function(items) {

Binary file not shown.

View File

@ -42,6 +42,7 @@
<a class="dropdown-item" id="bsp-interior-option">BSP Interior</a>
<a class="dropdown-item" id="drunkard-option">Drunkard Walk</a>
<a class="dropdown-item" id="maze-option">Maze</a>
<a class="dropdown-item" id="voronoi-option">Voronoi Hive</a>
<a class="dropdown-item" id="random-option">Random Generator</a>
</div>
</li>