Wednesday, November 23, 2011

Learning to Network

Hey everybody and welcome back for another development update on MEDUSA. In this post, I want to talk about networking and our experiences thus far. From the beginning of development we knew we wanted to achieve networking for MEDUSA to allow cooperative play with friends. A previously built prototype had 2 player cooperative play but only with with a single split-screen that greatly hindered field of view.

The major hurdle that our team had to clear was that no one had any experience with network programming. So myself and another programmer on the team, Luis Lairet, began researching on the subject to look for a starting point. Luis found a great website with articles written by Glenn Fiedler, a programmer in the industry for over 10 years and currently senior programmer at Sony Entertainment. You can find the link to his webpage at the bottom of this post and you should check it out for some some great articles on networking and physics programming. He does a great job at explaining the principles and basics while providing easy to follow tutorials.

Our Assistant Producer, Rob Martinez, also suggested that we seek the help of Darryl Malcomb, the Game Networking teacher here at Full Sail University. Our team sat down with Darryl and he was a great help in explaining some structural details for our network and the best methods of packet transfer for our needs. All of this help started us on our way and we have been making exciting progress ever since.

Today, we have our network set up with a Lobby system that is entered when players are ready to play. The Client Lobby state looks for active servers to connect to while the Server Lobby state listens for incoming connections to store. The packets of data that we send are constructed using basic structs that have a header to describe the message type and the Client that this message belongs to, along with any other information particular to that message. The basic running pattern of our game will be:

  • Client sends Input message to the Server
  • Server reads the message, using the input to compute positions and check for collisions between objects
  • Server sends a snapshot back to every connected Client with all updated object data like positions and player health/ammo
  • Client reads the snapshot message and draws all objects to the screen with the new data

The server will also send messages such as a 'Play Sound' message that the client will read and perform the proper action.

Currently, the Lobby states are connecting and allow the player to choose a character on the Client Lobby. The server also stores Client information so that if Player 2 disconnects, they will be reconnected as Player 2 again.

That's it for this post. The next step is for all objects in the game to be updated through the network and tweaks to the communication during gameplay. Stay tuned for more updates and thanks for reading!

Glenn Fiedler - Programming Website

0 comments:

Post a Comment