πΊοΈ basic-pathfinding
Pathfinding is a simple package for performing 2D A-star pathfinding in square- and hex-based tile grids.
Java/TypeScript Usage
const { findPath } = await import('pathfinding');
const grid: Grid = {
tiles: [
[1, 1, 0, 1, 1],
[1, 1, 0, 1, 1],
[1, 1, 0, 1, 1],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1]
],
walkableTiles: [1]
};
const path = findPath(grid, { x: 1, y: 2 }, { x: 3, y: 2 });
// [
// { x: 1, y: 2 },
// { x: 1, y: 3 },
// { x: 2, y: 3 },
// { x: 3, y: 3 },
// { x: 3, y: 2 }
// ]
π΄ Rust Usage
π οΈ Building
wasm-pack build
π¬ Testing
cargo test
wasm-pack test --headless --firefox