Hi Micha,micha wrote:I suppose you have a table with to indeces, with all the tiles in it. If this is the case, you can shorten the iteration by using the two-index structure. So lets say you have a table with two indices, containing information on what tiles have to be drawn: tile[x][y]. For a whole loop you would do two nested for loops for x and y each from 1 to the respective maximum. You can shorten these loopes, if you know the camera position. From the camera position, first determine the (tile)-coordinates of the first tile in the upper left corner and of the last tile in the lower right corner. These tile coordinates can now be used as the start and the end of the for loops. That way, the number of table entries to consider will never be larger than the number of tiles visible on screen.Pash wrote:I think larger table iterations are killing my performance. We are talking 100,000's of table items to look through.
So you mean something like this:-
for i,v in ipairs(tablename) do
logic for x match up to camera x pos
for i,v in ipairs(tablename) do
logic for y match up to camera y pos
end
end
Im guessing this is what you mean?
Cheers,
Pash
Cancel That. I get what you mean.