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.

93 lines
2.7 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
  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. map_scene:append(am.particles2d({source_pos=vec2(400, win.top),
  54. source_pos_var=vec2(0, 600),
  55. angle=math.pi/4,
  56. start_color=vec4(0.9),
  57. gravity=vec2(100),
  58. start_color_var=rcolor(),
  59. start_size=5}))
  60. --print(win.right - 268)
  61. return true
  62. end)
  63. end
  64. ----- [[ MAIN ]] -----------------------------------------------------------
  65. map = {}
  66. gui_scene = am.group()
  67. map_scene = am.group(); map_init(layout_init(vec2(win.left, win.bottom)))
  68. win.scene = am.group{map_scene, gui_scene}
  69. show_hex_coords(map)