Chapter 6. Adding Sound Effects to Your Games

In the earlier chapters, we discussed several techniques to draw game objects visually. In this chapter, we will focus on using the audio tag that is introduced in the HTML5 specification. We can add sound effects, background music, and control the audio through the JavaScript API. In addition, we will build a music game in this chapter. It is a game that requires players to hit the correct string at the right time to produce the music.

In this chapter, you will learn the following topics:

  • Adding a sound effect to the Play button
  • Building a mini piano musical game
  • Linking the music game and the Play button
  • Adding keyboard and touch inputs to the game
  • Creating a keyboard-driven music game
  • Completing the ...

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.