Learn › GBC Beginner

Lesson 5 of 6 · About 5 min

Adding a sound

Give the fox's jump a sound of its own.

The fox jumps over two slugs in Fox Run.

How Fox Run's sounds are made and played, and how to add one for the jump.

Sounds are written assets

A sound in Shiny Gen can be a few lines of text: a tempo, an instrument and some notes. The app turns it into audio, and these written sounds are free to make.

Fox Run lists its sounds in a comment at the top of the code. Each SOUND line names an audio asset of the game, and the code plays it by the name SND_ followed by the asset's name, for example SND_coin.

Events and their sounds

A table called SFX_SND says which sound each event plays: picking up an ember, stomping a foe, getting hurt, lighting a lantern, clearing a level, falling, winning and losing.

Sounds play only during play, so the demo on the title screen stays quiet. Each sound starts two frames after its event, which keeps the frame of the event itself light for the GBC.

The missing sound

The most common action in the game, the jump, has no sound. In the session you will add one: an asset, its SOUND line, a new event in SFX_SND, and a call where the fox jumps.

The Assets tab of the editor listing Fox Run's sounds, including the new jump sound.
Add a jump sound

Try it yourself

In the app this lesson opens a real game for you, with a guide that walks you through these steps:

  1. Every sound in this game is a small written asset with a name. The code plays it by that name.
  2. Add a short jump sound that plays every time the fox jumps.
  3. Sounds are assets of the game. Press Assets.
  4. Press Audio to list the game's sounds.
  5. These are the game's sounds, with jump among them. You can open one to hear it, or ask the AI to change it.
Start makingDownload on the App StoreGet it on Google Play