Hey, hello! I'm a beginner in programming. I followed the tutorial "Game Development using PICO-8 by Dylan Bennett" to learn to use Pico-8. follow the page 28 of the tutorial. I wrote a game which just like "Flappy Bird", and then I ran into some questions about "tables".
The questions are as follows:
I don't understand what the means about"cave={{["top"]=5,["btm"]=119}}".
The context of this code is as follows(In line 2):
function make_cave() cave={{["top"]=5,["btm"]=119}} top=45 btm=85 end function update_cave() if (#cave>player.speed) then for i=1,player.speed do del (cave,cave[1]) end end while (#cave<128) do local col={} local up=flr(rnd(7)-3) local dwn=flr(rnd(7)-3) col.top=mid(3, cave[#cave].top+up,top) col.btm=mid(btm, cave[#cave].btm+dwn,124) add(cave,col) end end function draw_cave() top_color=5 btm_color=5 for i=1,#cave do line(i-1,0,i-1,cave[i].top, top_color) line(i-1,127,i-1,cave[i].btm, btm_color) end end |
P#105969 2022-01-30 16:38