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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
TheOdyssey
Citizen
Posts: 52
Joined: Mon Jul 13, 2015 4:29 pm
Location: Turn Around...

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

Post 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
Attachments
lag.love
(468.9 KiB) Downloaded 134 times
User avatar
Murii
Party member
Posts: 216
Joined: Fri Jul 05, 2013 9:58 am
Location: Arad, Romania
Contact:

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

Post 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.
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

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

Post 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
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot] and 9 guests