hexyz is tower defense game, and a lua library for dealing with hexagonal grids
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.5 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. ## INTRODUCTION
  2. This is a small and simple library for using hexagonal grids in amulet + lua. I wrote it for a tower defense game I'm making.
  3. It's not really well documented. If you want an actual good resource, go to [amit's guide to hexagonal grids](https://redblobgames.com/grids/hexagons).
  4. So much of what is here I derived from amit's work.
  5. ## CONVENTIONS & TERMINOLOGY
  6. If you have read amit's guide to hexagon grid, a lot of the terminology will be familiar to you - I utilize many conventions he does in his guide. That being said,
  7. because so many similar kinds of data structures with different goals are used in this library it can be hard to remember precisely what they all refer to.
  8. The following table shows what each table/vector/array refers to in the code:
  9. | NAME | REFERS TO |
  10. | ---- | ------------------------------------------------------------ |
  11. | hex | xyz, *vector* used for most tasks, with constraint x+y+z=0 |
  12. | pix | xy, *vector* true screen pixel coordinates |
  13. | off | xy, 'offset', *vector* used for UI implementations |
  14. | map | xy, *table* of unit hexagon centerpoints arranged in a shape |
  15. * note that 'hex' here is a catch-all term for cube/axial, as they can often be used interchangeably.
  16. ## MAPS & MAP STORAGE
  17. The storage system used is based on the map shape - see chart:
  18. | SHAPE | STORAGE TYPE | KEY | VALUE |
  19. | ------------- | ---------------------- | ------------ | ------------- |
  20. | ring | ordered, array-like | index | vec2(i, j) |
  21. | spiral | ordered, array-like | index | vec2(i, j) |
  22. | parallelogram | unordered, hash-like | vec2(i, j) | simplex noise |
  23. | rectangular | unordered, hash-like | vec2(i, j) | simplex noise |
  24. | hexagonal | unordered, hash-like | vec2(i, j) | simplex noise |
  25. | triangular | unordered, hash-like | vec2(i, j) | simplex noise |
  26. * note that a spiral map is just a hexagonal one with a particular order.
  27. The noise values on the hashmaps are seeded. You can optionally provide a seed after the map's dimensions as an argument, otherwise it's a random seed.
  28. ## RESOURCES
  29. * [Hex Map 1](https://catlikecoding.com/unity/tutorials/hex-map/) - unity tutorial for hexagon grids with some useful generalized math.
  30. * [Hexagonal Grids](https://redblobgames.com/grids/hexagons) - THE resource on hexagonal grids on the internet.
  31. * [Amulet Docs](http://amulet.xyz/doc) - amulet documentation.