Log In  

I'm new to Pico-8 and this is my first snippet. I would appreciate any feedback, or ways of making this more efficient.

It's a snippet to draw a sprite in an area as a repeating pattern texture.

function drawpattern(idx, x0, y0, x1, y1)
    local sprx = 8 * (idx % 16)
    local spry = 8 * flr(idx/16)
    for y=y0,y1,8 do
        local endy = min(y1, y+8)
        local sampleh = endy-y
        for x=x0,x1,8 do
            local endx = min(x1, x+8)
            local samplew = endx-x
            sspr(sprx, spry, samplew, sampleh, x, y, samplew, sampleh)
        end
    end
end
P#44527 2017-09-24 07:43 ( Edited 2017-09-24 11:44)


[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 11:54:05 | 0.004s | Q:6