15 releases (5 breaking)

new 0.6.1 Jan 14, 2025
0.5.3 Jan 2, 2025
0.5.2 Dec 28, 2024
0.1.4 Nov 29, 2024

#242 in Game dev

Download history 189/week @ 2024-11-08 54/week @ 2024-11-15 122/week @ 2024-11-22 231/week @ 2024-11-29 400/week @ 2024-12-06 136/week @ 2024-12-13 234/week @ 2024-12-20 314/week @ 2024-12-27 161/week @ 2025-01-03 171/week @ 2025-01-10

881 downloads per month

MIT/Apache

61KB
1K SLoC

Hexlab

Hexlab is a Rust library for generating and manipulating hexagonal mazes.

Features

  • Create hexagonal mazes of configurable size
  • Customizable maze properties (radius, start position, seed)
  • Efficient bit-flag representation of walls for optimized memory usage
  • Multiple maze generation algorithms (WIP)
  • Maze builder pattern for easy and flexible maze creation

Installation

Add hexlab as a dependency:

cargo add hexlab

Getting Started

use hexlab::prelude::*;

fn main() {
    // Create a new maze with radius 5
    let maze = MazeBuilder::new()
        .with_radius(5)
        .build()
        .expect("Failed to create maze");
    println!("Maze size: {}", maze.len());
}

Usage

use hexlab::prelude::*;

// Create a new maze
let maze = MazeBuilder::new()
    .with_radius(5)
    .build()
    .expect("Failed to create maze");

// Get a specific tile
let tile = maze.get_tile(&Hex::new(1, -1)).unwrap();

// Check if a wall exists
let has_wall = tile.walls().contains(EdgeDirection::FLAT_NORTH);

Documentation

Full documentation is available at docs.rs.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgements

Hexlab relies on the excellent hexx library for handling hexagonal grid mathematics, coordinates, and related operations. We're grateful for the robust foundation it provides for working with hexagonal grids.

License

This project is dual-licensed under either:

at your option.

Dependencies

~10–22MB
~261K SLoC