Could the built-in demo variable names be any less helpful for n00bs? From demos/hello:
for i=1,11 do for j0=0,7 do j = 7-j0 col = 7+j t1 = t + i*4 - j*2 x = cos(t0)*5 y = 38 + j + cos(t1/50)*5 pal(7,col) spr(16+i, 8+i*8 + x, y) end end
What does j0 mean? jack0ff? What about j for that matter? I see col, which could mean column, but then I would expect row or something similar for a multi-dimension loop. t1? The t-1000 terminator? Bah! Humbug!
There's a ton of greatly helpful advice in the pico zines and in the forums here, but it just strikes me as frustrating to show n00bs the hello world demo and it just purposely uses these incredibly unhelpful variable names. I've always been taught that function names and variable names should be self explanatory as to their purpose for ease of code reading, particularly in an example meant to demonstrate program functionality.
*digs out the code and looks it over*
...so, like, on the one hand, i and j are standard loop counter variable names - I think that's a convention you'll find everywhere - but on the other hand, this code has no explanatory comments and at least one noticeable bug, so it could definitely have used some cleaning up before being included in the demos list.
On the gripping hand, I've figured out what they are? i is which letter from the "HELLO WORLD" line of sprites is being drawn, j is which ... 'echo'? of that letter is being drawn, j0 is just j counting the wrong way (j0 goes from 0 to 7, j goes from 7 to 0), and col is the color of the echo.
It's even worse than that. This line doesn't do anything because t0 is nil:
x = cos(t0)*5
The other carts are readable enough, I think -- I'll fix hello.p8 for the next update. The demos are also marked to be re-worked for 0.2.0 to tie in with a new version of the manual.
[Please log in to post a comment]