# Simple Tanks game - Client-Server communication approach doubts [closed]

I want to create simple a multiplayer 2D game with tanks ( cooperative ) in C# with .NET. I also want to keep it simple, because it is only a semester project, and unfortunately i don't have time to learn additional game engines like Unity.

So, can i do it without Unity, XNA or other game engine ? If yes, here is an architecture/design problem that i am facing: How should i notify the two players regarding the position of the other player on the map, the position of the bullets and the position of the enemies ?

1. Should i query the server at 50-100 ms intervals and get a list of JSON messages containing positions and states ( a tank exploded ) ?
2. Should i send a message from server regarding a bullet let's say, bullet no.1 started from x,y heading on axis y, then in the client, i will draw it until i will receive like an interrupt in case it hits an obstacle ( a tank that was passing by) ?

The first option seems more simpler, but it will kill the server in a real life ( 100000 players ) situation. The second seems like on overkill and over-engineering from client side.

Any other suggestions ? Thanks

• possible duplicate of What's an efficient way to represent game state for networked games? – Anko Apr 16 '15 at 20:03
• I made a game just like that and tried both approaches for educational purposes. Your analysis is correct: Sending the full game state many times a second is simpler but slower. Sending only minimal deltas is more complex but faster. However, in all likelihood, you won't have 100 000 players. I recommend using the simpler option and optimising later if it turns out to be necessary. – Anko Apr 16 '15 at 20:04

## 1 Answer

First, lets get this out of the way, aiming for 100k user is ridiculous for semester project. Aiming for 100k users playing in one physical server is insane for any game.

XNA is not an engine and no where near as high level as Unity. XNA just provides nice set of code, gathered in library with all the necessary "boilerplate code" done. It is DirectX for C#. So when doing games, with C# you should definitely check XNA ( or MonoGame)

For example, loading texture to your game:

 Texture2D tank = content.Load<Texture2D>("myTankImage");


and drawing

 spriteBatch.Draw(tank,new Vector2D(100,100),Color.White);


Inserting these, to right places, would draw your tank to locations 100,100.

Typical action based game sends anywhere from 10 to 30 ( 100ms/33ms) worldUpdate packets to all clients per second. Each client will send same or more to server each second.

WorldUpdate message would have all the necessary object info in it, that the client needs. It could be new position and/or movement speed and direction. Client could use that to rebuild the servers view on the client side. Messages are flying so fast around, that in local server, just updating the positions and setting them without any analysis ( predictions etc ), it would still show correctly.

Networking will definitely be the hardest part of your project, do not underestimate that.

There's great Networking library for C# game networking called Lidgren Network. There's tutorials at internet about basic game networking with Lidgren.

Some links for networking: