Game Development Reference
In-Depth Information
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
Understanding canvas 2D basics and the
drawing API
The 2D context provides objects, methods, and properties to draw and manipulate
graphics on the drawing surface of a canvas. Refer to the link http://www.
w3schools.com/html/html5_canvas.asp to learn more about canvas 2D. The
following is some example code for the canvas element:
<html>
<canvas id="canvasElement"></canvas>
</html>
Search WWH ::




Custom Search