Move Towards Cursor

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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Move Towards Cursor

Post by Robin »

nevon wrote:I'm definitely no Lua expert, but that's my understanding of it also. I'm currently looking through my code, trying to change some global variables into local ones instead, in the interest of performance. However, I've found that I can't really use that many local variables, since a lot of the stuff that I initialize in love.load() or love.update() is needed in love.draw() as well.
If you are a performance junky, this:

Code: Select all

function foo()
    local sin = math.sin
    for k,v in pairs(x) do
        x[k] = sin(v)
    end
end
is faster than:

Code: Select all

function foo()
    for k,v in pairs(x) do
        x[k] = math.sin(v)
    end
end
So if you use certain globals a lot in functions that don't set it you can do this.
Help us help you: attach a .love.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Move Towards Cursor

Post by nevon »

Robin wrote:If you are a performance junky, this:
I'm not a performance junky at all (if I was, my code wouldn't look like it does... Trust me). But I'm not crazy happy with my game's performance right now, and I still have a lot more math that needs doing before the game is complete. Every little bit helps.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests