Help with game lag

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
SpotlightKid
Prole
Posts: 6
Joined: Mon Nov 10, 2014 7:57 am
Location: Cologne, Germany

Re: Help with game lag

Post by SpotlightKid »

Muris wrote:I honestly think the worst thing about LUA is the fact that instead of crashing, it actually makes global variables by default unless especially told not to aka local. [...] I have a gut feeling that if the project size grows, the probability of me not being able to track bugs that comes from having accidentally created globals, and not being able to find a bug in my program.
Maybe these can help:

http://www.luafaq.org/index.html#T1.6
http://lua-users.org/wiki/DetectingUndefinedVariables
http://www.lua.org/extras/5.1/strict.lua
http://thomaslauer.com/comp/LuaStrict
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Help with game lag

Post by kikito »

Lafolie wrote: From what I've read there is actually little impact using globals over locals[...] They're mostly recommended because it helps to 'keep the scope clean' and makes your code somewhat easier to maintain
@Muris: I strongly suspect that Lafolie is referring to locals in that last phrase("locals are recommended because they keep the scope clean), but he ended up saying the opposite of what he meant.
The reason why I decided to go with libgdx on my project is mostly because I have a gut feeling that if the project size grows, the probability of me not being able to track bugs that comes from having accidentally created globals, and not being able to find a bug in my program.
I have used luacheck to detect unused/global variables in my code with good success recently. It does static analysis of your code, so it can warn you about these issues before run-time.
When I write def I mean function.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Help with game lag

Post by bartbes »

kikito wrote:but he ended up saying the opposite of what he meant.
Not even that, he was already talking about locals, all the way through.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Help with game lag

Post by s-ol »

Muris wrote:
Lafolie wrote:
jjmafiae wrote: tip 4: use locals and remove any unused globals
makes your code somewhat easier to maintain.
Globals and easier to maintain code doesn't really sound like something I would put together in most cases, unless you are 100% sure that you know exactly what you are doing. I honestly think the worst thing about LUA is the fact that instead of crashing, it actually makes global variables by default unless especially told not to aka local.

The reason why I decided to go with libgdx on my project is mostly because I have a gut feeling that if the project size grows, the probability of me not being able to track bugs that comes from having accidentally created globals, and not being able to find a bug in my program. The other reason is that I feel that debugging in java is easier, but there could be good tools for lua too.

Still I honestly think that Love2D is probably the best 2d engine I have seen so far, and most productive thing I've found.
You should try zerobrane studio, it has full in-code stepping, breakpoints, a REPL and can do livecoding!

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: Help with game lag

Post by jjmafiae »

Guys I found this a while ago: http://www.lua.org/gems/sample.pdf
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests