Search found 478 matches

by Azhukar
Fri Nov 10, 2017 2:42 pm
Forum: General
Topic: Local iterator functions slower than global?
Replies: 14
Views: 2957

Re: Local iterator functions slower than global?

To clarify, I didn't mean "localize it right before using it".

See http://wiki.luajit.org/Numerical-Comput ... ance-Guide the part about "Do not try to second-guess the JIT compiler."
by Azhukar
Fri Nov 10, 2017 2:16 pm
Forum: General
Topic: Local iterator functions slower than global?
Replies: 14
Views: 2957

Re: Local iterator functions slower than global?

I would still test how fast localizing ipairs, pairs and next is when the locals used have the same names ... pairs() and ipairs() are called exactly once per loop, to generate the 3 variables used by the for loop. You'd save at most a single index operation on _G per loop. next() is called each it...
by Azhukar
Fri Nov 10, 2017 11:45 am
Forum: General
Topic: Local iterator functions slower than global?
Replies: 14
Views: 2957

Re: Local iterator functions slower than global?

http://wiki.luajit.org/Bytecode-2.0#calls-and-vararg-handling Note: The Lua parser heuristically determines whether pairs() or next() might be used in a loop. In this case, the JMP and the iterator call ITERC are replaced with the specialized versions ISNEXT and ITERN. ISNEXT verifies at runtime tha...
by Azhukar
Wed Nov 08, 2017 2:20 pm
Forum: Support and Development
Topic: math help
Replies: 5
Views: 1273

Re: math help

Here's a function that takes 2 points and rotates one around the other. local function rotatePoint(cx,cy,px,py,angle) local s = math.sin(angle) local c = math.cos(angle) px,py = px-cx,py-cy return px*c - py*s + cx,px*s + py*c + cy end function love.draw() local cx,cy = 100,100 --center of rotation l...
by Azhukar
Sun Nov 05, 2017 2:06 pm
Forum: Support and Development
Topic: Inaccurate results from Font:getWidth()
Replies: 10
Views: 2558

Re: Inaccurate results from Font:getWidth()

Played around with the undocumented rasterizer, managed to draw the actual outline of a letter. local testFont = love.graphics.newFont("Power.ttf", 128) local rasterizer = love.font.newRasterizer("Power.ttf",128) local glyphData = rasterizer:getGlyphData("A") for k,v in pairs(getmetatable(glyphData)...
by Azhukar
Sun Nov 05, 2017 12:19 pm
Forum: Support and Development
Topic: Inaccurate results from Font:getWidth()
Replies: 10
Views: 2558

Re: Inaccurate results from Font:getWidth()

Post the font I'll give it a shot.
by Azhukar
Wed Nov 01, 2017 12:13 am
Forum: Support and Development
Topic: Trouble generating string-based seeds
Replies: 2
Views: 665

Re: Trouble generating string-based seeds

Repeated string concatenation produces a lot of garbage for the garbage collector, work with bytes or use table.concat Here's a very bad string hashing function local maxSeed = 2^30 local function stringToSeed(s) local seed = 1 for i=1,s:len() do seed = (seed*31337 + s:byte(i))%maxSeed end return se...
by Azhukar
Mon Oct 30, 2017 12:46 pm
Forum: Support and Development
Topic: Anim8 Walking Animation using keys returning nil
Replies: 2
Views: 728

Re: Anim8 Walking Animation using keys returning nil

Code: Select all

function love.update(dt)
	if love.keyboard.isDown('a') then
		current_animation = animations.left
		current_animation:update(dt)
	end
end
Read https://github.com/kikito/anim8