Jump to content
  • Advertisement
Sign in to follow this  

Picking a client/server model for a Networked Game (first post)

This topic is 2200 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I am a programmer of intermediate experience and I want to create a networked game. I can not decide what sort of "model" I should pick for this game. Currently, this is the model that I am thinking of:

Imagine there are four guys - User, John, Bob, and Server. Server is the guy controlling the game.

  • User is sitting at his computer playing the game. He clicks his mouse.
  • John is the program on User's computer who detects the mouse click. He doesn't know what it means, but he knows that he's supposed to send it to Bob.
  • Bob is at the server's end. He, like John, knows nothing about the click but he knows how communicate with John. He picks up the mouse click and gives it to Server, telling him it came from User.
  • Server is the brains. He interprets the mouse click and changes something in the game.
  • Every (say) 30 milliseconds, Server renders the game. He knows where User's camera is pointed and so he generates an image which should appear on User's screen.
  • Server doesn't know how to send it to User, so he gives it to Bob.
  • Bob sends the image to John.
  • John doesn't understand the image but he displays the image on the screen.

    Now, this is a 2 player game so I don't anticipate the server having issues processing all User requests. I would like to hear your feedback on this model. Is it good? If not, what are some alternatives? Edited by lordsurya08

Share this post

Link to post
Share on other sites
Never render an image server side. You should only be sending data about things like player position or score back and forth and then letting the clients deal with the rendering. If I was playing at 1900x1200 or some other massive res then the servers got to render EACH frame and send it back to the client over the internet, very slow. Instead if I send some plain text data about where my character is (and every other client does too) then the server can send a small list of where each character is located back to each client (might just be a few lines of text) and then the client can render it.

With 2 players you can probably use a peer to peer network (ie both clients communicate directly with no server in between) Assuming a FPS (probably isn't but its an example) you can just send an XYZ location plus the angle player is looking on, what weapon is equipped, if he is firing or not and which player skin he is using (an integer should suffice assuming all skins on both clients are the same). This would be a tiny amount of data which the other client can use to spawn the correct character model in game at the start of a round and then use to update its location, based on how much the co-ordinates have changed you can calculate the speed of movement to then correctly render slow walk/fast walk/sprint animation cycles.

Share this post

Link to post
Share on other sites
With 2 players you can probably use a peer to peer network (ie both clients communicate directly with no server in between)

Even for simple games with only a few clients, it's much easier to use the client server model than any kind of P2P setup - You don't need to have a dedicated machine to act as the server; You can pick one of the available peers (preferably one with the highest available resources to play the "host").

Having a designated authority can help remove a whole slew of sync/validity issues. P2P would just needlessly complicate things.

I actually did a video tutorial on a very simple client server model, using the Blender Game Engine (all the code is python):
Edited by Goran Milovanovic

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!