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.

63 lines
1.8 KiB

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 win = am.window{
  7. -- BASE RESOLUTION = 3/4 * WXGA Standard 16:10
  8. width = 1280 * 3 / 4, -- 960px
  9. height = 800 * 3 / 4, -- 600px
  10. title = "Warzone 2: Electric Boogaloo"}
  11. local title = am.group()
  12. local world = am.group()
  13. local layout = hex_layout(vec2(-368, win.bottom))
  14. local map = hex_rectangular_map(45, 31)
  15. local titlemap = hex_spiral_map(vec2(0), 10)
  16. local titlelayout = hex_layout(vec2(win.right, win.bottom))
  17. function show_axes()
  18. xaxis = am.line(vec2(win.left, 0), vec2(win.right, 0))
  19. yaxis = am.line(vec2(0, win.top), vec2(0, win.bottom))
  20. world:append(am.group{xaxis, yaxis}:tag("axes"))
  21. end
  22. function world_init()
  23. world:action(coroutine.create(function()
  24. for hex,_ in pairs(map) do
  25. world:append(am.circle(hex_to_pixel(hex, layout), 11, rrgb(1), 6))
  26. am.wait(am.delay(0.01))
  27. end
  28. end))
  29. end
  30. function init()
  31. local rotatable = am.group(am.rotate(45):tag"rotatable")
  32. local backdrop = am.group{rotatable}
  33. for _,hex in pairs(titlemap) do
  34. local center = hex_to_pixel(hex, titlelayout)
  35. rotatable:append(am.circle(center, 11, rrgb(1), 6))
  36. end
  37. local line1 = am.text("WARZONE 2")
  38. local line2 = am.text("Electric Boogaloo")
  39. local line3 = am.text("by Nick Hayashi")
  40. local title = am.group{backdrop,
  41. am.translate(0, 150) ^ am.scale(4) ^ line1,
  42. am.translate(0, 100) ^ am.scale(3) ^ line2,
  43. am.translate(0, 60) ^ am.scale(1) ^ line3
  44. }:action(function()
  45. rotatable"rotatable".angle = (am.frame_time / 5)
  46. end)
  47. win.scene = title
  48. end
  49. ----- [[ MAIN ]] ---------------------------------------------------------------
  50. init()