Well, it's not true... Scissor prevents the images to be displayed, not the love.graphics.draw call, so the game slows down also (already tried). A good algorithm would be:
function draw()
x1 = 1 - math.ceil(camera_x / 32)
x2 = 15 - math.floor(camera_x / 32)
y1 = 1 - math.ceil(camera_y / 32)
y2 = 10 - math.floor(camera_y / 32)
if x1 < 1 then
x1 = 1
end
if x2 > self.wide then
x2 = map_wide
end
if y1 < 1 then
y1 = 1
end
if y2 > self.high then
y2 = map_high
end
-- Draw lower/medium tiles
for x = x1, x2 do
for y = y1, y2 do
-- Set tile coordinates
local ox = x * 32 - 16 + math.floor(camera_x)
local oy = y * 32 - 16 + math.floor(camera_y)
-- Draw tile
etc...
end
end
end
Where 32 is the tile width/height, 15 and 10 are screen width / tile width and screen height / tile height.
This algorithm's speed is not influenced by the width and height values of the map (in tiles)... You can try to compare my algorithm on a 1000x1000 map with a normal algorithm using setScissor(x, y, w, h), checking FPS with love.graphics.setCaption(love.timer.getFPS())
bartbes wrote:So your video card shares memory? Dare I say "lame"? Yes.
No it doesn't, but you make a good point, WTF.
It's a 9600GT, with 512MB of it's own memory, but I was using love.graphics, might have been under love.update, would that change where it's loaded too?
Maybe it's just that the decoded image stays in memory, even though creating new images every tame seems to imply you don't store references, which in turn should make the garbage collector eat (tm) the memory. Anyway, even if you need a lot of images spawned a lot, just use resource caching!