Skip to content

Music and sound effects

Hayden Schiff edited this page Nov 28, 2019 · 1 revision

This page documents how music and sound effects are implemented in this game.

File organization

All sound files should go in assets/sound/ within the game's main folder. Best practice for browser-based games is to include several different file formats, but for the time being, we are only using MP3s to keep things simple.

Every sound file that is in use within the game needs to have an entry in the file assets/sound.json. You can open this file in any text editor (e.g. Atom, Notepad, TextEdit, etc). Here is what an entry in that file looks like:

      {
        "type": "audio",
        "key": "title_screen_theme",
        "url": "assets/sound/title_screen_theme.mp3"
      }

Here's what each of those properties means:

  • type: This should always be "audio".
  • key: This is the name which the game will use to identify this particular sound. In general, this should always match up with the filename.
  • url: The path to the audio file, relative to the game's main folder.

Background music

To add a background music track to a level, open the level map in Tiled and go to Map>Map Properties... This will show the map's metadata in the Properties panel in the left column of the app (assuming you haven't put it somewhere else in your workspace). Under "Custom Properties" in the Properties panel, add a new property using the '+' button at the bottom of the panel. Set the name to "music" and set the type to string, and your property will appear in the Custom Properties section. Set the property's value to the key for the sound file. The key must exactly match the key as it appears in assets/sound.json.

Currently, the background music for the title screen is hardcoded to title_screen_theme.

Sound effects

Not yet implemented!