0.10.0 • Published 2 years ago

@znuznu/groolkit v0.10.0

Weekly downloads
4
License
MIT
Repository
github
Last release
2 years ago

groolkit

npm version CI Status License

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.

Installation

npm i @znuznu/groolkit

Algorithms

Most of the provided algorithms could be used in a grid-based game (rogue-like for example).

They are grouped by family:

  • FOV
    • Recursive shadow casting
  • Line:
    • Line interpolation
  • Flood:
    • Flood fill
  • Pathfinder:
    • A* (4 or 8 directions)
    • Dijkstra (4 or 8 directions)

Usage

Just import the lib:

import * as Groolkit from '@znuznu/groolkit';

or

const Groolkit = require('@znuznu/groolkit');

What type of grid can I use ?

Any type of two-dimensional arrays. Groolkit doesn't mutate your grids.

What needs Groolkit ?

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, ...)

Documentation

See the full documentation, with examples here.

0.10.0

2 years ago

0.9.0

3 years ago

0.9.1

3 years ago

0.8.0

3 years ago

0.7.0

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.3.0

4 years ago

0.4.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago