Skip to content

Commit

Permalink
Almost done with documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ambiguousname committed Oct 7, 2023
1 parent 1c9504d commit 41f0d99
Show file tree
Hide file tree
Showing 58 changed files with 14,598 additions and 135 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Or you can come talk to me (Tyler, that’s me. If you don’t know who me is, c

The quick tutorial is available here {@link https://gdacollab.github.io/Microgame-Jam-GHGT-Framework/tutorial-adding-games.html}.

Made with [JSDoc]{@link https://jsdoc.app/} (jsdoc ./web/main.js ./web/globals.js ./web/gameinterface.js ./web/gameloader.js ./web/lib/input.js ./web/jam-version-assets/version-style.js ./web/lib/animationmanager.js ./web/lib/configloader.js ./web/lib/markdown-it.min.js ./web/lib/gamesound.js -u ./web/tutorials -d docs -R README.md -p)
Made with [JSDoc]{@link https://jsdoc.app/} (jsdoc ./web/main.js ./web/globals.js ./web/gameinterface.js ./web/gameloader.js ./web/lib/input.js ./web/jam-version-assets/version-style.js ./web/lib/animationmanager.js ./web/lib/configloader.js ./web/lib/markdown-it.min.js ./web/lib/gamesound.js ./web/lib/picointerface.js ./web/lib/options/menulib.js ./web/lib/options/menumanager.js ./web/lib/options/optionsmanager.js -u ./web/tutorials -d docs -R README.md -p)

A brief diagram of how it works:

Expand Down
1 change: 1 addition & 0 deletions Web/gameloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class GameLoader {

/**
* Called by {@link MicrogameJam#update}. Only calls {@link module:picointerface~PicoInterface#picoUpdate} if the current game is running PICO-8.
* @todo Should we call this.picoInterface.picoUpdate(this.picoInterface)???
*/
loadUpdate() {
if (PicoInterface.isPicoRunning()){
Expand Down
37 changes: 37 additions & 0 deletions Web/lib/gamesound.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,39 @@ var ini;
class AudioManager {
#setupPromise;

/**
* @constructs AudioManager
*/
constructor(){
/**
* Promise for waiting for the ini file from {@link module:configloader}, then calls {@link module:gamesound~AudioManager#constructSounds}.
*/
this.#setupPromise = new Promise(async (resolve) => {
ini = await iniReader;
this.#constructSounds();
resolve();
});
}

/**
* Returns {@link module:gamesound~AudioManager#setupPromise}
*/
get onSetup() {
return this.#setupPromise;
}

/**
* Set up sounds from the ini file loaded from {@link module:configloader}.
* @alias module:gamesound~AudioManager#constructSounds
* @private
*/
#constructSounds(){
/**
* Dictionary of sounds to play based on their names.
* Initialized in {@link module:gamesound~AudioManager#constructSounds}
* @type {Object.<string, Audio>}
* @todo I don't know why this isn't a private variable. (Should be #sounds instead of _sounds).
*/
this._sounds = ini["Sounds"];

for (var soundKey in this._sounds){
Expand All @@ -40,6 +60,14 @@ class AudioManager {
}
}

/**
* Play a sound.
* @param {string} sound Sound name that exists in {@link module:gamesound~AudioManager#_sounds}
* @param {number} volume The volume to play the sound at.
* @param {boolean} varyPitch Randomize the pitch on play?
* @param {boolean} looping Loop the sound?
* @param {function} callback Callback to play on sound stop.
*/
play(sound, volume, varyPitch = false, looping = false, callback){
this._sounds[sound].loop = looping;
this._sounds[sound].volume = volume;
Expand All @@ -61,10 +89,19 @@ class AudioManager {
}
}

/**
* Update a sound playing.
* @param {string} sound The sound to update from {@link module:gamesound~AudioManager#_sounds}.
* @param {number} volume The volume to update the sound with.
*/
updateSound(sound, volume) {
this._sounds[sound].volume = volume;
}

/**
* Stop a sound from playing.
* @param {string} sound The sound to stop playing from {@link module:gamesound~AudioManager#_sounds}.
*/
stop(sound){
this._sounds[sound].pause();
this._sounds.currentTime = 0;
Expand Down

0 comments on commit 41f0d99

Please sign in to comment.