Summary

In this chapter we took a few extra steps into the fascinating world of 2D rendering using the long-awaited canvas API. We took advantage of the canvas' ability to export images to make our game more engaging, and potentially more social. We also made the game more engaging and social by adding a persistence layer on top of the game, whereby we were able to save a player's high score.

Two other new powerful features of HTML5, web messaging and IndexedDB, were explored in this chapter, although there were no uses for these features in this version of the game. The web messaging API provides a mechanism for two or more windows to communicate directly through message passing. The exciting bit is that these windows (or HTML contexts) do not need to be in the same domain. Although this could sound like a security issue, there are several systems in place to ensure that cross-document and cross-domain messaging is secure and efficient.

The web storage interface brings with it three distinct solutions for long term data persistence on the client. These are session storage, local storage, and IndexedDB. While IndexedDB is a full-blown, built-in, fully transactional and asynchronous NoSQL object store, local and session storage provide a very simple key-value pair storage for simpler needs. All three of these systems introduce great benefits and gains over the traditional cookie-based data storage, including the fact that the total amount of data that can be persisted in the browser is much greater, and none of the data saved in the user's browser ever travels back and forth between the server and the client through HTTP requests.

In the next chapter we will look at some advanced HTML5 topics, including the next step beyond canvas' 2D rendering context – WebGL. While these topics will be covered in good detail, none of the features that follow will be added to a game. In fact, Chapter 6, Adding Features to Your Game, is another rare game in this book that is not built upon a fun HTML5 game, as we have being building together. We will pick up the game building projects in Chapter 7, HTML5 and Mobile Game Development, where we conclude the book with a mobile space shooter game.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.210.91