Page 43 of 91

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

Posted: Thu Jan 28, 2016 5:03 pm
by unixfreak
I have a question about keyboard shortcuts (desktop specific) and keybinds within a love application.

For instance in a shoot-em-up style game, the player will be holding the fire/shoot key most of the time. If the key to pause the game is "escape", and the key to shoot is "rctrl" (a common control setup)... when they pause the game and "rctrl is held down -- it causes the desktop/os specific shortcut to run. For me, using the KDE desktop, it launches the system task manager (ctrl+escape) and minimizes the game.

Is there a way to give priority to love with these sorts of keybinds, or to ignore the desktop keyboard shortcuts?

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

Posted: Thu Jan 28, 2016 5:22 pm
by Nixola
Yup, it slipped my mind ^^`
Edited, thanks
Unixfreak: I don't think there's a way.

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

Posted: Thu Jan 28, 2016 5:47 pm
by zorg
Disable os-wide shortcuts, or remap them if the os allows you that, or remap the pause key to p or something if it doesn't.

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

Posted: Thu Jan 28, 2016 9:44 pm
by adge
Nixola wrote:Pairs doesn't have a defined order. If you need them to be printed in a specific order, use a sequence and ipairs. Two examples:

Code: Select all

--do this if you need textual indices in listy;
function love.load()
   listy = {first = 1, middle = 2, last = 3}
   order = {"first", "middle", "last"} 

   for i, v in ipairs(order) do
      print(v, listy[v]) 
   end
end


function love.update(dt)
end


function love.draw()
end

Code: Select all

--do this if you don't 
function love.load()
   listy = {1, 2, 3}

   for i, v in ipairs(listy) do
      print(i, v)
   end
end


function love.update(dt)
end


function love.draw()
end
Thank you! Thats it!

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

Posted: Sat Jan 30, 2016 8:46 am
by murks
murks wrote: I have a game idea that would require lots of small pieces flying around, but physics based or pseudo physics based. Can this also be achieved using a particle system or do I need to use an actual physics engine (or at least collisions and simplified physics) for each tiny thingy?
Any suggestions regarding that? I guess it boils down to the question whether a particle is just drawn or whether physics can be attached to it somehow.

If physics can only be attached to emitters then I guess I could use those, but it probably makes more sense to use a lot of tiny game objects than many emitters, each emitting only a few particles. Right?
I guess both approaches could work, but I guess the performance of 1000 emitters (with collision behaviour * 10 particles is worse than 10000 objects (with collision behaviour). Correct?

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

Posted: Sat Jan 30, 2016 7:35 pm
by bobbyjones
You most likely can not get the position of each individual particle so its probably not possible to add physics to them.

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

Posted: Sat Jan 30, 2016 8:38 pm
by murks
Thank you. It is something that concerns only a future game project, but how to do it comes up in my mind rather often. At the moment I think many small collision objects is the way to go.

A question concerning my current game (due end of February):
Imagine a top-down view, or slight perspective, and the scene full of coloured clouds (particle effects).
I want the player to only see the particle effects in the immediate vicinity of the player character. Ideally a fading circle would surround it in which the particle effects would be visible. Everything else should be visible all the time.

How to do it?
I imagine the emitters would be active all the time and blend modes could be used to this effect, but I have no experience using those. Or is something else like shaders needed?

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

Posted: Sat Jan 30, 2016 10:27 pm
by Tchey
Hello,

How can i print a score on my screen ? I can print words, i can print data, but i can't find how to print both, in one line.

I want to print for example :

Score : #, where # is joueur.score
I only manage to print either
Score
or
#
but not
Score : #

Fine :

Code: Select all

 love.graphics.printf(joueur.score, 50, 50, 400, "left")

Code: Select all

 love.graphics.printf("Score : ", 50, 50, 400, "left")
OK but not so nice :

Code: Select all

love.graphics.printf("Score = ", 50, 50, 400, "left")
love.graphics.printf(joueur.score, 110, 50, 400, "left")
Broken :

Code: Select all

 love.graphics.printf("Score : "joueur.score, 50, 50, 400, "left")


Thanks, tell me if my question is unclear !

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

Posted: Sat Jan 30, 2016 11:24 pm
by aloisdeniel
You want to print two consecutive texts on screen ?

You can simply concatenate your string :

Code: Select all

love.graphics.printf("Score = " .. joueur.score, 50, 50, 400, "left")
You also have more control with Text object (https://love2d.org/wiki/Text) which have methods for measuring the size of your text.

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

Posted: Sat Jan 30, 2016 11:26 pm
by zorg
Two ways:

Code: Select all

love.graphics.print("aaaa" .. v .. " bbb ")
love.graphics.print(("aaaa%s bbb"):format(v))
first uses the lua concat operator ..
second uses a string, inside parentheses so we can call string.format on it this way; %s is where v will be substituted, as a string, one can use other specifiers like %d or %f or whatever, %% escapes the % character itself.
These work with both print and printf as well.