Chapter 5. Improving the Snake Game
This chapter is the second and final part of the series where we're building a more robust snake game. In this chapter, we'll take what we already had from Chapter 3, Understanding the Gravity of HTML5, and add more HTML5 APIs to it, so as to make the game more feature rich, providing an even more engaging user experience.
The first version of the game used five HTML5 concepts, namely 2D canvas rendering, offline application cache, web workers, typed arrays, and requestAnimationFrame. In this version, we'll include two features from the new web storage API, namely local storage and session storage. We'll also look at a third API that is part of web storage, IndexedDB, as well as the web messaging feature, which includes cross-domain messaging.
Local storage and session storage are two mechanisms that allow us to save data on the user's browser using a key-value strategy. This is similar to a cookie, where every value must be a string. The difference between...