Skip to content

Instantly share code, notes, and snippets.

@codeliger
Last active August 29, 2015 14:10
Show Gist options
  • Save codeliger/b0f7d733fd5c3c47596e to your computer and use it in GitHub Desktop.
Save codeliger/b0f7d733fd5c3c47596e to your computer and use it in GitHub Desktop.
function love.load()
debugging = false;
if( love.window.setMode(500, 500, {}) ) then
if debugging then print("Window size has been set.") end
love.graphics.setPointSize(10);
end
end
map = {}
function love.mousepressed(x, y, b)
if(b == "l") then
end
end
function love.update()
if( love.mouse.isDown("l") ) then
addRGBPoint(love.mouse.getX(), love.mouse.getY(), {math.random(0,100),math.random(0,100),math.random(0,100)})
end
end
function addRGBPoint(x,y,rgb)
assert(type(rgb) == "table", "rgb must be a table.");
if not(map[x]) then map[x] = {} end
map[x][y] = rgb
if debugging then print(string.format("Adding point to %d,%d", x, y)) end
end
function love.draw()
for xi,xv in pairs(map) do
for yi,yv in pairs(xv) do
love.graphics.setColor(yv[1],yv[2],yv[3])
love.graphics.point(xi, yi);
if debugging then print( string.format("Rendering points: %d, %d", xi, yi) ) end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment