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.

99 lines
2.0 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
5 years ago
  1. math.randomseed(os.time())
  2. math.random()
  3. math.random()
  4. math.random()
  5. do
  6. local width, height, title = 1920, 1080, "hexyz"
  7. WIN = am.window{
  8. width = width,
  9. height = height,
  10. title = title,
  11. highdpi = true,
  12. letterbox = true,
  13. --projection = projection
  14. }
  15. OFF_SCREEN = vec2(width * 2, 0) -- arbitrary location garunteed to be offscreen
  16. end
  17. -- assets and/or trivial code
  18. require "color"
  19. require "sound"
  20. require "texture"
  21. require "src/entity"
  22. require "src/extra"
  23. require "src/geometry"
  24. require "src/hexyz"
  25. require "src/game"
  26. require "src/grid"
  27. require "src/gui"
  28. require "src/mob"
  29. require "src/projectile"
  30. require "src/tower"
  31. -- global audio settings
  32. MUSIC_VOLUME = 0.1
  33. SFX_VOLUME = 0.1
  34. MODES = { MAIN, GAME }
  35. CURRENT_MODE = MODES.MAIN
  36. -- top right display types
  37. local TRDTS = {
  38. NOTHING,
  39. CENTERED_EVENQ,
  40. EVENQ,
  41. HEX,
  42. PLATFORM,
  43. PERF,
  44. SEED,
  45. TILE,
  46. }
  47. local TRDT = 0
  48. function update_top_right_message(display_type)
  49. local str = ""
  50. if display_type == TRDTS.CENTERED_EVENQ then
  51. str = centered_evenq.x .. "," .. centered_evenq.y .. " (cevenq)"
  52. elseif display_type == TRDTS.EVENQ then
  53. str = evenq.x .. "," .. evenq.y .. " (evenq)"
  54. elseif display_type == TRDTS.HEX then
  55. str = hex.x .. "," .. hex.y .. " (hex)"
  56. elseif display_type == TRDTS.PLATFORM then
  57. str = string.format("%s %s lang %s", am.platform, am.version, am.language())
  58. elseif display_type == TRDTS.PERF then
  59. str = table.tostring(PERF_STATS)
  60. elseif display_type == TRDTS.SEED then
  61. str = "SEED: " .. HEX_MAP.seed
  62. elseif display_type == TRDTS.TILE then
  63. str = table.tostring(HEX_MAP.get(hex.x, hex.y))
  64. end
  65. return str
  66. end
  67. function main_action()
  68. if WIN:key_pressed"f1" then
  69. TRDT = (TRDT + 1) % #table.keys(TRDTS)
  70. end
  71. end
  72. function main_scene()
  73. return am.group():action(main_action)
  74. end
  75. WIN.scene = am.group()
  76. game_init()
  77. noglobals()