Skip to content

Instantly share code, notes, and snippets.

@codeliger
Last active August 29, 2015 14:10
Show Gist options
  • Save codeliger/68390c738ee59e1da841 to your computer and use it in GitHub Desktop.
Save codeliger/68390c738ee59e1da841 to your computer and use it in GitHub Desktop.
local window = {
width = 500,
height = 500
}
pixelmap = {}
function love.load()
love.window.setMode(window.width, window.height, {});
love.window.setTitle("Warden")
love.graphics.setPointSize(200)
for xindex=1,window.width do
pixelmap[xindex] = {}
for yindex=1,window.height do
pixelmap[xindex][yindex] = {0,0,0,255}
end
end
end
function love.keypressed(key)
if(key == "escape") then
love.event.quit()
end
end
function love.update()
if(love.mouse.isDown("l")) then
local x, y = love.mouse.getPosition()
if(x > 0 and x <= window.width and y > 0 and y < window.height) then
pixelmap[x][y] = {255,255,255,255}
end
end
end
function love.draw()
for xindex=1,#pixelmap do
for yindex=1,#pixelmap[xindex] do
love.graphics.setColor(pixelmap[xindex][yindex])
love.graphics.point(xindex,yindex)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment