Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function generateQuads(atlas, tilewidth, tileheight) --[[ atlas is like a spritesheet. a path to the texture]]
- local sheetWidth = atlas:getWidth()/tilewidth
- local sheetHeight = atlas:getHeight()/tileheight -- we can't use local variables outside the file
- local sheetCounter = 1
- local quads = {}
- for y = 0, sheetHeight - 1 do
- for x = 0, sheetWidth - 1 do
- quads[sheetCounter] = love.graphics.newQuad(x * tilewidth, y * tileheight, tilewidth, tileheight, atlas:getDimensions()) -- arrays are 1 indexed
- sheetCounter = sheetCounter + 1 -- increment the quad in the sheet
- end
- end
- return quads
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement