4.1.5 • Published 5 months ago

honeycomb-grid v4.1.5

Weekly downloads
506
License
MIT
Repository
github
Last release
5 months ago

⬡ Honeycomb NPM version Minified size Gitter

A hexagon grid library made in JavaScriptTypeScript, heavily inspired by Red Blob Games' blog posts and code samples.

Honeycomb works in modern browsers and Node (>=16). It's recommended to use Honeycomb with TypeScript, but not required.

ko-fi

Installation

NPM:

npm i honeycomb-grid

Yarn:

yarn add honeycomb-grid

Or download the distribution from jsdelivr or unpkg.com.

Basic example

Create a rectangular grid of 10 by 10 hexes and log each hex:

import { defineHex, Grid, rectangle } from 'honeycomb-grid'

// 1. Create a hex class:
const Tile = defineHex({ dimensions: 30 })

// 2. Create a grid by passing the class and a "traverser" for a rectangular-shaped grid:
const grid = new Grid(Tile, rectangle({ width: 10, height: 10 }))

// 3. Iterate over the grid to log each hex:
grid.forEach(console.log)

Documentation

Documentation is available at abbekeultjes.nl/honeycomb. API docs can be found at abbekeultjes.nl/honeycomb/api/.

Backlog

These are ideas that may require further investigation 🕵️. Don't hesitate to open an issue or start a discussion.

  • Directions should also be given in degrees (in steps of 30°)?
  • Add functionality related to edges and/or corners. Use https://www.redblobgames.com/grids/parts/#hexagons.
  • Add path finding (e.g. A*) functionality. Currently available as an example, see /examples/a-star-path-finding/.
  • Clarify the "Line of sight" example (and rename to "Field of view"). Maybe add animations and some enemies as well?
  • Add examples for (procedural) map generation (from a seed).
4.1.5

5 months ago

4.1.4

10 months ago

4.1.3

10 months ago

4.1.2

10 months ago

4.1.1

12 months ago

4.1.0

12 months ago

4.0.1

2 years ago

4.0.0

2 years ago

4.0.0-beta.8

2 years ago

4.0.0-beta.7

2 years ago

4.0.0-beta.6

2 years ago

4.0.0-beta.5

2 years ago

4.0.0-beta.4

2 years ago

4.0.0-beta.3

2 years ago

4.0.0-beta.2

2 years ago

4.0.0-beta.1

2 years ago

4.0.0-alpha.5

3 years ago

4.0.0-alpha.4

3 years ago

4.0.0-alpha.3

3 years ago

4.0.0-alpha.2

3 years ago

4.0.0-alpha.1

3 years ago

3.1.8

3 years ago

4.0.0-alpha.0

3 years ago

3.1.7

4 years ago

3.1.6

4 years ago

3.1.5

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.1.0

5 years ago

2.0.3

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.4.4

5 years ago

1.4.4-0

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

6 years ago

1.3.6

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.7.0

6 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago