ecj2 / momo

[NOT MAINTAINED / ABANDONED] A simple 2D game-making library written in JavaScript.
MIT License
1 stars 0 forks source link

Clear inputs outside of the main procedure #5

Closed ecj2 closed 6 years ago

ecj2 commented 6 years ago

Mouse and keyboard states are stored in arrays which are cleared every frame in Momo.createLoop(). In the future, I would like Momo to allow separate timers to be used for updating and rendering. To allow for this, the inputs should be cleared elsewhere and not be dependent upon the main rendering procedure.

ecj2 commented 6 years ago

After doing a bit of testing, I have concluded that this is not reasonably feasible.

Clearing inputs outside of the rendering procedure results in inconsistent input timing when checking key and button states. This is true if the input timer does not match the timing of the update and/or rendering functions that rely upon said inputs.

In other words, the inputs must be interfaced with in a strict order: capture, use, and then clearing; but mismatching timers result in that order occasionally being broken.

I can think of one or so convoluted workarounds, but their inclusion would bog the system down and muddy the interface more than anything. Therefore, this pursuit should be disbanded.