Assume a client-server game where there server manages all state and the clients are simply rendering / input.

How much should I bake user input from the client before sending it off to the server?

Does it make sense to send "jump" or "space keydown"?

I'm inclined to bake the input as much as possible. Am I setting myself up for pain later?

  • \$\begingroup\$ What kind of game are we talking about? \$\endgroup\$ – Nitram Apr 6 '12 at 23:21
  • \$\begingroup\$ Do you want your game to support key remapping? \$\endgroup\$ – Kai Apr 7 '12 at 3:32
  • \$\begingroup\$ @Nitram, I thought the question wouldn't have a genre specific answer. Either way, side view worms/scorched earth genre. \$\endgroup\$ – deft_code Apr 9 '12 at 18:27
  • \$\begingroup\$ @Kai, I don't know :). Ostensibly yeah it will support every feature. In practice YAGNI, or its more vicious cousin YAGHT(you-aint-gonna-have-time). Will the answer be significantly different if user configurable controls are required? \$\endgroup\$ – deft_code Apr 9 '12 at 18:31

I'd send "jump", reason being that it applies to each keyboard, gamepad, and AI. "space keydown" might be useful in some cases, but I can't think of any right now.

  • \$\begingroup\$ +1. You always want to abstract over the details of user input on the client machine. \$\endgroup\$ – DeadMG Apr 7 '12 at 11:44

Speaking from MVC perspective, the client would be the View and the Controller, and the server would run the Model. One of the job of the Controller is to translate raw user input into model-appropriate input (i.e. Spacebar to Jump). Doing it this way will allow the client/controller to easily do key remapping, write alternative controller, and write alternative client (e.g. you might want a mobile-version and a desktop-version playing in the same server; with the controller translating them to mode-appropriate input, you woouldn't need to modify the server to add them).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.