Page 32 of 91

Re: "Questions that don't deserve their own thread" thread

Posted: Fri Apr 03, 2015 3:52 am
by bobbyjones
@Naseem142 The way i used to handle buttons when i was starting out was to make a button table inside a table.

Code: Select all

function callback1()
    print("button1")
end

function callback2(
    print("button2")
end
buttons = {{ x = 10, y = 10, width = 100, height = 100, callback = callback1 }, { x = 20, y = 20, width = 25, height = 27,  callback = callback2}}
When whenever i wanted to use this data i used a for loop.

Code: Select all

for i,button in ipairs(buttons) do
    --do stuff with the button
end
And for simplicity i made functions to handle all of this.

Code: Select all

function newButton( x, y, width, height )
    table.insert(buttons,{ x = x, y = y, width = width, height = height }
end

function buttonClicked( mouseX, mouseY )
    for i,button in ipairs(buttons) do
        if mouseX > button.x and mouseX < button.x + button.width and mouseY > button.y and mouseY < button.y + button.height then
            button.callback()
        end
    end    
end
The same can be done for drawing and updating just add more functions to the table. I hope i helped

Re: "Questions that don't deserve their own thread" thread

Posted: Fri Apr 03, 2015 11:18 pm
by TuxedoGlasses
So how do you install multiple versions of the very framework?
Because there are mods of Mari0 I want to try out, yet they require 0.8.0.

Re: "Questions that don't deserve their own thread" thread

Posted: Sat Apr 04, 2015 9:38 am
by Doctory
TuxedoGlasses wrote:So how do you install multiple versions of the very framework?
Because there are mods of Mari0 I want to try out, yet they require 0.8.0.
try deinstalling love then install 0.8.0 from here: https://bitbucket.org/rude/love/downloads

Re: "Questions that don't deserve their own thread" thread

Posted: Sat Apr 04, 2015 12:53 pm
by s-ol
TuxedoGlasses wrote:So how do you install multiple versions of the very framework?
Because there are mods of Mari0 I want to try out, yet they require 0.8.0.
Just install both to different locations, make sure the one you want to use usually is the one that appears first in PATH and when you want to play Mari0 just drag it onto the 0.8.0 exe.

Re: "Questions that don't deserve their own thread" thread

Posted: Tue Apr 21, 2015 3:32 pm
by Jack Dandy
Can anybody gimme some general tips about optimization that I can keep handy?

Re: "Questions that don't deserve their own thread" thread

Posted: Tue Apr 21, 2015 7:00 pm
by szensk
Jack Dandy wrote:Can anybody gimme some general tips about optimization that I can keep handy?
1) Fast algorithms: don't use an O(n^2) when there is an O(n log n) algorithm out there.
2) Spritebatches: the reduced draw calls improves performance greatly.
3) Don't use pairs() unless you must.
4) Use locals: this is minor but it can add up if you're using globals everywhere.

I listed them in order of the most likely gains. If you think you have minor problems everywhere see here.

Re: "Questions that don't deserve their own thread" thread

Posted: Tue Apr 21, 2015 7:14 pm
by Jack Dandy
What about ipairs()? Or are they generally the same?

Re: "Questions that don't deserve their own thread" thread

Posted: Tue Apr 21, 2015 10:15 pm
by Robin
Honestly, it should be:
  1. Algorithmic complexity
  2. Things like spritebatches and canvasses
  3. If it's still too slow, measure what takes the most time, and what saves the most time.
  4. Everything else

Re: "Questions that don't deserve their own thread" thread

Posted: Mon May 04, 2015 9:01 pm
by parallax7d
What types can quad be used on?

SpriteBatch and Image I know for sure, how about these types;

Canvas, Framebuffer, Mesh, ParticleSystem, Quad, Texture?

Re: "Questions that don't deserve their own thread" thread

Posted: Mon May 04, 2015 11:34 pm
by bobbyjones
I would think any drawable