Open crazy2be opened 11 years ago
Could be useful, but for the controls.every, in the case of shooting, we must keep it serverside validated. That would just be fore animation / sound repeating.
We might think of applying this paradigm to the server code, as in not sending Controls, but just sending data when the state changes. Then the server could hook into specific messages.
I noticed a fair bit of code that does things like:
We could allow this code to be rewritten as
And move the bookkeeping to controls.js.
I've been thinking about this for a bit now, I think the API should be something like:
controls.on(action, callback)
: Runs a callback when action is pressed (i.e. goes from a non-activated state to an activated state).controls.while(action, callback)
: Runs a callback every frame that action is down.It might even be nice to have some sort of
controls.every(1000 /*ms*/, 'fire', fireGun)
timer-integrated API, but I'm not totally sure how to do that properly.Thoughts?