Lydzje / lynput

Lynput is an input library for LÖVE that makes input handling very easy and intuitive :blue_heart:
MIT License
38 stars 2 forks source link

Implement delay modifiers #5

Open HugoBDesigner opened 5 years ago

HugoBDesigner commented 5 years ago

This might be a bit advanced and wouldn't work as intuitively as the other features (at least not the way I see it), but it'd be very interesting and useful if we could have control over how long an input has been pressed for. Some examples would be of an input that only fires if you hold a key for N seconds (a powerup/boost attack, or a dash, or a heavy action). Syntax could be something like this:

control:bind(
    "longFire",
    {
      "hold z for 5"
    }
  )

This would fire if, and only if, the key had been held for at least 5 seconds, and would continue outputting until it's released.

Another example would be to only let a key be held for N seconds, then forcibly "release" it. This could be useful to control stuff like long-distance jumping, or lifting a heavy object.

control:bind(
    "heavyPickup",
    {
      "press x after 5"
    }
  )

Perhaps the two properties could be combined, though personally I don't see a use for that. One last suggestion, which I'm also not particularly fond of (but still useful for game developers), would be to allow rapid key-pressing within an interval. With this option, players would have to continuously press a key for an action to take place. You'd only need to set the "keypress interval" and it'd correct for when the player presses/releases it, resetting the timer. Could be used in quicktime events, or making a character turn a valve, or a hacking sequence.

control:bind(
    "rotateHandle",
    {
      "press x every 0.5"
    }
  )

I believe these could be combined, but doing so in an intuitive and elegant way might be a challenge. There are also other, more nuanced ways in which timing could be useful and these suggestions wouldn't attend. Regardless, this is a very neat library with or without this feature!

Lydzje commented 5 years ago

Thank you so much for your suggestions @HugoBDesigner. I'have thought to implement some options for "hold" later, but I didn't thought about other modifiers or a more general "delay/timing modifier system". That's a really good idea and it's definitely going to be implemented.