Multiplayer HTML5, Node.js, Socket.IO

后端 未结 4 1431
刺人心
刺人心 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 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

提交回复
热议问题