-- genuary #5 2023
-- debug view
-- by carson kompon
matrix={}
debugmode=false
dbgx=-128
m_tim=0
w_len=32
w_len_slider={8,128}
w_wigam=8
w_wigam_slider={0,32}
w_thicc=6
w_thicc_slider={1,16}
w_col1=11
w_col2=12
w_col_table={3,4,5,6,7,8,9,10,11,12}
w_wavy=1
w_wavy_slider={0,2}
-- set fps to 60
_set_fps(60)
-- set palette colours
pal({[0]=0,5,6,136,8,4,9,3,11,1,140,2,14,7},1)
-- enable mouse functionality
poke(0x5f2d, 1)
-- debug slider function
function draw_slider(txt,y,var,bounds)
print(txt .. ": " .. tostr(var),dbgx+2,y-8,2)
line(dbgx+2,y,dbgx+52,y,1)
hx=dbgx+2+50*((var-bounds[1])/(bounds[2]-bounds[1]))
line(hx,y-2,hx,y+2,2)
if debugmode and mc==1 and mx>=dbgx+2 and my>=y-2 and mx<=dbgx+52 and my<=y+2 then
var=bounds[1]+(((mx-2)/50)*(bounds[2]-bounds[1]))
end
return var
end
-- debug colour select function
function draw_colselect(txt,y,var)
print(txt .. ":",dbgx+2,y-8,2)
l=#w_col_table
for i=1,l do
x=(i-1)*8
oc=1
if(var==w_col_table[i])oc=2
rect(dbgx+x+2,y,dbgx+x+8,y+6,oc)
rectfill(dbgx+x+3,y+1,dbgx+x+7,y+5,w_col_table[i])
if debugmode and mc==1 and mx>=dbgx+x+2 and my>=y and mx<=dbgx+x+8 and my<=y+6 then
var=w_col_table[i]
end
end
return var
end
lmc=0
-- main loop
::_::
-- clear the screen
cls()
-- get mouse info
mx=stat(32)
my=stat(33)
mc=stat(34)
-- spawn matrix character
if m_tim%4==0 then
add(matrix,{
x=rnd(128),y=0,c=chr(16+rnd(228-16)\1)
})
end
-- update matrix characters
for m in all(matrix) do
m.y += 1
print(m.c,m.x,m.y,1)
-- destroy if falls off-screen
if(m.y>=128)del(matrix,m)
end
m_tim+=1
-- draw worm body
xx=64-(w_len/2)
for i=1,w_len do
col=w_col2
if(i%2==0)col=w_col1
circfill(
xx+i,
64+sin(t()/8+(i/w_len*w_wavy))*w_wigam,
w_thicc,
col
)
end
-- print debug header
hdr="w𝘰𝘳𝘮 c𝘳𝘦𝘢𝘵𝘪𝘰𝘯 t𝘰𝘰𝘭𝘬𝘪𝘵 𝘷0.141276"
for i=1,#hdr do
print(hdr[i],i*4-2,4+sin(t()+i/#hdr*4)*.5,3+i%9)
end
-- draw controls
dp=26
w_len=flr(draw_slider("w𝘰𝘳𝘮 l𝘦𝘯𝘨𝘵𝘩",dp,w_len,w_len_slider)+.5)
dp+=16
w_thicc=flr(draw_slider("w𝘰𝘳𝘮 t𝘩𝘪𝘤𝘤𝘯𝘦𝘴𝘴",dp,w_thicc,w_thicc_slider)+.5)
dp+=16
w_wigam=flr(draw_slider("w𝘪𝘨𝘨𝘭𝘦 a𝘮𝘰𝘶𝘯𝘵",dp,w_wigam,w_wigam_slider)+.5)
dp+=16
w_wavy=draw_slider("w𝘢𝘷𝘺 a𝘮𝘰𝘶𝘯𝘵",dp,w_wavy,w_wavy_slider)
-- draw color selector
dp+=16
w_col1=draw_colselect("c𝘰𝘭𝘰𝘳 a",dp,w_col1)
dp+=16
w_col2=draw_colselect("c𝘰𝘭𝘰𝘳 b",dp,w_col2)
-- draw edit button
txt="edit"
if(debugmode)txt="back"
w=#txt*2
rectfill(64-w-2,119,64+w+2,128,12)
print(txt,64-w+1,121,13)
if mc==1 and lmc==0 and mx>=64-w-2 and my>=119 and mx<=64+w+2 and my<=128 then
debugmode = not debugmode
end
-- lerp debug menu
if debugmode then
dbgx=dbgx*.9
else
dbgx=dbgx*.9+(-128*.1)
end
-- draw cursor sprite
spr(0,mx,my)
flip()
lmc=mc
goto _