Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --util.lua
- 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 = {} -- a table that will store the quads... rectangles chunks of textures
- 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 -- he says the issue is to increment the sheet counter... i'm still getting the same error
- end
- end
- return quads
- end
- --[[
- Error
- Map.lua:69: bad argument #2 to 'draw' (Quad expected, got nil)
- Traceback
- [C]: in function 'draw'
- Map.lua:69: in function 'render'
- main.lua:34: in function 'draw'
- [C]: in function 'xpcall'
- ]]
Advertisement
Add Comment
Please, Sign In to add comment