From d159477fe145aa064c79661f308f24505ec5cc4f Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 1 Oct 2023 12:00:14 -0700 Subject: [PATCH] box-style ui --- pal_from_spr.p8 | 128 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 122 insertions(+), 6 deletions(-) diff --git a/pal_from_spr.p8 b/pal_from_spr.p8 index 05db86d..1c9e586 100644 --- a/pal_from_spr.p8 +++ b/pal_from_spr.p8 @@ -9,9 +9,33 @@ function _init() pal({[0]=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}, 2) poke(0x5f5f, 0x10) poke2(0x5f70, 0xffff) + + mode = "boxes" + active = "sprite" + scx = 0 + scy = 0 + dcx = 0 + dcy = 0 end function _update() + if (btnp(🅾️)) mode = (mode == "boxes") and "rows" or "boxes" + if (btnp(❎)) active = (active == "sprite") and "draw" or "sprite" + if active == "sprite" then + if (btnp(⬆️)) scy -= 1 + if (btnp(⬇️)) scy += 1 + if (btnp(⬅️)) scx -= 1 + if (btnp(➡️)) scx += 1 + else + if (btnp(⬆️)) dcy -= 1 + if (btnp(⬇️)) dcy += 1 + if (btnp(⬅️)) dcx -= 1 + if (btnp(➡️)) dcx += 1 + end + scx %= (mode == "boxes") and box_cols or rows_cols + dcx %= (mode == "boxes") and box_cols or rows_cols + scy %= (mode == "boxes") and box_rows or rows_rows + dcy %= (mode == "boxes") and box_rows or rows_rows end function _draw() @@ -21,12 +45,46 @@ function _draw() end function draw_hud() + palt() + if (mode == "boxes") return draw_box_hud() + draw_rows_hud() +end + +function print_shadow(s,x,y,c) + print(s,x+1,y+1,1) + print(s,x,y,c or 7) +end + +box_rows = 4 +box_cols = 4 + +function draw_box_hud() + spr(1,0,0,4,2) + local toff = time() * 4 \ 1 % 2 + spr(107 + (active == "sprite" and toff or 0), + 8*scx,4*scy,1,0.5) + spr(109 + (active == "draw" and toff or 0), + 8*dcx,4*dcy,1,0.5) + + print_shadow("spr",34,4,12) + sspr(8+8*scx,4*scy,8,4,47,4,16,8) + + print_shadow("draw",65,4,14) + sspr(8+8*dcx,4*dcy,8,4,83,4,16,8) end function draw_bars() for i=0,15 do - local i7 = i * 7 - rectfill(0,16+i7,128,i7+22,i) + local i6 = i * 6 + rectfill(0,16+i6,128,i6+21,i) + end + for i=0,15 do + for y=16,120,8 do + spr(i+112,9+i*7,y,0.625,1) + end + end + for y=16,120,8 do + spr(111,120,y) end end -->8 @@ -93,9 +151,67 @@ function palette:compile_palt() return bits end __gfx__ +00000000012300000123555501230000012355550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000456700004567555545670000456755550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0070070089ab000089ab555589ab000089ab55550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000cdef0000cdef5555cdef0000cdef55550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000012324440123355501232444012335550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700456744444567555545674444456755550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000089ab444489ab555589ab444489ab55550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000cdef4444cdef5555cdef4444cdef55550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000012301230123012301230123012301230000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000456745674567456745674567456745670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000089ab89ab89ab89ab89ab89ab89ab89ab0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000cdefcdefcdefcdefcdefcdefcdefcdef0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000012301230123012301230123012301230000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000456745674567456745674567456745670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000089ab89ab89ab89ab89ab89ab89ab89ab0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000cdefcdefcdefcdefcdefcdefcdefcdef0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000c00000007000000e0000000700000000c0c0c0c07070707e0e0e0e07070707001230123 +00000000000000000000000000000000000000000000000000000000c0000000700000000e00000007000000c0000000700000000000000e0000000745674567 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000007e00000007000000089ab89ab +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0c0c0c0707070700e0e0e0e07070707cdefcdef +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001230123 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045674567 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000089ab89ab +000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cdefcdef +5500055500111000002220000033300000444000005550000066600000777000008880000099900000aaa00000bbb00000ccc00000ddd00000eee00000fff000 +500055550111000002220000033300000444000005550000066600000777000008880000099900000aaa00000bbb00000ccc00000ddd00000eee00000fff0000 +00055555111000002220000033300000444000005550000066600000777000008880000099900000aaa00000bbb00000ccc00000ddd00000eee00000fff00000 +500055550111000002220000033300000444000005550000066600000777000008880000099900000aaa00000bbb00000ccc00000ddd00000eee00000fff0000 +5500055500111000002220000033300000444000005550000066600000777000008880000099900000aaa00000bbb00000ccc00000ddd00000eee00000fff000 +500055550111000002220000033300000444000005550000066600000777000008880000099900000aaa00000bbb00000ccc00000ddd00000eee00000fff0000 +00055555111000002220000033300000444000005550000066600000777000008880000099900000aaa00000bbb00000ccc00000ddd00000eee00000fff00000 +500055550111000002220000033300000444000005550000066600000777000008880000099900000aaa00000bbb00000ccc00000ddd00000eee00000fff0000