Multiplayer HTML5, Node.js, Socket.IO

后端 未结 4 1426
刺人心
刺人心 2020-12-12 18:28

I trying create simple Multi-player with HTML5 Canvas, JavaScript(too using John Resig simple Inheritance library) and Node.js with Socket.IO. My client code:



        
相关标签:
4条回答
  • 2020-12-12 18:54

    There is now an open-source multiplayer realtime javascript server (and client library) called Lance.gg, which provides, as you say, a real multiplayer experience

    It handles client-side prediction, step drift, bending, and basic physics.

    Disclaimer: I am one of the contributors

    0 讨论(0)
  • 2020-12-12 19:17

    First, check out http://www.google.com/events/io/2011/sessions/super-browser-2-turbo-hd-remix-introduction-to-html5-game-development.html

    it explains how to use requestAnimationFrame among other things.

    Second, the game state should exist on the server and be mirrored on the clients.

    When a player clicks down, the client should only send a message. The server should then send a message to all the clients, including the client that took the action.

    Each player should exist as an object on the server. When a player logs in they should be brought up to date about the status of each player already on the server.

    modified client code: http://codr.cc/s/d0154536/js

    modified server code: http://codr.cc/s/f96ce1d2/js

    0 讨论(0)
  • 2020-12-12 19:20

    Glenn Fiedler's What every programmer needs to know about game networking -article is good read for anyone who wants get into game networking. It explains the basics in very high level so that it is adaptable for JS and Socket.io.

    0 讨论(0)
  • 2020-12-12 19:20

    In case anyone stumbles across this question as I have just now, I wanted to add this link as an example.

    I was following the same path as the op several months ago and read every article I could find on the authoritative server model (including the one referenced in the answer by @Epeli), and how to implement it with nodejs/socketio.

    The result of my research manifested itself in the github project located at the link provided above (there is also a live demo). Hope this helps someone.

    0 讨论(0)
提交回复
热议问题