0

我目前正在为 android 构建游戏。游戏本身使用与谷歌登月器相同的架构。我还研究了蓝牙 api 和蓝牙聊天应用程序。我想制作我的游戏,以便可以使用蓝牙与 2 台设备互相玩。

我正在制作一个乒乓球风格的游戏。所以我有一个球和两个桨。每个玩家一个。我正在使用一个线程来更新游戏并重新渲染到表面视图。现在我正在使用这个线程将我的桨的位置发送到另一个设备。游戏以 50 fps 运行。这意味着我通过蓝牙进行了 50 次写入。这种方法有效,但有很大的延迟......

我应该如何提高蓝牙性能?我应该使用什么类型的输入和输出流?

亲切的问候

4

1 回答 1

0

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.

于 2011-02-24T19:42:00.450 回答