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.

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