Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying HTML5 Game Development by Example(Second Edition)
  • Table Of Contents Toc
HTML5 Game Development by Example(Second Edition)

HTML5 Game Development by Example(Second Edition)

3.8 (5)
close
close
HTML5 Game Development by Example(Second Edition)

HTML5 Game Development by Example(Second Edition)

3.8 (5)

Overview of this book

This book is for web designers who have a basic knowledge of HTML, CSS, and JavaScript and want to create Canvas or DOM-based games that run on browsers.
Table of Contents (13 chapters)
close
close
9
9. Building a Physics Car Game with Box2D and Canvas
12
Index

Chapter 8. Building a Multiplayer Draw-and-Guess Game with WebSockets

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...

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
HTML5 Game Development by Example(Second Edition)
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon