Android Question Real-time Bluetooth Multiplayer

wonder

Expert
Licensed User
Hey guys!! Hey @Erel! ;)

I was wondering, would it be possible and reliable to create a simple Pong game, where the 2 players compete via bluetooth in real-time, with negligible lag?

I guess the way to implement it would be a host/guest model, where the app in host mode is fed the Player 2 input and performs all the calculations before sending the data back to the second device running the app in guest mode.
Please correct me if there is a better way to do it.
 

Beja

Expert
Licensed User
The implementation you are suggesting is time consuming and will double the lag time, because the host will process for himself and for the guest.. but if each one just sent it's new position and let the other process it, this way you will save time.
 

wonder

Expert
Licensed User
The problem is the randomized behavior of the AI. Without a host the AI would have different movement patterns on each device, henceforth creating a different experience for each user in cooperative multiplayer.

However, for a simple versus match (such as a Pong game), yes... there's no need for a host/guest scheme.
 

Beja

Expert
Licensed User
you are right, I was thinking about Ping-Pong game that you mentioned..
 

Beja

Expert
Licensed User
The Pong game would be a proof of concept and if it works properly, I would happily publish the source code. :)
I would then implement what I've learned in my own game.
That would be great and can't wait to read your Ping-Pong code. I will definitely benefit from it..
Some time ago I think someone posted a project like Ping-Pong, but not quite sure. but that was single player.
 

Beja

Expert
Licensed User
Did you find the single player code posted here some time ago?

edit:
Just remembered it was not Ping-Pong, but only ping.. a moving bar at the bottom of the screen that will return the ball.. the ball will return in random angle and if hit a small box will destroy it.. when all boxes are destroyed then the game is over.

something like this:
 

Attachments

Last edited:
Top