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