so i have made a box2d game with cocos2d. The user can move the player and in the world there are dynamic objects. Now i thought of implementing a coop mode.
I know there’s gamekit.
My thoughts:
-
make one of the two devices (or more..) to the host.
-
if level loads send all positions from all objects (static+ dynamic + player positions) to the other clients (iphones/ipods/ipads) and now it should be sync
BUT
should i make a dict and then add the positions of all objects to it and then convert it to a nsdata object then send it.
Is that enough?
I want to make this without having any internet connection so P2P.
The only possibility is Bluetooth i think or are there more?
Is that enough?
Would be great if someone could give me some advice and some code on how to do that.
Thanks for reading
Have a nice day.
🙂
I think the good idea would be making one of the host to be a server. Because, if you create connection each to each, then you’ll have N*(N-1) connections total, and (N-1) connections for each host. If you use the server then you’ll have only N-1 connection for the server and only 1 connection for each client. So you’ll have to perform full simulation on each of the hosts and then synchronize that data with server. The simulation, synchronized at regular intervals, will tend to run identically on all computers. It means that only small and infrequent adjustments will be necessary to keep it the same for all users.
edit: you should also think about traffic minimization, that’s why sending the NSDictionary would be too much. You can send little structure, like
edit2:
Probably you want to add some header to the packet and place there the number of objects etc.