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.

46 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). So much of what is here I derived from amit's work.
  4. ## CONVENTIONS & TERMINOLOGY
  5. If you have read amit's guide to hexagon grids, a lot of the terminology will be familiar to you - I utilize many conventions he does in his guide. That being said, I use some he doesn't, and 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. The following table shows what each table/vector/array refers to in the code:
  6. | NAME | REFERS TO |
  7. | ---- | ------------------------------------------------------------ |
  8. | hex | xyz, *vector* used for most tasks, with constraint x+y+z=0 |
  9. | pix | xy, *vector* true screen pixel coordinates |
  10. | off | xy, 'offset', *vector* used for UI implementations |
  11. | map | *table* of unit hexagon centerpoints arranged in a shape |
  12. * note that 'hex' here is a catch-all term for cube/axial coordinates, as they can often be used interchangeably.
  13. ## MAPS & MAP STORAGE
  14. The storage system used is based on the map shape - see chart:
  15. | SHAPE | STORAGE TYPE | KEY | VALUE |
  16. | ------------- | ---------------------- | ------------ | ------------- |
  17. | ring | ordered, array-like | index | vec2(i, j) |
  18. | spiral | ordered, array-like | index | vec2(i, j) |
  19. | parallelogram | unordered, hash-like | vec2(i, j) | simplex noise |
  20. | rectangular | unordered, hash-like | vec2(i, j) | simplex noise |
  21. | hexagonal | unordered, hash-like | vec2(i, j) | simplex noise |
  22. | triangular | unordered, hash-like | vec2(i, j) | simplex noise |
  23. * note that a spiral map is just a hexagonal one with a particular order.
  24. 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.
  25. ## RESOURCES
  26. * [Hex Map 1](https://catlikecoding.com/unity/tutorials/hex-map/) - unity tutorial for hexagon grids with some useful generalized math.
  27. * [Hexagonal Grids](https://redblobgames.com/grids/hexagons) - THE resource on hexagonal grids on the internet.
  28. * [Amulet Docs](http://amulet.xyz/doc) - amulet documentation.