We built several local single-player games in the previous chapters. In this chapter, we will build a multiplayer game with the help of WebSockets. WebSockets enable us to create event-based server-client architecture. The messages are passed between all connected browsers instantly. We will combine the Canvas drawing, JSON data packing, and several techniques learned in the previous chapters to build the draw-and-guess game.
In this chapter, we will learn the following topics:
Trying an existing multiuser sketchpad that shows drawings from different connected users through WebSockets
Installing a WebSocket server that is implemented by node.js
Connecting the server from a browser
Creating an instant chat room with the WebSocket API
Creating a multiuser drawing pad in the Canvas
Building a draw-and-guess game by integrating the chat room and drawing with game logic
The following screenshot shows the draw-and-guess game that...