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.

84 lines
3.4 KiB

4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
  1. local fail_count = 0
  2. local function load_texture(filepath)
  3. local status, texture = pcall(am.texture2d, filepath)
  4. if status then
  5. return texture
  6. else
  7. fail_count = fail_count + 1
  8. log(filepath)
  9. return am.texture2d("res/bagel.jpg")
  10. end
  11. end
  12. TEXTURES = {
  13. -- note that in amulet, if you prefix paths with './', they fail to be found in the exported data.pak
  14. LOGO = load_texture("res/logo.png"),
  15. GEM1 = load_texture("res/gem1.png"),
  16. SHADED_HEX = load_texture("res/shaded_hex.png"),
  17. NEW_GAME_HEX = load_texture("res/newgamehex.png"),
  18. SAVE_GAME_HEX = load_texture("res/savegamehex.png"),
  19. LOAD_GAME_HEX = load_texture("res/loadgamehex.png"),
  20. SETTINGS_HEX = load_texture("res/settingshex.png"),
  21. MAP_EDITOR_HEX = load_texture("res/mapeditorhex.png"),
  22. ABOUT_HEX = load_texture("res/abouthex.png"),
  23. QUIT_HEX = load_texture("res/quithex.png"),
  24. UNPAUSE_HEX = load_texture("res/unpausehex.png"),
  25. MAIN_MENU_HEX = load_texture("res/mainmenuhex.png"),
  26. CURTAIN = load_texture("res/curtain1.png"),
  27. SOUND_ON1 = load_texture("res/sound-on.png"),
  28. SOUND_OFF = load_texture("res/sound-off.png"),
  29. -- gui stuff
  30. BUTTON1 = load_texture("res/button1.png"),
  31. WIDER_BUTTON1 = load_texture("res/wider_button1.png"),
  32. GEAR = load_texture("res/gear.png"),
  33. SELECT_BOX = load_texture("res/select_box.png"),
  34. -- tower stuff
  35. TOWER_WALL = load_texture("res/tower_wall.png"),
  36. TOWER_WALL_ICON = load_texture("res/tower_wall_icon.png"),
  37. TOWER_GATTLER = load_texture("res/tower_gattler.png"),
  38. TOWER_GATTLER_ICON = load_texture("res/tower_gattler_icon.png"),
  39. TOWER_HOWITZER = load_texture("res/tower_howitzer.png"),
  40. TOWER_HOWITZER_ICON = load_texture("res/tower_howitzer_icon.png"),
  41. TOWER_REDEYE = load_texture("res/tower_redeye.png"),
  42. TOWER_REDEYE_ICON = load_texture("res/tower_redeye_icon.png"),
  43. TOWER_MOAT = load_texture("res/tower_moat.png"),
  44. TOWER_MOAT_ICON = load_texture("res/tower_moat_icon.png"),
  45. TOWER_RADAR = load_texture("res/tower_radar.png"),
  46. TOWER_RADAR_ICON = load_texture("res/tower_radar_icon.png"),
  47. TOWER_LIGHTHOUSE = load_texture("res/tower_lighthouse.png"),
  48. TOWER_LIGHTHOUSE_ICON = load_texture("res/tower_lighthouse_icon.png"),
  49. -- mob stuff
  50. MOB_BEEPER = load_texture("res/mob_beeper.png"),
  51. MOB_SPOODER = load_texture("res/mob_spooder.png"),
  52. MOB_VELKOOZ = load_texture("res/mob_velkooz.png"),
  53. MOB_VELKOOZ1 = load_texture("res/mob_velkooz1.png"),
  54. MOB_VELKOOZ2 = load_texture("res/mob_velkooz2.png"),
  55. MOB_VELKOOZ3 = load_texture("res/mob_velkooz3.png"),
  56. }
  57. function pack_texture_into_sprite(texture, width, height, color)
  58. local sprite = am.sprite{
  59. texture = texture,
  60. s1 = 0, s2 = 1, t1 = 0, t2 = 1,
  61. x1 = 0, x2 = width, width = width,
  62. y1 = 0, y2 = height, height = height
  63. }
  64. if color then sprite.color = color end
  65. return sprite
  66. end
  67. if fail_count > 0 then
  68. log("failed to load %d texture(s)", fail_count)
  69. end