Module audio

Source
Expand description

Facilities for interacting with audio, including: AudioManager, MusicPreset, and SfxPreset

You may add your own sound files to the assets/ directory or any of its subdirectories and play them as sound effects or music by providing the relative path to the file. For example, if you place a file named my_sound_effect.mp3 in assets/, you can play it with:

// Inside your logic function...
game.audio_manager.play_sfx("my_sound_effect.mp3", 1.0);

Or, if you create a assets/my_game/ subdirectory and place a file named spooky_loop.ogg, you could play it as continuous music with:

// Inside your logic function...
game.audio_manager.play_music("my_game/spooky_loop.ogg", 1.0);

The sound effects provided in this asset pack have convenient enums defined that you can use instead of a path to the file: SfxPreset and MusicPreset. For example:

// Import the enums into scope first
use rusty_engine::prelude::*;

// Inside your logic function...
game.audio_manager.play_sfx(SfxPreset::Confirmation1, 1.0);
game.audio_manager.play_music(MusicPreset::Classy8Bit, 1.0);

Structs§

AudioManager
You will interact with the AudioManager for all audio needs in Rusty Engine. It is exposed through the Engine struct provided to your logic function each frame as the audio_manager field. It is also accessible through the Game struct in your main function.
Music

Enums§

MusicPreset
Music included with the downloadable asset pack. You can hear this music in the music example by cloning the rusty_engine repository and running the following command:
SfxPreset
Sound effects included with the downloadable asset pack. You can hear these all played in the sfx example by cloning the rusty_engine repository and running the following command: