Page 86 of 91

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

Posted: Sun Dec 11, 2016 5:22 pm
by paul54000
what's the difference beetwen particle and shaders effect ?

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

Posted: Sun Dec 11, 2016 9:59 pm
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)

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

Posted: Mon Dec 12, 2016 12:53 am
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.

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

Posted: Mon Dec 12, 2016 1:03 am
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?

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

Posted: Mon Dec 12, 2016 1:27 am
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

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

Posted: Mon Dec 12, 2016 4:47 am
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.

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

Posted: Mon Dec 12, 2016 9:07 am
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...

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

Posted: Mon Dec 12, 2016 5:03 pm
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.

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

Posted: Mon Dec 12, 2016 6:45 pm
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?

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

Posted: Mon Dec 12, 2016 9:00 pm
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?