function love.load()
map_width = 60
map_height = 40
map={}
--initialize the table
for i = 1,map_width do
map[i] = {}
for j = 1,map_height do
map[i][j] = math.random(0,3)
end
end
mapX = 1
mapY = 1
tileDisWidth = 26
tileDisHeight = 20
zoomX = 1
zoomY = 1
--construct map
tilesetImage = love.graphics.newImage( "/res/map.png" )
tilesetImage:setFilter("nearest", "linear") -- this "linear filter" removes some artifacts if we were to scale the tiles
tileSize = 32
-- grass
img1 = love.graphics.newQuad(0 * tileSize, 20 * tileSize, tileSize, tileSize,
tilesetImage:getWidth(), tilesetImage:getHeight())
-- kitchen floor tile
img2 = love.graphics.newQuad(2 * tileSize, 0 * tileSize, tileSize, tileSize,
tilesetImage:getWidth(), tilesetImage:getHeight())
-- parquet flooring
img3 = love.graphics.newQuad(4 * tileSize, 0 * tileSize, tileSize, tileSize,
tilesetImage:getWidth(), tilesetImage:getHeight())
-- middle of red carpet
img4 = love.graphics.newQuad(3 * tileSize, 9 * tileSize, tileSize, tileSize,
tilesetImage:getWidth(), tilesetImage:getHeight())
tilesetBatch = love.graphics.newSpriteBatch(tilesetImage, 600)
end
function updateTilesetBatch()
tilesetBatch:clear()
tilesetBatch:addq(img1, 32, 32)
tilesetBatch:addq(img2, 64, 64)
tilesetBatch:addq(img3, 128, 128)
tilesetBatch:addq(img4, 256, 256)
end
function love.draw()
love.graphics.draw(tilesetBatch)
end
]]
--[[
img = love.graphics.newImage("/house/house1.png")
-- Let's say we want to display only the top-left
-- 32x32 quadrant of the Image:
top_left = love.graphics.newQuad(0, 0, img:getWidth(), img:getHeight(), img:getWidth(), img:getHeight())
-- And here is bottom left:
bottom_left = love.graphics.newQuad(200, img:getHeight()+20, img:getWidth(), img:getHeight(), img:getWidth(), img:getHeight())
--tilesetBatch = love.graphics.newSpriteBatch(img, 400)
--love.graphics.drawq(img, top_left, 200, 200)
--love.graphics.draw(tilesetBatch)
function love.draw()
love.graphics.drawq(img, top_left, 50, 50)
love.graphics.drawq(img, bottom_left, 100, 200)
end