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.

87 lines
3.6 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
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 [1.1]
  2. this is a library for using hexagonal grids in amulet/lua.
  3. it is extremely incomplete. the following list of features is
  4. either implemented shoddily, or not at all.
  5. if you want an actual good resource, go to [1.9].
  6. ## GETTING STARTED [1.2]
  7. * TODO
  8. ## COORDINATE SYSTEMS [1.3]
  9. as much coordinate manipulation as possible is done internally.
  10. depending on the task, uses either Axial, Cube, or Doubled coordinates.
  11. three different ways of returning and sending coordinates:
  12. * amulet vectors
  13. * lua tables
  14. * individual coordinate numbers
  15. so you can use what your graphics library likes best!
  16. ## MAPS & MAP STORAGE [1.4]
  17. Some map shapes: parallelogram, rectangular, hexagonal, triangular. (and more)
  18. The storage system used is based on the map shape - see chart:
  19. | SHAPE | MAP STORAGE |
  20. | ----------------- | --------------------------------------------- |
  21. | parallelogram | unordered, hash-like OR ordered, array-like |
  22. | rectangular | unordered, hash-like OR ordered, array-like |
  23. | hexagonal | unordered, hash-like OR ordered, array-like |
  24. | triangular | unordered, hash-like OR ordered, array-like |
  25. | ring | ordered, array-like |
  26. | spiral | ordered, array-like** |
  27. | arbitrary | unordered, hash-like |
  28. ** note that a spiral map is just a hexagonal one with a particular order.
  29. ## CONVENTIONS AND TERMINOLOGY [1.8]
  30. If you have read amit's guide to hexagon grids, (see [1.9]), a lot of the
  31. terminology will be familiar to you - I utilize many conventions he does in
  32. his guide. That being said...
  33. Because so many different kinds of coordinate groupings are used in this library,
  34. and they are all fundamentally tables/vectors/arrays of integers, it can be hard
  35. to remember what they are all referring to.
  36. The following table shows what each table/vector/array refers to in the code:
  37. | NAME | REFERS TO |
  38. | ---- | ---------------------------------------------------------- |
  39. | cube | xyz, used for most maps, with constraint x+y+z=0. ** |
  40. | pix | xy, true screen pixel coordinates |
  41. | dbl | xy, 'doubled', used for rectangular maps |
  42. | off | xy, 'offset', used for UI implementations |
  43. | ---- | ---------------------------------------------------------- |
  44. | map | xy, table of unit hexagon centerpoints arranged in a shape |
  45. ** note that 'axial' coordinates are a subset of cube coordinates, where
  46. you simply omit the z value. for many algorithms this is done, but instead
  47. of using some reference name 'axial', I just used the name 'cube' for both
  48. cases. I found this to be clearer and less prone to end-user error. when
  49. an algorithm asks for a cube, give it a cube. if you want to know if it works
  50. with axial as well, look at the code and see if it uses a 'z' value.
  51. Other terminology:
  52. * TODO
  53. ## RESOURCES USED TO DEVELOP THIS LIBRARY, AND FOR WHICH I AM GRATEFUL [1.9]
  54. * [Hex Map 1](https://catlikecoding.com/unity/tutorials/hex-map/) - unity tutorial for hexagon grids with some useful generalized math.
  55. * [3Blue1Brown - Essence of Linear Algebra](https://youtube.com/watch?v=fNk_zzaMoSs&list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab) - amazing series on linear algebra by 3Blue1Brown
  56. * [Hexagonal Grids](https://redblobgames.com/grid/hexagons) - THE resource on hexagonal grids on the internet.
  57. * [Amulet Docs](http://amulet.xyz/doc) - amulet documentation.