Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 lordsurya08   Members   -  Reputation: 102

Like
0Likes
Like

Posted 05 August 2012 - 04:39 PM

Hi,

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, 05 August 2012 - 06:39 PM.


Sponsor:

#2 6677   Members   -  Reputation: 1054

Like
1Likes
Like

Posted 06 August 2012 - 03:44 AM

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.

#3 Goran Milovanovic   Members   -  Reputation: 1104

Like
0Likes
Like

Posted 07 August 2012 - 11:13 PM

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, 07 August 2012 - 11:14 PM.

+---------------------------------------------------------------------+

| Game Dev video tutorials  ->   http://www.youtube.com/goranmilovano |
+---------------------------------------------------------------------+




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS