Advertisement
joseleeph

Untitled

Feb 4th, 2021
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. function generateQuads(atlas, tilewidth, tileheight) --[[ atlas is like a spritesheet. a path to the texture]]
  2.  
  3. local sheetWidth = atlas:getWidth()/tilewidth
  4. local sheetHeight = atlas:getHeight()/tileheight -- we can't use local variables outside the file
  5.  
  6. local sheetCounter = 1
  7. local quads = {}
  8.  
  9.  
  10. for y = 0, sheetHeight - 1 do
  11. for x = 0, sheetWidth - 1 do
  12. quads[sheetCounter] = love.graphics.newQuad(x * tilewidth, y * tileheight, tilewidth, tileheight, atlas:getDimensions()) -- arrays are 1 indexed
  13. sheetCounter = sheetCounter + 1 -- increment the quad in the sheet
  14. end
  15. end
  16. return quads
  17. end
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement