"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
paul54000
Prole
Posts: 22
Joined: Mon Nov 28, 2016 12:19 am

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

Post by paul54000 »

what's the difference beetwen particle and shaders effect ?
User avatar
partnano
Prole
Posts: 20
Joined: Sat Jun 11, 2016 4:53 pm
Location: twitter.com/partnano
Contact:

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

Post by partnano »

So, I have no idea if this was asked already somewhere and honestly, I don't even know if it's my system, love, or plainly me.

So, take this code: (sorry for the moon)

Code: Select all

love.draw = ->
    if grab_mode
        g.print "Grab Mode", 10, 40
        grab_mode = false

love.update = (dt) ->
    if k.isDown "space"
        grab_mode = true        
Simple enough right?
The problem I have is that, when I now press space (or any button really) for a bit longer, it will work correctly for the time I have space down, then, when I release it, it will still register as isdown for a while, however quickly switching around between down and up (as if I would press the key really really quickly). The longer I keep the key down, the longer the repeat is happening afterwards.

Any ideas of what's happening? Shouldn't, as soon as I release the key, grab_mode be false? What am I missing?

(I'm on Linux btw.)
(I also have tried a version with on love.keypressed -> grab_mode = true / love.keyreleased -> grab_mode = false with the same phenomena)
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

paul54000 wrote:what's the difference beetwen particle and shaders effect ?
They are completely different.

Particles are sprites that Löve controls according to the parameters you give. Try e.g. APE to edit them (there was another recent particle editor but I don't have the URL handy)

Shaders are OpenGL-based programs that you write in GLSL ([open]GL Shader Language).

See http://blogs.love2d.org/content/beginners-guide-shaders for an introduction to one of the kinds of shaders.
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

Sorry for the double post. This thread kind of invites it.
partnano wrote:The problem I have is that, when I now press space (or any button really) for a bit longer, it will work correctly for the time I have space down, then, when I release it, it will still register as isdown for a while, however quickly switching around between down and up (as if I would press the key really really quickly). The longer I keep the key down, the longer the repeat is happening afterwards.

Any ideas of what's happening? Shouldn't, as soon as I release the key, grab_mode be false? What am I missing?
Sounds like auto-repeat goes faster than your frame rate, and the events keep piling up in the event queue. I don't know why that happens; I would have said that all pending events should be processed at once every frame.

How many FPS does your program have? Does disabling vsync help?
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

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

Post by Positive07 »

Why aren't you using [wiki]love.keypressed[/wiki] and [wiki]love.keyreleased[/wiki] which are actually triggered on pressing and release? They are there so that you can easily switch state.

[wiki]love.keyboard.isDown[/wiki] is there for things that are updated constantly like player movement which doesn't really change abruptly with the state of the key.

Still as pgimeno said, you may still have problems if the repeat is too high, or vsync interferes, or a frame takes too much time. Put [wiki]love.keypressed[/wiki] and [wiki]love.keyreleased[/wiki] should be called for each event... so you shouldn't find problems there
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post by zorg »

Unless you're creating a typing game (and imo even then) i'd recommend disabling keyrepeat, because it's horrid for a game; just code it yourself (set a key to true in love.keypressed, false in love.keyreleased, and in update, check the state and do stuff with it; should work fine), and then the OS's one won't interfere with yours.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
partnano
Prole
Posts: 20
Joined: Sat Jun 11, 2016 4:53 pm
Location: twitter.com/partnano
Contact:

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

Post by partnano »

Positive07 wrote: Still as pgimeno said, you may still have problems if the repeat is too high, or vsync interferes, or a frame takes too much time. Put [wiki]love.keypressed[/wiki] and [wiki]love.keyreleased[/wiki] should be called for each event... so you shouldn't find problems there
First off, thanks for the replies!

Yeah, apparently my auto-repeat is a bit too fast for the event queue...
However, I got the same problems with keypressed/keyreleased (tried the exact version you mentioned as well with the same problems)

Is there a way to turn off the OS auto-repeat for love? All I could find was love.keyboard.setRepeat, which should be off by default, as far as documentation says.

With vsync off it kinda works, but then (both versions, keypressed/keyreleased) the key doesn't register consistently and flickers off every few frames, which is kinda strange as well?

By now I'm mainly curious of what's happening, I can obviously work around it...
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

partnano wrote:With vsync off it kinda works, but then (both versions, keypressed/keyreleased) the key doesn't register consistently and flickers off every few frames, which is kinda strange as well?

By now I'm mainly curious of what's happening, I can obviously work around it...
That kind of sounds as if your keyboard driver is for some reason sending keypressed/keyreleased events on every key repeat. Can you add a counter that counts the keyreleased events when you hold a key pressed, and tell us if it increases?

By the way, this question did deserve its own thread. I'll ask the moderators if it can be split.
User avatar
partnano
Prole
Posts: 20
Joined: Sat Jun 11, 2016 4:53 pm
Location: twitter.com/partnano
Contact:

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

Post by partnano »

pgimeno wrote:That kind of sounds as if your keyboard driver is for some reason sending keypressed/keyreleased events on every key repeat. Can you add a counter that counts the keyreleased events when you hold a key pressed, and tell us if it increases?
Well, it most definitely has something to do with the keyrepeat, both keypressed and keyreleased counters stay the same, they are both increasing while I'm holding down the key (shouldn't they both just trigger once on one keypress?) and both continue to increase for a while after releasing the key as well, in the same speed as when holding the key.

Welp, didn't think this would be such an .. issue haha
I'll keep it here for now, unless a separate thread really is requested?
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

Yes, normally only keypressed increases while you hold the key, and keyreleased only does when you release it. And then keypressed only gets repeats when you set love.keyboard.setKeyRepeat(true). Something's fishy with the keyboard driver. Or maybe with the keyboard itself. What's your CPU? ia32? ia64? Others? What distro? What's your keyboard model? Are you using xkb?
Locked

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 10 guests