且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

多人台球游戏物理模拟

更新时间:2023-02-02 17:59:06

我认为第三个是***的.

I think that the 3rd one is the best.

但是如果在将它们发送给客户端之前计算服务器中的所有碰撞和运动(每次碰撞和运动等),则可以使客户端变得更好,那么客户端只需要执行"它们即可.

But you can make it even better if you compute all the collisions and movement in the server before sending them to the clients (every collisions and movements, etc...) then clients just have to "execute" them.

如果这样做,您每次发送信息只会发送一次,这将大大减少网络问题.

If you do that you will send the informations only once per shot, that will greatly reduce the network issue.

就像JimR所写的那样,您应该使用速度或运动方程,而不是一步一步地进行逐步仿真(例如Runge-Kutta方法)

And as JimR wrote, you should use velocity or movement equation instead of doing small step by small step incremental simulation (like the Runge-Kutta method)

服务器发送给客户端的信息如下:

The information that the server send to the client would look like this:

Blackball hit->move from x1,y1 to x2,y2 until time t1
Collision between blackball and ball 6 at time t1
Ball 6 -> move from x3,y3 to x4,y4 until time t3
Blackball -> move from x5,y5 to x6,y6 until time t4
Collision between Ball 6 and Ball 4 at time t3
and so on until nothings move anymore

此外,您可能需要一堆代表不同物理方程的类,并有一种方法可以将它们序列化以将其发送给客户端(Java或C#可以轻松地序列化对象).

Also, you are likely to need a bunch of classes representing the differents physics equations and have a way to serialize them to send them to the clients (Java or C# can serialize objects easily).