I made a simple drawSpritePalette routine, but its pretty slow.
Kerm: could you make a built in function that does this?
Code:
function ffgfx.drawSpritePalette( data, x, y, width, height, palette, res )
local res=res or 1
local k=1
for i=1,height do
for j=1,width do
if palette[string.sub(data,k,k)+1]~=0 then
zmg.drawRectFill(x+(j-1)*res, y+(i-1)*res, res, res, palette[string.sub(data,k,k)+1])
end
k=k+1
end
end
end
Example usage
Code:
grass = "00000000100100100010010111111111"
grasspalette = {zmg.makeColor(15,255,15),zmg.makeColor("green")}
drawSpritePalette(grass, 1, 1, 8, 4, grasspalette, 4)
data: sprite data.
x, y: positioning
width, height: height and width of sprite
palette: sprite's color palette.
res: resolution. 1 is 1x1 pixels, 2 is 2x2 pixels, etc.