0 Members and 1 Guest are viewing this topic.
function Player:tick(del) local floor,abs=math.floor,math.abs...
The point of localizing the math functions is to not having Lua access the math table. Here it's still being accessed at each tick You could simply put the local out of the function Sure, what you do is already better than nothing since the local version will be used for the loops calculations, but anyway, let's go all the way (and localize every math functions you use, btw, it can't be bad.)
occasionally parts of the screen go blank
I believe I don't have many things to say about the code layout, at least from what I quickly saw it looks well indented and pretty clear to read (classes and good (enough) seperation from code and paint )
What editor did you use, btw ?
(I may have a few optimizations, for example, you already make good things, like localizing things etc., but here is a mistake :Code: [Select]function Player:tick(del) local floor,abs=math.floor,math.abs...The point of localizing the math functions is to not having Lua access the math table. Here it's still being accessed at each tick You could simply put the local out of the function Sure, what you do is already better than nothing since the local version will be used for the loops calculations, but anyway, let's go all the way (and localize every math functions you use, btw, it can't be bad.)
local math=math
Also, I see you declare functions within the paint function... why ? I suppose you can just put them somewhere else (and add parameters if needed), so they just get defined once, that'll speed things up.
I understand, but wouldn't those variables be localized on a lower level, so that everytime when I call them on a higher level, they have to be loaded into the ligher level which takes time? Or do the different levels make no difference? What about just writing Code: [Select]local math=math at the beginning of the script, would then all math functions be as fast accessible as if I localize them individually?
And btw. I noticed that the localizing itself takes time, so if you call a math function only once, it seems be faster not to localize it.
*Bump* Has there been any progress on this?