Log In  

Cart #48610 | 2018-01-28 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

A test in making 3D graphics within Pico. I'm pretty pleased with the result, although the shader isn't working well enough to show off here.

P#48611 2018-01-27 23:00 ( Edited 2018-01-28 06:53)

:: Felice

Heads up on a nice feature of lua:

Assignments can be done simultaneously, obviating the need for a swap function. So, for instance, you could simplify your sorty() function:

function sorty(t)
  nt=t
    if (t[1][2] > t[2][2]) then t[1],t[2]=t[2],t[1] end
    if (t[2][2] > t[3][2]) then t[2],t[3]=t[3],t[2] end
    if (t[1][2] > t[2][2]) then t[1],t[2]=t[2],t[1] end

    return nt
end

Mind you, the benefits of this kind of intrinsic swapping are felt better when using variables directly, rather than accessing table members, as it introduces a couple of extra table dereferences that would normally be consolidated inside a single swap() function. So, in this case, you only about break even on tokens, but the performance would be a little better without the temporary and the call overhead.

Nice demo btw. I might steal your icosahedron setup code, which is always a bother to re-derive when I need one, and I haven't bothered to do it since I started messing with PICO-8. ;)

P#48615 2018-01-28 01:53 ( Edited 2018-01-28 06:55)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-02-26 11:10 | 0.017s | 2097k | Q:28