Advertisement
Guest User

Untitled

a guest
Aug 10th, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. function love.draw() // declares the function
  2. for rowIndex=1, #TileTable do // This is the first loop, it means start at row 1 and for every row in #Tiletable loop once
  3. local row = TileTable[rowIndex] // The current row being handled is put into a temporary variable local to the function
  4. for columnIndex=1, #row do // This is the second/nested loop, it means start at column 1 and for every column in the current row loop once
  5. local number = row[columnIndex] // store the current column in a temporary variable local to the function
  6. local x = (columnIndex-1)*TileW // Substract 1 from the current column location and multiply it by a tile width, store in a local variable to the function ***more on this below
  7. local y = (rowIndex-1)*TileH // Substract 1 from the current row location and multiply it by a tile width, store in a local variable to the function ***more on this below
  8. love.graphics.draw(Tileset, Quads[number], x, y) // draw from the tileset (im assuming this is where the graphics file is) the quads determines where to "cut" the sprite at to get the right tile, then draw it at location x and y on the screen?
  9. end // Exit second/nested loop once all the columns are processed
  10. end // Exit first loop once all the rows are processed
  11. end // The funciton ends here
  12.  
  13. *** I'm assuming the reason 1 is subtracted from the current row/column location is because in programming we start with 0. The loops start at 1 so this needs to be set at 0 for proper x and y positioning? Again, more love2d logic is here and I'm not sure what this is all about either.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement