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

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.
Locked
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

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

Post 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
User avatar
TuxedoGlasses
Prole
Posts: 1
Joined: Thu Apr 02, 2015 12:00 pm

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

Post 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.
User avatar
Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

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

Post 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
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

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

Post 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.

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
User avatar
Jack Dandy
Prole
Posts: 49
Joined: Mon Sep 08, 2014 4:26 pm

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

Post by Jack Dandy »

Can anybody gimme some general tips about optimization that I can keep handy?
szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

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

Post 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.
User avatar
Jack Dandy
Prole
Posts: 49
Joined: Mon Sep 08, 2014 4:26 pm

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

Post by Jack Dandy »

What about ipairs()? Or are they generally the same?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post 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
Help us help you: attach a .love.
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

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

Post 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?
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

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

Post by bobbyjones »

I would think any drawable
Locked

Who is online

Users browsing this forum: Google [Bot] and 157 guests