| Crates.io | krunker-maze-generator |
| lib.rs | krunker-maze-generator |
| version | 0.2.1 |
| created_at | 2025-04-17 22:12:23.011813+00 |
| updated_at | 2025-04-22 14:33:14.883942+00 |
| description | Generates mazes for Krunker maps |
| homepage | https://github.com/Sorte1/krunker-maze-generator |
| repository | https://github.com/Sorte1/krunker-maze-generator |
| max_upload_size | |
| id | 1638564 |
| size | 266,618 |
A simple command-line tool written in Rust to generate, solve, and export mazes. It can produce a PNG image of the maze (with solution path overlay) and an optional JSON file describing the maze walls for use in other applications.
map.json in the format for krunker.io (tested version 7.5.0).Ensure you have Rust and Cargo installed.
Clone this repository:
git clone https://github.com/Sorte1/krunker-maze-generator.git
cd krunker-maze-generator
Build the project in release mode:
cargo build --release
The executable will be in target/release/krunker-maze-generator.
USAGE:
krunker-maze-generator [OPTIONS]
OPTIONS:
-W, --width <width> Maze width in cells [default: 100]
-H, --height <height> Maze height in cells [default: 100]
-S, --cell-size <cell_size> Pixel size of each cell [default: 40]
-T, --wall-thickness <thick> Wall thickness in pixels [default: 4]
-I, --image <image> Output image file path [default: "maze.png"]
-M, --map <map> Output JSON map file path [default: "map.json"]
--no-map Skip JSON map generation
-V, --version Print version information
-h, --help Print help information
Generate a default 100×100 maze and export both PNG and JSON:
krunker-maze-generator
Generate a 50×30 maze, small cells, thick walls:
krunker-maze-generator -W 50 -H 30 -S 20 -T 8 -I output.png -M walls.json
Generate only the PNG (skip JSON):
krunker-maze-generator --no-map -i maze.png
Add the dependency in your Cargo.toml:
[dependencies]
krunker-maze-generator = "0.2.1"
In your code, import and use the Maze API:
use krunker_maze_generator::Maze;
use std::path::Path;
fn main() {
// Create and generate a 50×50 maze
let mut maze = Maze::new(50, 50);
maze.generate();
// Draw to an image
let img = maze.draw(20, 4);
img.save(Path::new("custom_maze.png")).unwrap();
// Optionally, generate the JSON map:
let map_json = maze.to_map_json(20, 4);
std::fs::write("custom_map.json", serde_json::to_string_pretty(&map_json).unwrap()).unwrap();
}
{
"name": "GeneratedMaze",
"ambient": "#97a0a8",
"light": "#f2f8fc",
"sky": "#dce8ed",
"fog": "#8d9aa0",
"fogD": 2000,
"xyz": [<room_width>, 1, <room_height>, <w1>, 20, <l1>, ...],
"objects": [
{ "p": [x, y, z], "si": 0 },
{ "p": [x1, 0, z1], "si": 1 },
...
],
"spawns": [
[startX, 0, startZ, 0, 0, 0],
[endX, 0, endZ, 0, 0, 0]
]
}
git checkout -b feature/YourFeature).git commit -m "Add feature").git push origin feature/YourFeature).Please ensure your code is formatted with cargo fmt and linted with cargo clippy.
This project is licensed under the MIT License.