A JavaScript library with a bunch of algorithms related to grids.
Note: this is a WIP library and breaking changes might occur in the future.
npm i @znuznu/groolkit
Most of the provided algorithms could be used in a grid-based game (rogue-like for example).
They are grouped by family:
Just import the lib:
import * as Groolkit from '@znuznu/groolkit';
or
const Groolkit = require('@znuznu/groolkit');
Any type of two-dimensional arrays. Groolkit
doesn't mutate your grids.
The only thing required alongside the grid is a callback function to checks the cell property of the grid.
For example, Groolkit
needs to know what makes a cell of your array a blocking one in order to avoid it during a shortest path computation.
blockCallbackFn
: return true
if the cell is a blocking one (line of sight, shortest path, ...)lightCallbackFn
: return true
if the cell doesn't let the light passes through (FOV, ...)floodCallbackFn
: return true
if the cell is a one to flood (flood, ...)
See the full documentation with examples here.
You can try Groolkit on the playground.
Generated using TypeDoc