Saving the entire game progress

We have enhanced our CSS3 card matching game by adding a game over screen and storing the last game record. Imagine now that a player is mid-game and accidentally closes the web browser. Once the player opens the game again, the game starts from the beginning and the game that the player was playing is lost. With the local storage, we can encode the entire game's data into JSON and store it. In this way, players can resume their game later.

We are going to pack the game data into one object and save it into the local storage every second.

Get HTML5 Game Development by Example : Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.