basic-pathfinding
v0.1.2
Published
Tile-based A* pathfinding in Rust/WebAssembly
Downloads
6
Readme
🗺️ 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