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.

56 lines
1.5 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
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(map)
  7. test_scene:action(function()
  8. mouse_position = vec2(win:mouse_position().x, win:mouse_position().y)
  9. hex = map.retrieve(mouse_position)
  10. test_scene:remove("text")
  11. test_scene:append(am.translate(win.right - 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. end
  18. ----- [[ BLAH BLAH LBAH ]] -----------------------------------------------
  19. win = am.window {
  20. title = "Warzone 2: Electric Boogaloo",
  21. -- BASE RESOLUTION = 3/4 * WXGA Standard 16:10 Aspect Ratio
  22. width = 1280 * 3 / 4, -- 960
  23. height = 800 * 3 / 4} -- 600
  24. ----- [[ MAP RENDERING ]] ------------------------------------------------
  25. function game_scene(layout)
  26. map = map_rectangular_init(layout, 45, 31)
  27. hexagons = am.group()
  28. for _,hex in pairs(map) do
  29. hexagons:append(
  30. am.circle(hex, layout.size.x, rcolor(), 6):tag(tostring(hex)))
  31. end
  32. return hexagons
  33. end
  34. ----- [[ MAIN ]] -----------------------------------------------------------
  35. map = {}
  36. game_scene = game_scene(layout_init(vec2(win.left, win.bottom)))
  37. test_scene = am.group()
  38. win.scene = am.group{test_scene, game_scene}
  39. show_hex_coords(map)