Code: Select all
table.has = function(tabl, value)
for i,v in pairs(tabl) do
if value == item then return true end
end
return false
end
table.length = function(tabl)
local count = 0
for i,v in pairs(tabl) do
count = count + 1
end
return count
end
function love.load()
pixels = {}
end
function love.update()
pos = {love.mouse.getX(), love.mouse.getY()}
if(love.mouse.isDown("r"))then
pixels = {}
end
for i,v in ipairs(pixels) do
if(table.has(pixels, v))then
v = nil
end
end
if(love.mouse.isDown("l"))then
table.insert(pixels, pos)
end
end
function love.draw()
love.graphics.setColor(255,255,255)
for i,v in ipairs(pixels) do
love.graphics.point(v[1], v[2])
end
love.graphics.print(love.timer.getFPS(), 10, 10)
love.graphics.print("Amount of pixels being drawn: "..table.length(pixels), 10, 30)
end