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.

79 lines
3.1 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
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
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. CURTAIN = load_texture("res/curtain1.png"),
  26. SOUND_ON1 = load_texture("res/sound-on.png"),
  27. SOUND_OFF = load_texture("res/sound-off.png"),
  28. -- gui stuff
  29. BUTTON1 = load_texture("res/button1.png"),
  30. WIDER_BUTTON1 = load_texture("res/wider_button1.png"),
  31. GEAR = load_texture("res/gear.png"),
  32. SELECT_BOX = load_texture("res/select_box.png"),
  33. -- tower stuff
  34. TOWER_WALL = load_texture("res/tower_wall.png"),
  35. TOWER_WALL_ICON = load_texture("res/tower_wall_icon.png"),
  36. TOWER_GATTLER = load_texture("res/tower_gattler.png"),
  37. TOWER_GATTLER_ICON = load_texture("res/tower_gattler_icon.png"),
  38. TOWER_HOWITZER = load_texture("res/tower_howitzer.png"),
  39. TOWER_HOWITZER_ICON = load_texture("res/tower_howitzer_icon.png"),
  40. TOWER_REDEYE = load_texture("res/tower_redeye.png"),
  41. TOWER_REDEYE_ICON = load_texture("res/tower_redeye_icon.png"),
  42. TOWER_MOAT = load_texture("res/tower_moat.png"),
  43. TOWER_MOAT_ICON = load_texture("res/tower_moat_icon.png"),
  44. TOWER_RADAR = load_texture("res/tower_radar.png"),
  45. TOWER_RADAR_ICON = load_texture("res/tower_radar_icon.png"),
  46. TOWER_LIGHTHOUSE = load_texture("res/tower_lighthouse.png"),
  47. TOWER_LIGHTHOUSE_ICON = load_texture("res/tower_lighthouse_icon.png"),
  48. -- mob stuff
  49. MOB_BEEPER = load_texture("res/mob_beeper.png"),
  50. MOB_SPOODER = load_texture("res/mob_spooder.png"),
  51. }
  52. function pack_texture_into_sprite(texture, width, height, color)
  53. local sprite = am.sprite{
  54. texture = texture,
  55. s1 = 0, s2 = 1, t1 = 0, t2 = 1,
  56. x1 = 0, x2 = width, width = width,
  57. y1 = 0, y2 = height, height = height
  58. }
  59. if color then sprite.color = color end
  60. return sprite
  61. end
  62. if fail_count > 0 then
  63. log("failed to load %d texture(s)", fail_count)
  64. end