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.

57 lines
1.4 KiB

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. require "util"
  6. local world
  7. local guibgcolor = vec4(0.5, 0.5, 0.2, 0)
  8. local win = am.window{
  9. -- BASE RESOLUTION = 3/4 * WXGA Standard 16:10
  10. width = 1280 * 3 / 4, -- 960px
  11. height = 800 * 3 / 4, -- 600px
  12. title = "Warzone 2: Electric Boogaloo"}
  13. function show_axes()
  14. xaxis = am.line(vec2(win.left, 0), vec2(win.right, 0))
  15. yaxis = am.line(vec2(0, win.top), vec2(0, win.bottom))
  16. world:append(am.group{xaxis, yaxis}:tag("axes"))
  17. end
  18. function world_init()
  19. world = am.group()
  20. local layout = layout_init(vec2(-402, win.bottom))
  21. local map = rectmap_init(45, 31)
  22. local lgui = am.group(
  23. am.rect(win.left, win.top, -402, win.bottom, guibgcolor))
  24. local rgui = am.group(
  25. am.rect(win.right, win.top, 402, win.bottom, guibgcolor))
  26. world:append(lgui)
  27. world:append(rgui)
  28. world:action(coroutine.create(function()
  29. for hex,_ in pairs(map) do
  30. world:append(am.circle(hex_to_pixel(hex, layout), 11, rrgb(1), 6))
  31. am.wait(am.delay(0.01))
  32. end
  33. end))
  34. end
  35. function init()
  36. world_init()
  37. show_axes()
  38. win.scene = world
  39. end
  40. ----- [[ MAIN ]] ---------------------------------------------------------------
  41. init()