Book Image

HTML5 Game Development by Example: Beginner's Guide

By : Seng Hin Mak
Book Image

HTML5 Game Development by Example: Beginner's Guide

By: Seng Hin Mak

Overview of this book

Table of Contents (18 chapters)
HTML5 Game Development by Example Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
9
Building a Physics Car Game with Box2D and Canvas
Index

Summary


We learned a lot in this chapter about connecting browsers to WebSockets. The messages and events from one browser are sent to all connected browsers in almost real time.

Specifically, we learned how WebSockets provide real-time events by drawing on an existing multiplayer sketchpad. It shows drawings from other users who are connected. We chose Node.js as the server-side WebSocket server. By using this server, we can easily build an event-based server to handle WebSocket requests from browsers. We discussed the relationship between the server and a client, which compares WebSockets with other approaches such as long-polling. We built an instant chat room application. We learned how to implement a server script to send all incoming messages to other connected browsers. We also learned how to display a received message from the server on the client side. Next, we built a multiuser drawing board and finally a draw-and-guess game by integrating the chatting along with the drawing pad...