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.

The game is between two players, real time, and has to be very synchronized - latency will certainly favor one player over the other. It's built for iOS and Android and every touch on one end has to be instantanious on the other end.

The game will be built on Corona SDK and I'm looking to use a service to simplify communication (even if it involves additional costs). I'm currently considering PubNub or Parse.

I'm new to game dev and this is my first real time game. Please be as specific as possible.

share|improve this question
    
I'd say the best option would be Erlang in the server-side , but I'm not quite sure how can you make it interact with the CoronaSDK, I suppose there is a way (?) –  dysoco Jul 26 '12 at 17:47
add comment

1 Answer

up vote 3 down vote accepted

Network Architecture is difficult. The problem is your never going to get "Instantaneous" clicks on both sides. There will be some lag, and most games get around this by accepting it and building the architecture around it.

For example, most first person shooters use prediction. They keep the entire game state and logic on both ends, but the server sends constant updates on every object in the game. Then, when you do something like shoot something on a client, your side calculates what happened, and then shows you the result. It also sends the event to the server, and the server "should" calculate the same result, since both computers have the same state. If it does, then it tells the client. The client says "tell me something I don't know" and moves on. If the server disagrees, then it updates the client with what really happened, and the player sees a guy they just shot in the head stand up and run away.

The latency will be even worse with mobile phones. From this question http://stackoverflow.com/questions/1097937/latency-on-mobile-networks-android it looks like you can expect anywhere from 80 ms to 3000 ms.

My advice would be to use the lock step client-client architecture that most RTS's favor. You run deterministic game logic on both ends, then only send user input back and forth. Then you delay the time between input and when the input is given to the game logic so it can by synchronized on all sides. For more info check out http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_288_network_.php/.

Here is an article on how to write the network code for Corona SDK: http://developer.coronalabs.com/code/multiplayer-networking.

share|improve this answer
    
Thank you very much Thomas. You've actually answered several other questions i had. And the Corona SDK article uses pubnub, so i'm going to give it a try first to see how it goes. –  Victor C. Jul 26 '12 at 14:47
add comment

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.