Page 1 of 1

Lag lag lag. No idea why framerate is dipping so low

Posted: Sat Dec 19, 2015 11:58 pm
by TheOdyssey
Something I'm doing is causing very low frame rates to happen. I'm almost entirely sure it's being caused by

Code: Select all

for y=1, #currentMap do
		for x=1, #currentMap[y] do
        if currentMap[y][x] == 1 then
          walls[#walls+1] = wall(x*10, y*64)
        end
		end
	end

  for i, wall in pairs(walls) do
    wall:draw()
  end
in love.draw() but I don't know how to do it in a more efficient way. Any suggestions? Thanks

Re: Lag lag lag. No idea why framerate is dipping so low

Posted: Sun Dec 20, 2015 12:07 pm
by Murii

Code: Select all

for y=1, #currentMap do
      for x=1, #currentMap[y] do
        if currentMap[y][x] == 1 then
          walls[#walls+1] = wall(x*10, y*64)
        end
      end
   end
You need to find a way of putting this into a load method and from there based on tiles position draw them using spritebatches or using simple images.

Re: Lag lag lag. No idea why framerate is dipping so low

Posted: Sun Dec 20, 2015 1:22 pm
by MadByte
You should avoid to generate all your tiles every frame.
here is another way to create your map. It demonstates the usage of an canvas and how to re-generate the map.
canvasMap.love