Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to create a simple game that can be played with one to two player. I plan on using TCP sockets, Farseer Physics, XNA, a BinaryFormater and a Memorystream.

as far as i know i can't do the physics on both clients, or you'll end up with everything out of sync. So my Idea was to do the physics on the host side then send the Farseer World data to the other client, however it is un-serializable and I also realized this was a lot of data to send every tick.

I could just send the players movements back to the server and send a Texture2D to the client to be drawn, however a Texture2D is un-serializable as well. it has dawned on me i must be doing this completely wrong.

But this is how i am attempting to send the data:

[Serializable()]
class ServerData
{
    public Texture2D Test;

    public Vector2 Test2;
}

    static void SendData()
    {
        byte[] DataBuffer = null;

        MemoryStream stream = new MemoryStream();
        BinaryFormatter formatter = new BinaryFormatter();
        NetworkStream netStream = PlayerOneSocket.GetStream();

        ServerData ServerDataToSend = new ServerData();

        formatter.Serialize(stream, ServerDataToSend);
        DataBuffer = stream.ToArray();
        netStream.Write(DataBuffer, 0, DataBuffer.Length);
        netStream.Flush();
    }

what am i doing wrong or how do i do it right.

I've done basic server stuff before with custom classes and serialization, I'm just at a loss on how to make a multiplayer game.

Thanks for the help

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Send logical data, not presentation. Most games will never send graphics or textures to other systems during gameplay. Each system should already have all the resources it needs to render the events; you just send information about which events have taken place.

share|improve this answer
    
thanks, i actually just woke up about an hour ago thinking the same thing. But having clarification is really helpful :) –  Dusty May 28 '12 at 11:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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