
Kata Recurse
This is the approach that I currently use; it was pointed out to me that polling the state of the keys on every input is considered bad practice since it means that key clicks that happen in between physics updates don't get registered at all, hence why I wanted to use a more event-driven approach.
The idea of this approach is that the set of currently pressed keys is
constructed by the application loop, not the wire itself. Every event
triggers another step of the wire.
One problem with that approach is that the rendering may be much slower
than a wire step, so you get event congestion and thus delayed
responses. This suggests that it would pay off to handle all events in
a single instant, but that is much more difficult than it sounds. What
should a wire do, if in a single instant a key is pressed and released,
or if it is pressed multiple times?
A simple solution exists: Wires can deal with a time delta of 0, so
step the wire with dt = 0 for all queued events before you render the
next frame. There is nothing wrong with mixing this with sessions. In,
say, SDL terms, if the event is NoEvent, use stepSession* and render.
If it's any other event, use stepWire* and don't render.
Greets,
Ertugrul
--
Key-ID: E5DD8D11 "Ertugrul Soeylemez