Im creating a multiplayer asteroids type game for the Windows Phone 7, 2 players can challenge each other over who will get the highest score. On each players phone the opponent is displayed and both go about shooting asteroids and enemies. In an assignment I have due I would like to talk about the packet design, what would be the least amount of info that I can send over the connection? Instead of constantly having to send each players position, asteroid position, bullet position and enemy position etc. Or would all that data constantly need to be sent?
2 Answers
This is not trivial.
In general you want to make your game predictable. You also need to synchronize the clocks in both clients. If you do this there is no need to send the asteroids position every frame because both clients will be doing the same simulation. After a given number of frames you make sure that the simulations have not changed. Once you have done this you can send each player input and repeat the simulation of what happened in the other client exactly.
This is one of the most known articles and a good introduction. It's a postmortem on how they built Age of Empires multiplayer.
You can also check this fantastic one. The author has written a multiplayer Asteroids game. There is a second article in his website with more details.
You can send whatever you want. Typically you only need to send what has changed. You can also group things to send to minimize traffic.