Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

If each player has their own avatar, that can move, jump, and do actions to entities in the world (let's say, boxes). How is it handled? Is clients sending commands to the server and getting the current state of the world in response a viable design?

share|improve this question

closed as off topic by Mark Trapp Aug 3 '11 at 2:18

Questions on Programmers Stack Exchange are expected to relate to software development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

It is viable. But do note that you have a trade-off. If you only send the information about the part of the world that is currently visible, latency and interactivity get hurt. If you send updates about the local area, usability is better but you face the possibility of people breaking your protocol and using it to generate compromised clients that can do things like see around corners. –  btilly Aug 3 '11 at 0:54
I think this question would get better answers on gamedev.stackexchange. Is there a mod around to move it? :) –  Tyanna Aug 3 '11 at 1:49
GameDev.SE would be where this is on-topic, but it's a pretty broad question. You should look at their multiplayer tag to see if your question is answered there before asking a more specific question. –  user8 Aug 3 '11 at 2:20
What does the "design patterns" item refer to in the faq then? –  Tamás Szelei Aug 3 '11 at 11:12

2 Answers 2

Is clients sending commands to the server and getting the current state of the world in response a viable design?

Broadly speaking, yes. Now, that changes a bit when you start talking about peer-to-peer systems, or real-time-strategy games with exponentially more entities and states to account for.

I highly recommend browsing some of the published documentation for Valve's Source engine as a starting point:

Notable features/optimizations include:

  • Client-side prediction
  • Interpolation of entities
  • Lag-compensation for instant-travel attacks
  • Using geometry information in the world to avoid sending data about things that are "out of sight".
share|improve this answer

Depending on your game you are going to need some communication between the client and the server. If your game doesn't need to be real-time then asking the state of the server from the client is a viable alternative.
If, however, you need more real-time capabilities you are going to want to look in to Socket Programming, especially using a language where the Sockets can send events.

share|improve this answer

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