开发者

multiplayer game using surfaceview for drawing and bluetooth for multiplayer (performance)

I'am currently building a game for android. The game itself works using the same architecture as google's lunar lander. I also studied the bluetooth api and the bluetooth chat app. I would like to make my game so it can be played with 2 devices ageanst each other using bluetooth.

I'am making a pong style game. So i have a ball and 2 paddles. One for each player. I'am using a thread for updating the game and for the redering to the surfaceview. Now i'am using this thread for s开发者_如何学运维ending the position of my paddle to the other device. The game runs at 50 fps. This means that i do 50 writes over bluetooth. This method works, but there are huge delays...

How should i improve bluetooth performance? What type of input and outputstream shoud i use?

Kind regards


You shouldn't rely on the connection to be good, expect variable delays.

You need some kind of time synchronization, and timestamp certain events so that even when the other side is to late, it can calculate where the ball should be at that moment, and the game stays in sync.

As I understand it, the minimum you should send/timestamp is the pallet position while it hits the ball and/or the outgoing vector of the ball, from then on the other device can calculate on its own what will happen until he hits the ball en does the same. Any pallet updates from then on are supplementary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜