## inexplicable slowdown in draw loop

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
yarlesp
Prole
Posts: 9
Joined: Sun Apr 07, 2013 3:55 pm

### inexplicable slowdown in draw loop

Hi, I'm making a little strategy game about being a landlord in 19th century england. Right now I'm just trying to get the scrolling map working right. When the game was in a single file I didn't have problems, but when I re-designed the game to spread things out across several files I started running into serious slowdown issues. I can't click anywhere on my map without the game coming to a crawl. I think I've isolated the slowdown to this piece of code (when 'get_selected' returns nil the game runs smoothly) but I have some profiler output and the full source all the same.

This function is in main.lua and it calls a function in land.lua (land.get_selected)

Code: Select all

function draw_gui()
love.graphics.print("IT IS "..season[game.season].." CORN: 0  SEED CORN: 2  POPULATION: 10", 10, 5, 0, 1, 1, 0, 0)
if land.get_selected() then
love.graphics.print( land.get_selected(), 10, (display_h * tile_height) - 20, 0, 1, 1, 0, 0) --get selected
end
end
My guess is that it has something to do with the fact that I'm calling a function across two lua files, and I'm doing it a few times a second. I've thought about creating some sort of function that would pass the values back to main, where they would be stored as variables and then put into a string which would itself be passed to the gui function, so that the gui still gets drawn every second but it isn't constantly dereferencing. But that seems too complicated, surely it isn't supposed to be a huge deal to call a function from outside of its immediate context? I must be missing something obvious here. First week or so using lua btw so I'm sure it will be a bonehead mistake. Thanks for taking a look.

Here's the output from the profiler I had running, just for kicks: http://pastebin.com/raw.php?i=B0gXefP6

And I attached the game below. Left click to select a piece of land, right click to de-select, arrow keys to scroll around.
Attachments
corn.love
my game lol

Jackim
Prole
Posts: 12
Joined: Wed Apr 03, 2013 3:02 am

### Re: inexplicable slowdown in draw loop

I don't get any slowdowns, what are your specs?

yarlesp
Prole
Posts: 9
Joined: Sun Apr 07, 2013 3:55 pm

### Re: inexplicable slowdown in draw loop

win 7 64bit, 6gb ram, amd athalon x2 250, radeon 6800

but to be honest this code should run fine on a pentium 2. It doesn't seem that intense

Xgoff
Party member
Posts: 211
Joined: Fri Nov 19, 2010 4:20 am

### Re: inexplicable slowdown in draw loop

i'd make sure your graphics drivers are updated, just to rule that out.

other than that, there's nothing immediately obvious as to what would cause that much slowdown. i'd watch your variable usage in the land.lua file; you have a ton of globals that probably should go into the land table instead

Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

### Re: inexplicable slowdown in draw loop

I'm running much lower specs and it's going fine with no slowdown on anything. Might very well be a driver issue.

yarlesp
Prole
Posts: 9
Joined: Sun Apr 07, 2013 3:55 pm

### Re: inexplicable slowdown in draw loop

Well the driver update did actually solve the problem. Thanks guys. Hopefully next time I'll have a more interesting question.

### Who is online

Users browsing this forum: Google [Bot] and 10 guests