Summary

You learned a lot in this chapter about using the HTML5 audio element and built a music game. Specifically, we managed and controlled audio playback by using the HTML audio tag and related JavaScript API. You learned different attributes that change the audio tag's behavior. We made use of the audio tag to create a keyboard-based canvas game. We also made the game work on touch devices by sharing the common logic between keyboard input and touch input. We created the game with a special mode that helps the game level designer to create the level data.

You learned about adding music and sound effects in our HTML5 games. Now we are ready to build a more complete game by adding a leaderboard to store game scores in the next chapter.

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.