When does love.keypressed actually run?

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

Re: When does love.keypressed actually run?

Post by s-ol » Mon May 04, 2015 11:50 pm

parallax7d wrote:
S0lll0s wrote:
Whenever the user does something, an event is sent into the queue. At the start of every loop, the whole queue is applied to the callbacks in order; That means as far as love.keypressed and love.mouseclicked are concerned, you can pretend the events are completely real-time, you cannot select entity A, hit delete and select entity B before A gets deleted and mess up the input.
cool, I got that now, thanks for elaborating
S0lll0s wrote: I just ran a quick test and when I type as fast as I absolutely can there are still a minimum of 5 frames between letters (for hello). I can't manage to type the same key twice in under 7 frames.
Well, that depends on the time between frames :3
at 60fps (vsync)

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
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: When does love.keypressed actually run?

Post by I~=Spam » Tue May 05, 2015 3:30 am

I am not sure if it is possible for a person to hit 60 keys per second. :P
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: When does love.keypressed actually run?

Post by bartbes » Tue May 05, 2015 8:37 am

parallax7d wrote: I figure the fastest APM in the world is 818 = 13.6 actions per second. I guess as long as the fps of the game stay above double that, the chances for a lost command are tiny. It's just so annoying when it does happen!
But when would an action get lost? It wouldn't! It would just be applied the next frame.

Muris
Party member
Posts: 131
Joined: Fri May 23, 2014 9:18 am

Re: When does love.keypressed actually run?

Post by Muris » Wed May 06, 2015 4:47 am

If you are making a rhythm based game, you might run into problems with the accuracy. If you consider normal 60fps, its way too inaccurate for rhythm based games, meaning you probably have to make some way polling of keys actually work on separate thread outside of draw / update functions. I am not really sure how it would go though, but that seems to be the only really viable way of being able to read the keypress more often or removing Vsync could also work, but that doesn't seem the best solution out there.

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: When does love.keypressed actually run?

Post by Robin » Wed May 06, 2015 8:04 am

You would need to define a valid time range anyway, because no way human reaction time is more precise than 60FPS, so I don't think that's necessary.
Help us help you: attach a .love.

Muris
Party member
Posts: 131
Joined: Fri May 23, 2014 9:18 am

Re: When does love.keypressed actually run?

Post by Muris » Wed May 06, 2015 4:48 pm

Robin wrote:You would need to define a valid time range anyway, because no way human reaction time is more precise than 60FPS, so I don't think that's necessary.
Maybe the quote itself was not a reply for my rhythm based games, rather than a general answer, but regardless:

Quick searching shows that some versions of Stepmania have 22.5ms time window for marvelous, so that would be +-11ms and it seems that some DDRs have even smaller time window, thus 17ms interval for reading keypresses are far too infrequent for rhythm type of games. The thing is, rhythm game does not base on reaction, rather than prediction and memorizing when to press a button. Also the more constant the delay is, the better it is for rhythm games.

Altho I agree that in most cases the small delay wont matter much, but when it comes to competition such as fps or other very reaction type of a game, the other player using 60fps, and thus 60 times scanning inputs vs other person vsync off and having 200 fps for example, the person who has 200 updates per second might gain a slight edge, depending on a game.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests