XenonLab-Studio/TerraCraft

Need to add sound effects

benmoran56 opened this issue · 4 comments

At some point, we can begin to add sound effects. For a start, we can use a site such as "jfxr" to generate some simple free samples. They can be exported as wav files: https://jfxr.frozenfractal.com/

For playback, the most simple way would be to:

  1. Write a simplified AudioPlayer class, to wrap the pyglet.media.Player class. This class can have play and play_music methods to start.
  2. Each Scene will have a reference to the audio player, so you can do something like: self.audio_player.play('jump.wav')` from any Scene.

This would be very simple and quick to add. To start, maybe we should rename /img to /assets? Then we can organize things into something like /assets/sounds and /assets/images. What do you think?

It's a good idea. the assets folder is used to keep all the resources that we will add later, so I totally agree with you.

I've been very busy lately, but I will make a pull request soon for this. I have an audio player class that I have written for another project, so I can easily donate that code to TerraCraft. It's a slightly higher level abstraction on the pyglet base classes, making it very easy to use to play sfx, or separately queue a music track. Maybe a good name for the class is AudioEngine.

Along with that, I'll add temporary jumping and digging sfx. We can change these later of course. I was thinking that we can put the "digging" sfx as a Block attribute, so that we can easily have different sounds for different block types. Does that sound OK?

Your idea seems very good to me. Your work is very precious. Terracraft with the addition of audio tracks has a much more complete appearance. Thanks so much.

Already added!