Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying HTML5 Game Development by Example(Second Edition)
  • Table Of Contents Toc
HTML5 Game Development by Example(Second Edition)

HTML5 Game Development by Example(Second Edition)

3.8 (5)
close
close
HTML5 Game Development by Example(Second Edition)

HTML5 Game Development by Example(Second Edition)

3.8 (5)

Overview of this book

This book is for web designers who have a basic knowledge of HTML, CSS, and JavaScript and want to create Canvas or DOM-based games that run on browsers.
Table of Contents (13 chapters)
close
close
9
9. Building a Physics Car Game with Box2D and Canvas
12
Index

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 musical game with a level data recording and the game over event

You can play the game example at: http://makzan.net/html5-games/audiogame/.

The following screenshot shows the final result we will create through this chapter:

Adding Sound Effects to Your Games

So, let's...

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
HTML5 Game Development by Example(Second Edition)
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon