-- title: bdash
-- author: pixelbath
-- desc: some dashing around game
-- site: website link
-- license: MIT License
-- version: 0.1
-- script: lua
ticks=0
x=96
y=24
function ui_update()
local mx, my, lb = mouse()
for k,v in pairs(obj.children) do
end
end
function cb_btntest()
trace("cleeeck")
end
function append_elem(obj, append_obj)
table.insert(obj.children, append_obj)
end
function render_ui(obj, xs, ys)
xs = xs or 0
ys = ys or 0
local objx, objy = obj.x + xs, obj.y + ys
if obj.type == "container" then
for k,v in pairs(obj.children) do
render_ui(v, objx, objy)
end
end
if obj.type == "btn" then
rect(objx, objy, (#obj.text) * 4 + 1, 7, 2)
print(obj.text, objx + 1, objy + 1, 4, 1, 1, 1)
end
end
function create_ui_object(xpos, ypos, w, h)
return {
x = xpos or 0,
y = ypos or 0,
width = w or 240,
height = h or 136,
children = {},
type = "container",
}
end
function create_ui_btn(xpos, ypos, text, cb_func)
local elem = create_ui_object(xpos or 0, ypos or 0)
elem.text = text or "Button"
elem.type = "btn"
elem.cb = cb_func
return elem
end
ui_container = create_ui_object()
ui_btn = create_ui_btn(0, 0, "Click", cb_btntest)
append_elem(ui_container, ui_btn)
tiles = {
impass = {
editor = 76,
sprites = { 2 },
},
wall = {
editor = 77,
sprites = { 4 },
},
exit = {
editor = 95,
sprites = { 2, 6 },
},
bush = {
editor = 78,
sprites = { 8 },
},
rock = {
editor = 92,
sprites = { 10 },
},
bfly = {
editor = 108,
sprites = { 64, 66, 68, 66 },
},
rock = {
editor = 92,
sprites = { 10 },
},
square = {
editor = 93,
sprites = { 96, 98, 100, 102 },
},
amoeba = {
editor = 110,
sprites = { 160, 162, 164, 162 },
},
diamond = {
editor = 109,
sprites = { 128, 130, 132, 134, 136, 138 },
},
}
-- TODO: pick palette schemes - map drawing tool / palette tool
-- TODO: mapping tool
function draw_grid(clr)
for gridx=8,240,8 do
line(gridx, 0, gridx, 136, clr)
end
for gridy=8,136,8 do
line(0, gridy, 240, gridy, clr)
end
local mx, my, lb = mouse()
local gridmx, gridmy = (mx // 8) * 8, (my // 8) * 8
rect(gridmx, gridmy, 8, 8, 2)
end
function set_pal(idx, clr)
end
function update_editor()
--pix(mx, my, 5)
-- draw editor
end
-- draws everything that has a .editor prop
function draw_toolbox()
local idx = 0
for k,v in pairs(tiles) do
trace(v)
if v.editor ~= nil then
spr(v.editor, idx * 8, 10)
idx = idx + 1
end
end
end
function TIC()
update_editor()
if btn(0) then y=y-1 end
if btn(1) then y=y+1 end
if btn(2) then x=x-1 end
if btn(3) then x=x+1 end
cls(0)
render_ui(ui_container)
-- draw_grid(1)
-- draw_toolbox()
end
--
-- 002:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
-- 003:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
-- 004:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
-- 005:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
-- 006:dddddddddddddddddd000000dd000000dd000000dd000000dd000000dd000000
-- 007:dddddddddddddddd000000dd000000dd000000dd000000dd000000dd000000dd
-- 008:000fee00eeee000f00eeffeeeeee00eeee00eeee00feee00ffeeeeefee00eeee
-- 009:00ee00eeee0000ee0feeef00eeee00eeee00eeeeefffee00ff00eeeeeeeeff00
-- 010:0000cccc00cc00cccceecc00ffccee0effffffeeffeeffffffffeeeeffffffff
-- 011:cc000000eecc0000cccccc00eeccccc0eeecccccffee00ccffffccccfffeffcc
-- 018:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
-- 019:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
-- 020:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
-- 021:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
-- 022:dd000000dd000000dd000000dd000000dd000000dd000000dddddddddddddddd
-- 023:000000dd000000dd000000dd000000dd000000dd000000dddddddddddddddddd
-- 024:00eeeeeeeeef00feeeffee0000feeeefee00ef00eeee0000eef0eeff00ee0000
-- 025:ffeeeeeeeeeeef00ffee00ee00efffeeee00eef0eeee0fee00eef000ee00ee00
-- 026:ff00fffffff000ffff000fffffff000f0fffff0000ffffff0000ff00000000ff
-- 027:ffffffeeffeefffefffffffffffffff0fffffff0ffffff00eeff0000ff000000
-- 032:000000000000d0000000dddd000ddccd00dddc4d0000dddd000000ee00000ddd
-- 033:00000000000d0000dddd0000dccdd000d4cddd00dddd0000ee000000ddd00000
-- 048:0000d0cc0000d0ee0000c0cc000000ee00000fff0000ff000000ff0000dccc00
-- 049:cc0d0000ee0d0000cc0c0000ee000000fff0000000ff000000ff000000cccd00
-- 064:c0000000ee000000ccc00000ccee0000eeeec0000fffee00000000cc000000ee
-- 065:0000000e000000ff00000ecc0000ffcc000eeeee00fffff0ee000000ff000000
-- 066:000c0000000e0000000cc000000cee00000eeec00000ffe00000000c0000000e
-- 067:0000e0000000f000000ec00000ffc0000eeee0000fff0000e0000000f0000000
-- 068:00000c0000000e0000000cc000000ce000000ee0000000f00000000c0000000e
-- 069:00e0000000f0000000c000000fc000000ee000000f000000e0000000f0000000
-- 076:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
-- 077:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
-- 078:000fee00eeee000f00eeffeeeeee00eeee00eeee00feee00ffeeeeefee00eeee
-- 080:0fffffcceeeeeeeecccccc00cccce000eecc0000ffe00000ee000000f0000000
-- 081:eefffff0ffeeeeee00eecccc000fcccc0000eeee00000fff000000ff0000000f
-- 082:0000fffc000eeeee000cccc0000ccce0000ecc00000fee00000ee000000f0000
-- 083:efff0000feeee0000eecc00000fcc000000ee000000ff0000000f0000000f000
-- 084:000000fc00000eee00000cc000000cc000000ec000000fe000000e0000000f00
-- 085:ef000000fee00000eec000000fc0000000e0000000f0000000f0000000f00000
-- 092:000cec000ce0ecc0fefffe0cfffffffcff0ffeffff00ffff0ffffff0000ff000
-- 093:eeeeeeeeecccccceeceeeeceeceffeceeceffeceeceeeeceecccccceeeeeeeee
-- 094:00000000000000000000dd00000d00000000d00000000d00000dd00000000000
-- 095:0000000000000000000ddd00000d0000000dd000000d0000000ddd0000000000
-- 096:cccccccccccccccccceeeeeecceeeeeecceeffffcceeffffcceeffeecceeffee
-- 097:cccccccccccccccceeeeeecceeeeeeccffffeeccffffeecceeffeecceeffeecc
-- 098:eeeeeeeeeeeeeeeeeeffffffeeffffffeeffeeeeeeffeeeeeeffeecceeffeecc
-- 099:eeeeeeeeeeeeeeeeffffffeeffffffeeeeeeffeeeeeeffeecceeffeecceeffee
-- 100:ffffffffffffffffffeeeeeeffeeeeeeffeeccccffeeccccffeecceeffeeccee
-- 101:ffffffffffffffffeeeeeeffeeeeeeffcccceeffcccceeffeecceeffeecceeff
-- 102:eeeeeeeeeeeeeeeeeecccccceecccccceecceeeeeecceeeeeecceeffeecceeff
-- 103:eeeeeeeeeeeeeeeecccccceecccccceeeeeecceeeeeecceeffeecceeffeeccee
-- 108:e000000fce0000fcffe00ffffffeffffeeeefeeecce000ccfe0000fff000000f
-- 109:000dc00000dccc000deeeec0dffffffceffffffc0edeeed000edcd00000ee000
-- 110:ccceeccceccccccefeccccefecccccceccccccccccccccccccceeccccceffecc
-- 112:cceeffeecceeffeecceeffffcceeffffcceeeeeecceeeeeecccccccccccccccc
-- 113:eeffeecceeffeeccffffeeccffffeecceeeeeecceeeeeecccccccccccccccccc
-- 114:eeffeecceeffeecceeffeeeeeeffeeeeeeffffffeeffffffeeeeeeeeeeeeeeee
-- 115:cceeffeecceeffeeeeeeffeeeeeeffeeffffffeeffffffeeeeeeeeeeeeeeeeee
-- 116:ffeecceeffeecceeffeeccccffeeccccffeeeeeeffeeeeeeffffffffffffffff
-- 117:eecceeffeecceeffcccceeffcccceeffeeeeeeffeeeeeeffffffffffffffffff
-- 118:eecceeffeecceeffeecceeeeeecceeeeeecccccceecccccceeeeeeeeeeeeeeee
-- 119:ffeecceeffeecceeeeeecceeeeeecceecccccceecccccceeeeeeeeeeeeeeeeee
-- 128:0000000d000000de00000ded0000decc000deccc00dedddd0deeeeeedfffffff
-- 129:c0000000dc000000ddc00000ccdc0000cccdc000dddddc00eeeeeec0fffffffc
-- 130:0000000d000000de00000dec0000dedd000deeee00deffff0defffffdfeeeeee
-- 131:c0000000dc000000cdc00000dddc0000eeedc000ffffdc00fffffec0eeeeeefc
-- 132:0000000d000000de00000dee0000deff000defff00deeeee0deddddddfcccccc
-- 133:c0000000dc000000edc00000ffdc0000fffdc000eeeedc00dddddec0ccccccfc
-- 134:0000000d000000de00000def0000deee000deddd00decccc0decccccdfdddddd
-- 135:c0000000dc000000fdc00000eedc0000ddddc000ccccdc00cccccec0ddddddfc
-- 136:0000000d000000de00000ded0000decc000deccc00dedddd0deddddddfcccccc
-- 137:c0000000dc000000ddc00000ccdc0000cccdc000dddddc00dddddec0ccccccfc
-- 138:0000000d000000de00000dec0000dedd000deddd00decccc0decccccdfdddddd
-- 139:c0000000dc000000cdc00000dddc0000ddddc000ccccdc00cccccec0ddddddfc
-- 144:efffffff0eeeeeee00eddddd000ecccc0000edcc00000edd000000ee0000000e
-- 145:fffffffdeeeeeed0dddddd00ccccd000cccd0000ddd00000dd000000e0000000
-- 146:efdddddd0eeccccc00edcccc000ecddd0000eddd00000edc000000ee0000000e
-- 147:ddddddfdccccced0ccccdd00dddcd000ddcd0000cdd00000dd000000e0000000
-- 148:efcccccc0eeddddd00eddddd000ecccc0000edcc00000edd000000ee0000000e
-- 149:ccccccfdddddded0dddddd00ccccd000cccd0000ddd00000dd000000e0000000
-- 150:efdddddd0eeccccc00edcccc000ecddd0000edee00000edf000000ee0000000e
-- 151:ddddddfdccccced0ccccdd00dddcd000eecd0000fdd00000dd000000e0000000
-- 152:efcccccc0eeddddd00edeeee000ecfff0000edff00000ede000000ee0000000e
-- 153:ccccccfdddddded0eeeedd00fffcd000ffcd0000edd00000dd000000e0000000
-- 154:efeeeeee0eefffff00edffff000eceee0000eddd00000edc000000ee0000000e
-- 155:eeeeeefdfffffed0ffffdd00eeecd000ddcd0000cdd00000dd000000e0000000
-- 160:ccccccefcccccccecccccccceeccccccffeccccceecccccccccccccccccccccc
-- 161:ffeccccceeccccccccccccccccccccceccccccefcccccccecccccccccccccccc
-- 162:ccccccefccccccefcccccccecccccccceccccccceccccccccccccccccccccccc
-- 163:ffecccccffeccccceecccccccccccccccccccccecccccccecccccccccccccccc
-- 164:cccccccecccccccccccccccceeccccccffecccccffeccccceecccccccccccccc
-- 165:eeccccccccccccccccccccccccccccceccccccefccccccefcccccccecccccccc
-- 176:ccccccccccccccccecccccccfeccccccfeccccccecccccccccccccceccccccef
-- 177:ccccccccccccccccccccceeeccccefffccccefffccccceeeeeccccccffeccccc
-- 178:ccccccccecccccccfeccccccfeccccccfeccccccecccccccccccccceccccccef
-- 179:ccccccccccccceeeccccefffccccefffccccefffccccceeeeeccccccffeccccc
-- 180:ccccccccccccccccecccccccfeccccccecccccccccccccccccccccccccccccce
-- 181:ccccccccccccccccccccceeeccccefffccccceeecccccccccccccccceecccccc
--
--
--
-- 000:00000000ffffffff00000000ffffffff
-- 001:0123456789abcdeffedcba9876543210
-- 002:0123456789abcdef0123456789abcdef
--
--
-- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
--
--
-- 000:100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
--
--
-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
--