我正在编写简单的游戏,我计划将多人游戏(通过网络)作为我的大学项目。我正在考虑客户端-服务器通信的两种方案:
物理(它们是微不足道的!实际上我应该称之为“碰撞测试”:))仅在服务器机器上处理。因此通信看起来像
Client1->Server: Pressed "UP"
Server->Clients: here you go, Client1 position is now [X,Y]
Client2->Server: Pressed "fire"
Server->Clients: Client1 hit Client2, make Client2 disappear!
服务器接收事件并将其广播给所有其他客户端。
Client1->Server: Pressed "UP"
Server->Clients: Client1 pressed "UP", recalculate his position!!
[Client1 receives this one as well!]
哪一个更好?或者可能一个都没有?