micha wrote:
This, by the way, is also the method to store tile-based maps.
Yeah, I've tried working with tilemaps before, I never really grasped the concept correctly. Thanks for explaining this to me! Now, to color the pixels white, I'd simply loop through all the array entries and check if their values are, let's say, the string "white"? And if yes, then color that pixel white?
Code: Select all
for i=1,#pixels do
for j=1,#pixels[i] do
if(pixels[i][j]=="white")then
love.graphics.point(...) --this is the part where I can't figure out. I'm thinking pixels[i][j], but that doesn't work, since it's not a coordinate.
end
end
end
EDIT:
tavuntu wrote:oops, a little later.
Thanks for helping nonetheless!
DOUBLE EDIT:
I tried something out, but it has huge performance issues in the love.draw, and it's not even drawing.
Code: Select all
g = love.graphics
m = love.mouse
function love.load()
pixels = {}
for i=1,600 do
pixels[i]={}
for j=1,800 do
pixels[i][j]={}
end
end
g.setColor(255,255,255,255)
g.setCaption("p-a-int")
width = g.getWidth()
height = g.getHeight()
end
function love.update()
pos = {m.getX(), m.getY()}
if(m.isDown("r"))then
pixels = {}
end
if(m.isDown("l"))then
for i,v in pairs(pixels) do
for j,z in pairs(v) do
z = {1, pos}
end
end
end
end
function love.draw()
for i,v in pairs(pixels) do
for j,z in pairs(v) do
if(z[1]==1)then
g.point(z[2][1], z[2][2])
end
end
end
g.print(love.timer.getFPS(), 10, 10)
--g.print("Amount of pixels being drawn: "..table.length(pixels), 10, 30) to be remade later
end