The most straightforward example possible. (You can probably do this much cleaner.)
On loading; make the line/fill variables and stuff them in a table. When drawing, reload the line/fill from the table and use it to draw each block.
If you don't understand what is happening, let me know I'll explain more.
(Like everything I post; untested function. If it gives an error, try to solve it yourself as it's probably just a typo)
Code: Select all
function love.load()
blocks = {}
makeBlocks()
end
function makeBlocks()
h,w = love.window.getHeight,love.window.getWidth
for i = 0,12 do
blocks[i] = {}
for h = 0,12 do
t = love.math.random(1,2)
if t == 1 then
love.graphics.rectangle("line",i*45,h*45,45,45)
blocks[i][h] = "line";
else
love.graphics.rectangle("fill",i*45,h*45,45,45)
blocks[i][h] = "fill";
end
end
end
end
function drawBlocks()
h,w = love.window.getHeight,love.window.getWidth
for i = 0,12 do
for h = 0,12 do
love.graphics.rectangle(blocks[i][h],i*45,h*45,45,45)
end
end
end
function love.update()
end
function love.draw()
drawBlocks()
end