bdash.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. -- title: bdash
  2. -- author: pixelbath
  3. -- desc: some dashing around game
  4. -- site: website link
  5. -- license: MIT License
  6. -- version: 0.1
  7. -- script: lua
  8. ticks=0
  9. x=96
  10. y=24
  11. function ui_update()
  12. local mx, my, lb = mouse()
  13. for k,v in pairs(obj.children) do
  14. end
  15. end
  16. function cb_btntest()
  17. trace("cleeeck")
  18. end
  19. function append_elem(obj, append_obj)
  20. table.insert(obj.children, append_obj)
  21. end
  22. function render_ui(obj, xs, ys)
  23. xs = xs or 0
  24. ys = ys or 0
  25. local objx, objy = obj.x + xs, obj.y + ys
  26. if obj.type == "container" then
  27. for k,v in pairs(obj.children) do
  28. render_ui(v, objx, objy)
  29. end
  30. end
  31. if obj.type == "btn" then
  32. rect(objx, objy, (#obj.text) * 4 + 1, 7, 2)
  33. print(obj.text, objx + 1, objy + 1, 4, 1, 1, 1)
  34. end
  35. end
  36. function create_ui_object(xpos, ypos, w, h)
  37. return {
  38. x = xpos or 0,
  39. y = ypos or 0,
  40. width = w or 240,
  41. height = h or 136,
  42. children = {},
  43. type = "container",
  44. }
  45. end
  46. function create_ui_btn(xpos, ypos, text, cb_func)
  47. local elem = create_ui_object(xpos or 0, ypos or 0)
  48. elem.text = text or "Button"
  49. elem.type = "btn"
  50. elem.cb = cb_func
  51. return elem
  52. end
  53. ui_container = create_ui_object()
  54. ui_btn = create_ui_btn(0, 0, "Click", cb_btntest)
  55. append_elem(ui_container, ui_btn)
  56. tiles = {
  57. impass = {
  58. editor = 76,
  59. sprites = { 2 },
  60. },
  61. wall = {
  62. editor = 77,
  63. sprites = { 4 },
  64. },
  65. exit = {
  66. editor = 95,
  67. sprites = { 2, 6 },
  68. },
  69. bush = {
  70. editor = 78,
  71. sprites = { 8 },
  72. },
  73. rock = {
  74. editor = 92,
  75. sprites = { 10 },
  76. },
  77. bfly = {
  78. editor = 108,
  79. sprites = { 64, 66, 68, 66 },
  80. },
  81. rock = {
  82. editor = 92,
  83. sprites = { 10 },
  84. },
  85. square = {
  86. editor = 93,
  87. sprites = { 96, 98, 100, 102 },
  88. },
  89. amoeba = {
  90. editor = 110,
  91. sprites = { 160, 162, 164, 162 },
  92. },
  93. diamond = {
  94. editor = 109,
  95. sprites = { 128, 130, 132, 134, 136, 138 },
  96. },
  97. }
  98. -- TODO: pick palette schemes - map drawing tool / palette tool
  99. -- TODO: mapping tool
  100. function draw_grid(clr)
  101. for gridx=8,240,8 do
  102. line(gridx, 0, gridx, 136, clr)
  103. end
  104. for gridy=8,136,8 do
  105. line(0, gridy, 240, gridy, clr)
  106. end
  107. local mx, my, lb = mouse()
  108. local gridmx, gridmy = (mx // 8) * 8, (my // 8) * 8
  109. rect(gridmx, gridmy, 8, 8, 2)
  110. end
  111. function set_pal(idx, clr)
  112. end
  113. function update_editor()
  114. --pix(mx, my, 5)
  115. -- draw editor
  116. end
  117. -- draws everything that has a .editor prop
  118. function draw_toolbox()
  119. local idx = 0
  120. for k,v in pairs(tiles) do
  121. trace(v)
  122. if v.editor ~= nil then
  123. spr(v.editor, idx * 8, 10)
  124. idx = idx + 1
  125. end
  126. end
  127. end
  128. function TIC()
  129. update_editor()
  130. if btn(0) then y=y-1 end
  131. if btn(1) then y=y+1 end
  132. if btn(2) then x=x-1 end
  133. if btn(3) then x=x+1 end
  134. cls(0)
  135. render_ui(ui_container)
  136. -- draw_grid(1)
  137. -- draw_toolbox()
  138. end
  139. -- <TILES>
  140. -- 002:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
  141. -- 003:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
  142. -- 004:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
  143. -- 005:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
  144. -- 006:dddddddddddddddddd000000dd000000dd000000dd000000dd000000dd000000
  145. -- 007:dddddddddddddddd000000dd000000dd000000dd000000dd000000dd000000dd
  146. -- 008:000fee00eeee000f00eeffeeeeee00eeee00eeee00feee00ffeeeeefee00eeee
  147. -- 009:00ee00eeee0000ee0feeef00eeee00eeee00eeeeefffee00ff00eeeeeeeeff00
  148. -- 010:0000cccc00cc00cccceecc00ffccee0effffffeeffeeffffffffeeeeffffffff
  149. -- 011:cc000000eecc0000cccccc00eeccccc0eeecccccffee00ccffffccccfffeffcc
  150. -- 018:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
  151. -- 019:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
  152. -- 020:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
  153. -- 021:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
  154. -- 022:dd000000dd000000dd000000dd000000dd000000dd000000dddddddddddddddd
  155. -- 023:000000dd000000dd000000dd000000dd000000dd000000dddddddddddddddddd
  156. -- 024:00eeeeeeeeef00feeeffee0000feeeefee00ef00eeee0000eef0eeff00ee0000
  157. -- 025:ffeeeeeeeeeeef00ffee00ee00efffeeee00eef0eeee0fee00eef000ee00ee00
  158. -- 026:ff00fffffff000ffff000fffffff000f0fffff0000ffffff0000ff00000000ff
  159. -- 027:ffffffeeffeefffefffffffffffffff0fffffff0ffffff00eeff0000ff000000
  160. -- 032:000000000000d0000000dddd000ddccd00dddc4d0000dddd000000ee00000ddd
  161. -- 033:00000000000d0000dddd0000dccdd000d4cddd00dddd0000ee000000ddd00000
  162. -- 048:0000d0cc0000d0ee0000c0cc000000ee00000fff0000ff000000ff0000dccc00
  163. -- 049:cc0d0000ee0d0000cc0c0000ee000000fff0000000ff000000ff000000cccd00
  164. -- 064:c0000000ee000000ccc00000ccee0000eeeec0000fffee00000000cc000000ee
  165. -- 065:0000000e000000ff00000ecc0000ffcc000eeeee00fffff0ee000000ff000000
  166. -- 066:000c0000000e0000000cc000000cee00000eeec00000ffe00000000c0000000e
  167. -- 067:0000e0000000f000000ec00000ffc0000eeee0000fff0000e0000000f0000000
  168. -- 068:00000c0000000e0000000cc000000ce000000ee0000000f00000000c0000000e
  169. -- 069:00e0000000f0000000c000000fc000000ee000000f000000e0000000f0000000
  170. -- 076:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
  171. -- 077:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
  172. -- 078:000fee00eeee000f00eeffeeeeee00eeee00eeee00feee00ffeeeeefee00eeee
  173. -- 080:0fffffcceeeeeeeecccccc00cccce000eecc0000ffe00000ee000000f0000000
  174. -- 081:eefffff0ffeeeeee00eecccc000fcccc0000eeee00000fff000000ff0000000f
  175. -- 082:0000fffc000eeeee000cccc0000ccce0000ecc00000fee00000ee000000f0000
  176. -- 083:efff0000feeee0000eecc00000fcc000000ee000000ff0000000f0000000f000
  177. -- 084:000000fc00000eee00000cc000000cc000000ec000000fe000000e0000000f00
  178. -- 085:ef000000fee00000eec000000fc0000000e0000000f0000000f0000000f00000
  179. -- 092:000cec000ce0ecc0fefffe0cfffffffcff0ffeffff00ffff0ffffff0000ff000
  180. -- 093:eeeeeeeeecccccceeceeeeceeceffeceeceffeceeceeeeceecccccceeeeeeeee
  181. -- 094:00000000000000000000dd00000d00000000d00000000d00000dd00000000000
  182. -- 095:0000000000000000000ddd00000d0000000dd000000d0000000ddd0000000000
  183. -- 096:cccccccccccccccccceeeeeecceeeeeecceeffffcceeffffcceeffeecceeffee
  184. -- 097:cccccccccccccccceeeeeecceeeeeeccffffeeccffffeecceeffeecceeffeecc
  185. -- 098:eeeeeeeeeeeeeeeeeeffffffeeffffffeeffeeeeeeffeeeeeeffeecceeffeecc
  186. -- 099:eeeeeeeeeeeeeeeeffffffeeffffffeeeeeeffeeeeeeffeecceeffeecceeffee
  187. -- 100:ffffffffffffffffffeeeeeeffeeeeeeffeeccccffeeccccffeecceeffeeccee
  188. -- 101:ffffffffffffffffeeeeeeffeeeeeeffcccceeffcccceeffeecceeffeecceeff
  189. -- 102:eeeeeeeeeeeeeeeeeecccccceecccccceecceeeeeecceeeeeecceeffeecceeff
  190. -- 103:eeeeeeeeeeeeeeeecccccceecccccceeeeeecceeeeeecceeffeecceeffeeccee
  191. -- 108:e000000fce0000fcffe00ffffffeffffeeeefeeecce000ccfe0000fff000000f
  192. -- 109:000dc00000dccc000deeeec0dffffffceffffffc0edeeed000edcd00000ee000
  193. -- 110:ccceeccceccccccefeccccefecccccceccccccccccccccccccceeccccceffecc
  194. -- 112:cceeffeecceeffeecceeffffcceeffffcceeeeeecceeeeeecccccccccccccccc
  195. -- 113:eeffeecceeffeeccffffeeccffffeecceeeeeecceeeeeecccccccccccccccccc
  196. -- 114:eeffeecceeffeecceeffeeeeeeffeeeeeeffffffeeffffffeeeeeeeeeeeeeeee
  197. -- 115:cceeffeecceeffeeeeeeffeeeeeeffeeffffffeeffffffeeeeeeeeeeeeeeeeee
  198. -- 116:ffeecceeffeecceeffeeccccffeeccccffeeeeeeffeeeeeeffffffffffffffff
  199. -- 117:eecceeffeecceeffcccceeffcccceeffeeeeeeffeeeeeeffffffffffffffffff
  200. -- 118:eecceeffeecceeffeecceeeeeecceeeeeecccccceecccccceeeeeeeeeeeeeeee
  201. -- 119:ffeecceeffeecceeeeeecceeeeeecceecccccceecccccceeeeeeeeeeeeeeeeee
  202. -- 128:0000000d000000de00000ded0000decc000deccc00dedddd0deeeeeedfffffff
  203. -- 129:c0000000dc000000ddc00000ccdc0000cccdc000dddddc00eeeeeec0fffffffc
  204. -- 130:0000000d000000de00000dec0000dedd000deeee00deffff0defffffdfeeeeee
  205. -- 131:c0000000dc000000cdc00000dddc0000eeedc000ffffdc00fffffec0eeeeeefc
  206. -- 132:0000000d000000de00000dee0000deff000defff00deeeee0deddddddfcccccc
  207. -- 133:c0000000dc000000edc00000ffdc0000fffdc000eeeedc00dddddec0ccccccfc
  208. -- 134:0000000d000000de00000def0000deee000deddd00decccc0decccccdfdddddd
  209. -- 135:c0000000dc000000fdc00000eedc0000ddddc000ccccdc00cccccec0ddddddfc
  210. -- 136:0000000d000000de00000ded0000decc000deccc00dedddd0deddddddfcccccc
  211. -- 137:c0000000dc000000ddc00000ccdc0000cccdc000dddddc00dddddec0ccccccfc
  212. -- 138:0000000d000000de00000dec0000dedd000deddd00decccc0decccccdfdddddd
  213. -- 139:c0000000dc000000cdc00000dddc0000ddddc000ccccdc00cccccec0ddddddfc
  214. -- 144:efffffff0eeeeeee00eddddd000ecccc0000edcc00000edd000000ee0000000e
  215. -- 145:fffffffdeeeeeed0dddddd00ccccd000cccd0000ddd00000dd000000e0000000
  216. -- 146:efdddddd0eeccccc00edcccc000ecddd0000eddd00000edc000000ee0000000e
  217. -- 147:ddddddfdccccced0ccccdd00dddcd000ddcd0000cdd00000dd000000e0000000
  218. -- 148:efcccccc0eeddddd00eddddd000ecccc0000edcc00000edd000000ee0000000e
  219. -- 149:ccccccfdddddded0dddddd00ccccd000cccd0000ddd00000dd000000e0000000
  220. -- 150:efdddddd0eeccccc00edcccc000ecddd0000edee00000edf000000ee0000000e
  221. -- 151:ddddddfdccccced0ccccdd00dddcd000eecd0000fdd00000dd000000e0000000
  222. -- 152:efcccccc0eeddddd00edeeee000ecfff0000edff00000ede000000ee0000000e
  223. -- 153:ccccccfdddddded0eeeedd00fffcd000ffcd0000edd00000dd000000e0000000
  224. -- 154:efeeeeee0eefffff00edffff000eceee0000eddd00000edc000000ee0000000e
  225. -- 155:eeeeeefdfffffed0ffffdd00eeecd000ddcd0000cdd00000dd000000e0000000
  226. -- 160:ccccccefcccccccecccccccceeccccccffeccccceecccccccccccccccccccccc
  227. -- 161:ffeccccceeccccccccccccccccccccceccccccefcccccccecccccccccccccccc
  228. -- 162:ccccccefccccccefcccccccecccccccceccccccceccccccccccccccccccccccc
  229. -- 163:ffecccccffeccccceecccccccccccccccccccccecccccccecccccccccccccccc
  230. -- 164:cccccccecccccccccccccccceeccccccffecccccffeccccceecccccccccccccc
  231. -- 165:eeccccccccccccccccccccccccccccceccccccefccccccefcccccccecccccccc
  232. -- 176:ccccccccccccccccecccccccfeccccccfeccccccecccccccccccccceccccccef
  233. -- 177:ccccccccccccccccccccceeeccccefffccccefffccccceeeeeccccccffeccccc
  234. -- 178:ccccccccecccccccfeccccccfeccccccfeccccccecccccccccccccceccccccef
  235. -- 179:ccccccccccccceeeccccefffccccefffccccefffccccceeeeeccccccffeccccc
  236. -- 180:ccccccccccccccccecccccccfeccccccecccccccccccccccccccccccccccccce
  237. -- 181:ccccccccccccccccccccceeeccccefffccccceeecccccccccccccccceecccccc
  238. -- </TILES>
  239. -- <MAP>
  240. -- 001:203020302030203020302030203020302030203020302030203020302030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  241. -- 002:213121312131213121312131213121312131213121312131213121312131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  242. -- 003:203080908090809080908090809000008090809008188090a0b000008090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  243. -- 004:213181918191819181918191819100008191819109198191a1b100008191000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  244. -- 005:20308090a0b00212a0b08090809080908090809080900000809080908090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  245. -- 006:21318191a1b10313a1b18191819181918191819181910000819181918191000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  246. -- 007:20308090809080908090809080908090809080908090000080908090a0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  247. -- 008:21318191819181918191819181918191819181918191000081918191a1b1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  248. -- 009:2030a0b08090a0b0a0b0809080908090809080908090809080908090a0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  249. -- 010:2131a1b18191a1b1a1b1819181918191819181918191819181918191a1b1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  250. -- 011:2030a0b080900000a0b08090809080908090809080908090809080900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  251. -- 012:2131a1b181910000a1b18191819181918191819181918191819181910000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  252. -- 013:2030809080908090000080908090a0b08090809080908090809080908090000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  253. -- 014:2131819181918191000081918191a1b18191819181918191819181918191000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  254. -- 015:203040504050405040504050405040504050405040504050405040504050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  255. -- 016:213141514151415141514151415141514151415141514151415141514151000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  256. -- </MAP>
  257. -- <WAVES>
  258. -- 000:00000000ffffffff00000000ffffffff
  259. -- 001:0123456789abcdeffedcba9876543210
  260. -- 002:0123456789abcdef0123456789abcdef
  261. -- </WAVES>
  262. -- <SFX>
  263. -- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
  264. -- </SFX>
  265. -- <TRACKS>
  266. -- 000:100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  267. -- </TRACKS>
  268. -- <PALETTE>
  269. -- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
  270. -- </PALETTE>