2 Commits 20bc17847f ... 1adbb05813

Author SHA1 Message Date
  pixelbath 1adbb05813 lets fail to make a ui framework 5 months ago
  pixelbath 65d881fe34 palettization 5 months ago
2 changed files with 242 additions and 93 deletions
  1. BIN
      bdash.aseprite
  2. 242 93
      bdash.lua

BIN
bdash.aseprite


+ 242 - 93
bdash.lua

@@ -1,117 +1,266 @@
--- title:   game title
--- author:  game developer, email, etc.
--- desc:    short description
+-- title:   bdash
+-- author:  pixelbath
+-- desc:    some dashing around game
 -- site:    website link
 -- site:    website link
--- license: MIT License (change this to your license of choice)
+-- license: MIT License
 -- version: 0.1
 -- version: 0.1
 -- script:  lua
 -- script:  lua
 
 
-t=0
+ticks=0
 x=96
 x=96
 y=24
 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()
 function TIC()
+	update_editor()
 
 
 	if btn(0) then y=y-1 end
 	if btn(0) then y=y-1 end
 	if btn(1) then y=y+1 end
 	if btn(1) then y=y+1 end
 	if btn(2) then x=x-1 end
 	if btn(2) then x=x-1 end
 	if btn(3) then x=x+1 end
 	if btn(3) then x=x+1 end
 
 
-	cls(13)
-	spr(1+t%60//30*2,x,y,14,3,0,0,2,2)
-	print("HELLO WORLD!",84,84)
-	t=t+1
+	cls(0)
+	render_ui(ui_container)
+	-- draw_grid(1)
+	-- draw_toolbox()
 end
 end
 
 
 -- <TILES>
 -- <TILES>
--- 002:3333333333333333333333333331113333333133333c11333333333333333333
--- 003:333333333333333333333333331113333333133333c113333333333333333333
+-- 002:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
+-- 003:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
 -- 004:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
 -- 004:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
 -- 005:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
 -- 005:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
--- 006:3333333333333333330000003300000033000000330000003300000033000000
--- 007:3333333333333333000000330000003300000033000000330000003300000033
--- 008:0007660066660007006677666666006666006666007666007766666766006666
--- 009:0066006666000066076667006666006666006666677766007700666666667700
--- 010:0000cccc00cc00cccc22cc0011cc220211111122112211111111222211111111
--- 011:cc00000022cc0000cccccc0022ccccc0222ccccc112200cc1111cccc111211cc
--- 018:33333333333333333331113333333133333c1133333333333333333333333333
--- 019:3333333333333333331113333333133333c11333333333333333333333333333
+-- 006:dddddddddddddddddd000000dd000000dd000000dd000000dd000000dd000000
+-- 007:dddddddddddddddd000000dd000000dd000000dd000000dd000000dd000000dd
+-- 008:000fee00eeee000f00eeffeeeeee00eeee00eeee00feee00ffeeeeefee00eeee
+-- 009:00ee00eeee0000ee0feeef00eeee00eeee00eeeeefffee00ff00eeeeeeeeff00
+-- 010:0000cccc00cc00cccceecc00ffccee0effffffeeffeeffffffffeeeeffffffff
+-- 011:cc000000eecc0000cccccc00eeccccc0eeecccccffee00ccffffccccfffeffcc
+-- 018:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
+-- 019:dddddddddddddddddddddddddddfffdddddddfdddddcffdddddddddddddddddd
 -- 020:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
 -- 020:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
 -- 021:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
 -- 021:dddd00dddddd00ffffff00ff0000000000dddddd00ffdddd00ffffff00000000
--- 022:3300000033000000330000003300000033000000330000003333333333333333
--- 023:0000003300000033000000330000003300000033000000333333333333333333
--- 024:0066666666670076667766000076666766006700666600006670667700660000
--- 025:7766666666666700776600660067776666006670666607660066700066006600
--- 026:1100111111100011110001111111000101111100001111110000110000000011
--- 027:1111112211221112111111111111111011111110111111002211000011000000
--- 032:00000000000030000000333300033cc300333c43000033330000002200000333
--- 033:0000000000030000333300003cc3300034c33300333300002200000033300000
--- 048:000030cc000030aa0000c0cc000000aa00000999000099000000990000dccc00
--- 049:cc030000aa030000cc0c0000aa00000099900000009900000099000000cccd00
--- 064:c000000022000000ccc00000cc2200002222c00001112200000000cc00000022
--- 065:0000000200000011000002cc000011cc00022222001111102200000011000000
--- 066:000c000000020000000cc000000c2200000222c0000011200000000c00000002
--- 067:00002000000010000002c0000011c00002222000011100002000000010000000
--- 068:00000c000000020000000cc000000c2000000220000000100000000c00000002
--- 069:002000000010000000c0000001c0000002200000010000002000000010000000
--- 080:011111cc22222222cccccc00cccc200022cc0000112000002200000010000000
--- 081:22111110112222220022cccc0001cccc00002222000001110000001100000001
--- 082:0000111c00022222000cccc0000ccc200002cc00000122000002200000010000
--- 083:2111000012222000022cc000001cc00000022000000110000000100000001000
--- 084:0000001c0000022200000cc000000cc0000002c0000001200000020000000100
--- 085:210000001220000022c0000001c0000000200000001000000010000000100000
--- 096:cccccccccccccccccc222222cc222222cc221111cc221111cc221122cc221122
--- 097:cccccccccccccccc222222cc222222cc111122cc111122cc221122cc221122cc
--- 098:222222222222222222111111221111112211222222112222221122cc221122cc
--- 099:222222222222222211111122111111222222112222221122cc221122cc221122
--- 100:111111111111111111222222112222221122cccc1122cccc1122cc221122cc22
--- 101:11111111111111112222221122222211cccc2211cccc221122cc221122cc2211
--- 102:222222222222222222cccccc22cccccc22cc222222cc222222cc221122cc2211
--- 103:2222222222222222cccccc22cccccc222222cc222222cc221122cc221122cc22
--- 112:cc221122cc221122cc221111cc221111cc222222cc222222cccccccccccccccc
--- 113:221122cc221122cc111122cc111122cc222222cc222222cccccccccccccccccc
--- 114:221122cc221122cc221122222211222222111111221111112222222222222222
--- 115:cc221122cc221122222211222222112211111122111111222222222222222222
--- 116:1122cc221122cc221122cccc1122cccc11222222112222221111111111111111
--- 117:22cc221122cc2211cccc2211cccc221122222211222222111111111111111111
--- 118:22cc221122cc221122cc222222cc222222cccccc22cccccc2222222222222222
--- 119:1122cc221122cc222222cc222222cc22cccccc22cccccc222222222222222222
--- 128:0000000b000000ba00000bab0000bacc000baccc00babbbb0baaaaaab9999999
--- 129:c0000000bc000000bbc00000ccbc0000cccbc000bbbbbc00aaaaaac09999999c
--- 130:0000000b000000ba00000bac0000babb000baaaa00ba99990ba99999b9aaaaaa
--- 131:c0000000bc000000cbc00000bbbc0000aaabc0009999bc0099999ac0aaaaaa9c
--- 132:0000000b000000ba00000baa0000ba99000ba99900baaaaa0babbbbbb9cccccc
--- 133:c0000000bc000000abc0000099bc0000999bc000aaaabc00bbbbbac0cccccc9c
--- 134:0000000b000000ba00000ba90000baaa000babbb00bacccc0bacccccb9bbbbbb
--- 135:c0000000bc0000009bc00000aabc0000bbbbc000ccccbc00cccccac0bbbbbb9c
--- 136:0000000b000000ba00000bab0000bacc000baccc00babbbb0babbbbbb9cccccc
--- 137:c0000000bc000000bbc00000ccbc0000cccbc000bbbbbc00bbbbbac0cccccc9c
--- 138:0000000b000000ba00000bac0000babb000babbb00bacccc0bacccccb9bbbbbb
--- 139:c0000000bc000000cbc00000bbbc0000bbbbc000ccccbc00cccccac0bbbbbb9c
--- 144:a99999990aaaaaaa00abbbbb000acccc0000abcc00000abb000000aa0000000a
--- 145:9999999baaaaaab0bbbbbb00ccccb000cccb0000bbb00000bb000000a0000000
--- 146:a9bbbbbb0aaccccc00abcccc000acbbb0000abbb00000abc000000aa0000000a
--- 147:bbbbbb9bcccccab0ccccbb00bbbcb000bbcb0000cbb00000bb000000a0000000
--- 148:a9cccccc0aabbbbb00abbbbb000acccc0000abcc00000abb000000aa0000000a
--- 149:cccccc9bbbbbbab0bbbbbb00ccccb000cccb0000bbb00000bb000000a0000000
--- 150:a9bbbbbb0aaccccc00abcccc000acbbb0000abaa00000ab9000000aa0000000a
--- 151:bbbbbb9bcccccab0ccccbb00bbbcb000aacb00009bb00000bb000000a0000000
--- 152:a9cccccc0aabbbbb00abaaaa000ac9990000ab9900000aba000000aa0000000a
--- 153:cccccc9bbbbbbab0aaaabb00999cb00099cb0000abb00000bb000000a0000000
--- 154:a9aaaaaa0aa9999900ab9999000acaaa0000abbb00000abc000000aa0000000a
--- 155:aaaaaa9b99999ab09999bb00aaacb000bbcb0000cbb00000bb000000a0000000
--- 160:6666664166666664666666664466666611466666446666666666666666666666
--- 161:1146666644666666666666666666666466666641666666646666666666666666
--- 162:6666664166666641666666646666666646666666466666666666666666666666
--- 163:1146666611466666446666666666666666666664666666646666666666666666
--- 164:6666666466666666666666664466666611466666114666664466666666666666
--- 165:4466666666666666666666666666666466666641666666416666666466666666
--- 176:6666666666666666466666661466666614666666466666666666666466666641
--- 177:6666666666666666666664446666411166664111666664444466666611466666
--- 178:6666666646666666146666661466666614666666466666666666666466666641
--- 179:6666666666666444666641116666411166664111666664444466666611466666
--- 180:6666666666666666466666661466666646666666666666666666666666666664
--- 181:6666666666666666666664446666411166666444666666666666666644666666
+-- 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
 -- </TILES>
 -- </TILES>
 
 
 -- <MAP>
 -- <MAP>