使用WebSocket構建多人遊戲



在此視頻中,我演示了如何使用websockets構建可在任何設備上運行的基於瀏覽器的多人遊戲。我使用伺服器權威模型設計多人遊戲,其中遊戲狀態存儲在伺服器上。我將WebSockets用作我正在開發的遊戲的通信介質。

連接到伺服器:6:00
創建遊戲:9:45
加入遊戲:13:00
玩遊戲:16:00
廣播狀態18:00
例子22:15
代碼31:00
連接代碼31:00
創建遊戲代碼50:00
加入遊戲代碼59:10
玩遊戲代碼1:20:40
廣播代碼1:30:00

源代碼

https://github.com/hnasr/javascript_playground/tree/master/websocket-cell-game。

9 comments
  1. Awesome video, thanks! I wonder why does the websocket server rely on the http server and how do they interact with each other. They use the same port so there should be some mechanisms for passing message from one to another?

  2. Great video. One of the best session on Websocket multiplayer game.
    It would be good if you could share the code.
    Waiting for your session on the same working on Multiserver with Redis

Comments are closed.