Book Image

WebGL Game Development

By : Sumeet Arora
Book Image

WebGL Game Development

By: Sumeet Arora

Overview of this book

<p>WebGL, the web implementation of Open GL, is a JavaScript API used to render interactive 3D graphics within any compatible web browser, without the need for plugins. It helps you create detailed, high-quality graphical 3D objects easily. WebGL elements can be mixed with other HTML elements and composites to create high-quality, interactive, creative, innovative graphical 3D objects.</p> <p>This book begins with collecting coins in Super Mario, killing soldiers in Contra, and then quickly evolves to working out strategies in World of Warcraft. You will be guided through creating animated characters, image processing, and adding effects as part of the web page canvas to the 2D/3D graphics. Pour life into your gaming characters and learn how to create special effects seen in the most powerful 3D games. Each chapter begins by showing you the underlying mathematics and its programmatic implementation, ending with the creation of a complete game scene to build a wonderful virtual world.</p>
Table of Contents (17 chapters)
WebGL Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 10. 2D Canvas and Multiplayer Games

In all our previous chapters, we have discussed 3D rendering in-depth but have not discussed 2D rendering. In this chapter, we will discuss the canvas 2D context, which is a very important aspect of game development. The canvas 2D context offers a very powerful drawing API.

We will also discuss the concepts of HTML-based multiplayer games. We will then discuss Node.js and the Socket.IO API to implement a spectator player who can see what is happening in the game. In this chapter, we will cover:

  • Canvas 2D basics and the drawing API

  • 2D sprites for model labels and game scores

  • Real-time communication: HTTP long polling and WebSockets

  • Node.js: Socket.IO

  • Sample implementation of the multiplayer game: a spectator player