function readTile(tileFileName) tile = {} tile.img = love.graphics.newImage(tileFileName) tile.w, tile.h = tile.img:getDimensions() -- get dimensions (width, height) tile.c = tile.w / 16 -- columns tile.r = tile.h / 16 -- rows tile.b = tile.c * tile.r -- total blocks end function getBlockPos(tileBlock) -- Get Block Tile Position getBlockY(tileBlock) -- y pixel position (block.y) getBlockX(tileBlock) -- x pixel position (block.x) print (block.y) print (block.x) end function getBlockY(tileBlock) -- Get Block Y position block = {} count = 0 for i = 1,tile.r,1 do if( tileBlock <= (tile.r * i) ) then count = (count + 1) end end block.col = (tile.r - count) -- cols 0:7 block.y = ((block.col) * 16) -- y pixel position end function getBlockX(tileBlock) -- Get Block X position count = 0 if( block.col == 0 ) then for x = 1,8,1 do count = (count + 1) if( tileBlock == x ) then block.row = (count) end end end if( block.col == 1 ) then for x = 9,16,1 do count = (count + 1) if( tileBlock == x ) then block.row = (count) end end end if( block.col == 2 ) then for x = 17,24,1 do count = (count + 1) if( tileBlock == x ) then block.row = (count) end end end if( block.col == 3 ) then for x = 25,32,1 do count = (count + 1) if( tileBlock == x ) then block.row = (count) end end end if( block.col == 4 ) then for x = 33,40,1 do count = (count + 1) if( tileBlock == x ) then block.row = (count) end end end if( block.col == 5 ) then for x = 41,48,1 do count = (count + 1) if( tileBlock == x ) then block.row = (count) end end end if( block.col == 6 ) then for x = 49,56,1 do count = (count + 1) if( tileBlock == x ) then block.row = (count) end end end if( block.col == 7 ) then for x = 57,64,1 do count = (count + 1) if( tileBlock == x ) then block.row = (count) end end end block.x = (block.row * 16) end