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.

86 lines
2.3 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. ----- [[ WARZONE 2 - HEXAGONAL GRID RESOURCE BASED TOWER DEFENSE GAME]] -------
  2. --[[ author@churchianity.ca
  3. ]]
  4. require "hex"
  5. ----- [[ DUMMY FUNCTIONS ]] ----------------------------------------------------
  6. function show_hex_coords()
  7. gui_scene:action(function()
  8. gui_scene:remove("text")
  9. mouse_position = vec2(win:mouse_position().x, win:mouse_position().y)
  10. if mouse_position.x < 268 then
  11. hex = map.retrieve(mouse_position)
  12. gui_scene:append(am.translate(win.left + 30, win.top - 10)
  13. ^ am.text(string.format("%d,%d", hex.s, hex.t)))
  14. end
  15. end)
  16. end
  17. function rcolor()
  18. return vec4(math.random(20, 80) / 100,
  19. math.random(20, 80) / 100,
  20. math.random(20, 80) / 100,
  21. 1)
  22. end
  23. ----- [[ BLAH BLAH LBAH ]] -----------------------------------------------
  24. win = am.window {
  25. title = "Warzone 2: Electric Boogaloo",
  26. -- BASE RESOLUTION = 3/4 * WXGA Standard 16:10 Aspect Ratio
  27. width = 1280 * 3 / 4, -- 960
  28. height = 800 * 3 / 4} -- 600
  29. ----- [[ MAP RENDERING ]] ------------------------------------------------
  30. function map_init(layout)
  31. map = rectmap_init(layout, 45, 31)
  32. map_scene:action(function()
  33. for _,hex in pairs(map) do
  34. if hex_equals(_, vec2(23, 16)) then
  35. print("yay")
  36. else
  37. map_scene:append(am.circle(hex, layout.size.x, rcolor(), 6))
  38. end
  39. end
  40. map_scene:append(am.rect(268, win.top, win.right, win.bottom, vec4(0.4, 0.6, 0.8, 1)))
  41. local coalburner = [[
  42. .........
  43. ..kkkkk..
  44. .k.....k.
  45. k..wo...k
  46. k..ooo..k
  47. k...o...k
  48. .k.....k.
  49. ..kkkkk..
  50. .........
  51. ]]
  52. map_scene:append(am.translate(350, 200) ^ am.scale(10) ^ am.sprite(coalburner))
  53. --print(win.right - 268)
  54. return true
  55. end)
  56. end
  57. ----- [[ MAIN ]] -----------------------------------------------------------
  58. map = {}
  59. gui_scene = am.group()
  60. map_scene = am.group(); map_init(layout_init(vec2(win.left, win.bottom)))
  61. win.scene = am.group{map_scene, gui_scene}
  62. show_hex_coords(map)