I don't want to use mapPixel but instead make my own map loading method.
So im trying to get each pixel for each row on the line and create a value in a table for it. I think the way i made my table is incorrect. So i was wondering if anyone could look at my code and tell me whats wrong.
The map is just getting loaded from this incorrectly, i looked at the table (mapData) and it was incorrectly loaded.
Here is what im trying to load :
(supposed to be 16x16)
http://imgur.com/5kulseh
Here is what i get :
http://imgur.com/a/lHviN
Any help would be awesome thanks!
Code:
Code: Select all
function mapLoad()
local mapPixels = love.image.newImageData("/rec/maps/woodtest.png")
local pixelX = 1
local pixelY = 1
mapToDraw = true
for i = 1,15 do
for i = 1,15 do
mapR , mapG , mapB , mapA = mapPixels:getPixel(pixelX - 1,pixelY - 1)
if mapR == 0 and mapG == 127 and mapB == 14 then
table.insert(mapData, "grass")
elseif mapR == 124 and mapG == 73 and mapB == 38 then
table.insert(mapData, "darkoakwood")
elseif mapR == 150 and mapG == 88 and mapB == 46 then
table.insert(mapData, "oakwood")
end
if pixelX == 16 then
pixelX = 1
else
pixelX = pixelX + 1
end
end
if pixelY == 16 then
pixelY = 1
else
pixelY = pixelY + 1
end
end
pY = pixelY
pX = pixelX
return
end