I am now at the planning stage for a 2D game for mobile devices, which I will do in C ++ using cocos2d-x. The game will be rotated, and each turn will have a phase in which physical simulations will be conducted. It will also be cross-platform.
I am new to the multi-user network, and I am wondering what is the best way to sync physics, since Box2d does not behave exactly the same on different devices.
Simulation should not happen simultaneously on each device, but I need the results to be exactly the same. Ideally, players will be able to witness on their own device the same physical simulation (i.e. projectile movement, bouncing, collisions), and the result that occurred during their opponents turns when they decide to start their turn.
What would be the best way to do this? From my research I came up with a couple of solutions. Do I have to write server code on which I would take user input and process the entire physical simulation, and then send the results to each device? or is there a way that I could process the simulation on one device and send all the information to another?
Also, how exactly is everything that happens during the simulation sent over the network sent, since I cannot run the simulation on each device and get the same results? Can I just update the server (or device) with information about what happens during every few TimeSteps?
I would also think about implementing my own physics / collision detection.
source
share