Skip to content

Commit 74f0d9e

Browse files
author
Diogenesthecynic
committed
Created AudioHandlr.js
Reshuffled Sounds to use it, and deleted sounds.js.
1 parent 17f363d commit 74f0d9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+536
-277
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Sounds/ogg/Bowser Falls.mp3

-13.2 KB
Binary file not shown.

Sounds/ogg/Bowser Fires.mp3

-14.4 KB
Binary file not shown.

Sounds/ogg/Break Block.mp3

-7.39 KB
Binary file not shown.

Sounds/ogg/Bump.mp3

-3.71 KB
Binary file not shown.

Sounds/ogg/Coin.mp3

-12.3 KB
Binary file not shown.

Sounds/ogg/Ending.mp3

-76.3 KB
Binary file not shown.

Sounds/ogg/Fireball.mp3

-2.79 KB
Binary file not shown.

Sounds/ogg/Firework.mp3

-6.16 KB
Binary file not shown.

Sounds/ogg/Flagpole.mp3

-14.7 KB
Binary file not shown.

Sounds/ogg/Gain Life.mp3

-11.1 KB
Binary file not shown.

Sounds/ogg/Game Over 2.mp3

-64.6 KB
Binary file not shown.

Sounds/ogg/Game Over.mp3

-75.7 KB
Binary file not shown.

Sounds/ogg/Hurry.mp3

-36.8 KB
Binary file not shown.

Sounds/ogg/Into the Tunnel.mp3

-53.6 KB
Binary file not shown.

Sounds/ogg/Jump Small.mp3

-8 KB
Binary file not shown.

Sounds/ogg/Jump Super.mp3

-8 KB
Binary file not shown.

Sounds/ogg/Kick.mp3

-3.1 KB
Binary file not shown.

Sounds/ogg/Level Complete.mp3

-92.5 KB
Binary file not shown.

Sounds/ogg/Pause.mp3

-9.22 KB
Binary file not shown.

Sounds/ogg/Pipe.mp3

-10.4 KB
Binary file not shown.

Sounds/ogg/Player Dies.mp3

-32.8 KB
Binary file not shown.

Sounds/ogg/Power Down.mp3

-10.5 KB
Binary file not shown.

Sounds/ogg/Powerup Appears.mp3

-8.01 KB
Binary file not shown.

Sounds/ogg/Powerup.mp3

-12.6 KB
Binary file not shown.

Sounds/ogg/Stage Clear.mp3

-67.1 KB
Binary file not shown.

Sounds/ogg/Vine Emerging.mp3

-14.7 KB
Binary file not shown.

Sounds/ogg/World Clear.mp3

-74.4 KB
Binary file not shown.

Sounds/ogg/You Dead.mp3

-66.5 KB
Binary file not shown.

data.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function findScore(lev) {
127127

128128
function gainLife(num, nosound) {
129129
data.lives.amount += typeof(num) == "number" ? num : 1;
130-
if(!nosound) play("Gain Life");
130+
if(!nosound) AudioPlayer.play("Gain Life");
131131
updateDataElement(data.lives);
132132
}
133133

generator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ function endCastleInsideRandomFinal(xloc) {
472472
function placeRandomCastleNPC(xloc) {
473473
var npc = pushPreThing(Toad, xloc + 194, 12).object;
474474
npc.text = [
475-
pushPreText({innerHTML: "THANK YOU" + window.player.title.toUpperCase() + "!"}, xloc + 160, 66).object,
475+
pushPreText({innerHTML: "THANK YOU " + window.player.title.toUpperCase() + "!"}, xloc + 160, 66).object,
476476
pushPreText({innerHTML: "LOL YOU THOUGHT THERE WOULD BE SOMETHING HERE DIDN'T YOU!"}, xloc + 148, 50).object
477477
];
478478
}

library.js

+1-47
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

load.js

+1-43
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Load.js */
2-
// Maps and sounds are loaded via AJAX
2+
// Maps are loaded via AJAX
33

44
/* Maps */
55

@@ -47,46 +47,4 @@ function setNextLevelArr(arr) {
4747
arr[1] = 1;
4848
}
4949
return arr;
50-
}
51-
52-
53-
/* Sounds */
54-
55-
function startLoadingSounds() {
56-
var libsounds = library.sounds;
57-
setTimeout(function() { loadSounds(libsounds, library.sounds.names, "Sounds/"); }, 7);
58-
setTimeout(function() { loadSounds(libsounds, library.sounds.themes, "Sounds/Themes/"); }, 14);
59-
}
60-
61-
// Loads sounds (in order) from the reference into the container
62-
function loadSounds(container, reference, prefix) {
63-
var sound, name_raw,
64-
details = {
65-
preload: 'auto',
66-
prefix: '',
67-
used: 0
68-
},
69-
len, i;
70-
for(i = 0, len = reference.length; i < len; ++i) {
71-
name_raw = reference[i];
72-
73-
// Create the sound and store it in the container
74-
sound = createElement("Audio", details);
75-
container[name_raw] = sound;
76-
mlog("Sounds", sound)
77-
78-
// Create the MP3 and OGG sources for the audio
79-
sound.appendChild(createElement("Source", {
80-
type: "audio/mp3",
81-
src: prefix + "mp3/" + name_raw + ".mp3"
82-
}));
83-
sound.appendChild(createElement("Source", {
84-
type: "audio/ogg",
85-
src: prefix + "ogg/" + name_raw + ".ogg"
86-
}));
87-
88-
// This preloads the sound.
89-
sound.volume = 0;
90-
sound.play();
91-
}
9250
}

maps.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function setAreaSetting(area, setting, sound) {
7373
if(area.fillStyle.indexOf("Underwater") != -1) goUnderWater();
7474
else goOntoLand();
7575

76-
if(sound) playTheme();
76+
if(sound) AudioPlayer.playTheme();
7777
if(gameon) clearAllSprites();
7878
map.shifting = false;
7979
}
@@ -217,7 +217,7 @@ function shiftToLocation(loc) {
217217
// Typically this will do nothing or be from a pipe
218218
loc.entry(player, loc.entrything);
219219
// Don't forget the least annoying part of programming this!
220-
TimeHandler.addEvent(playTheme, 2);
220+
TimeHandler.addEvent(AudioPlayer.playTheme, 2);
221221

222222
// Texts are bound-check checked periodically for peformance reasons
223223
TimeHandler.addEventInterval(checkTexts, 117, Infinity);
@@ -505,7 +505,7 @@ function walkToPipe() {
505505
var move = setInterval(function() {
506506
if(player.piping) {
507507
// We have started piping
508-
if(sounds[0]) sounds[0].pause();
508+
AudioPlayer.pauseTheme();
509509
nokeys = player.keys.run = notime = false;
510510
clearInterval(move);
511511
player.maxspeed = player.maxspeedsave;
@@ -551,8 +551,8 @@ function intoPipeHoriz(me, pipe, transport) {
551551
}, timer);
552552
}
553553
function pipePreparations(me) {
554-
pauseTheme();
555-
play("Pipe");
554+
AudioPlayer.pauseTheme();
555+
AudioPlayer.play("Pipe");
556556
locMovePreparations(me);
557557
me.nofall = me.nocollide = nokeys = notime = true;
558558
me.movement = me.xvel = me.yvel = 0;
@@ -580,7 +580,7 @@ function startCastle(me) {
580580
function exitPipeVert(me, pipe) {
581581
switchContainers(me, characters, scenery);
582582
me.nofall = nokeys = notime = true;
583-
play("Pipe");
583+
AudioPlayer.play("Pipe");
584584
setTop(me, pipe.top);
585585
setMidXObj(me, pipe, true);
586586
var dy = unitsize / -4, move = setInterval(function() {
@@ -840,7 +840,7 @@ function endCastleInsideFinal(xloc, last) {
840840
if(last) {
841841
pushPreThing(Peach, xloc + 194, 13).object;
842842
text = stopper.text = [
843-
pushPreText({innerHTML: "THANK YOU" + window.player.title.toUpperCase() + "!", style: style}, xloc + 160, 66).object,
843+
pushPreText({innerHTML: "THANK YOU " + window.player.title.toUpperCase() + "!", style: style}, xloc + 160, 66).object,
844844
pushPreText({innerHTML: "YOUR QUEST IS OVER.<BR>WE PRESENT YOU A NEW QUEST.", style: style}, xloc + 148, 50).object,
845845
pushPreText({innerHTML: "PRESS BUTTON B<BR>TO SELECT A WORLD.", style: style}, xloc + 148, 26).object
846846
];
@@ -849,7 +849,7 @@ function endCastleInsideFinal(xloc, last) {
849849
else {
850850
pushPreThing(Toad, xloc + 194, 12).object;
851851
text = stopper.text = [
852-
pushPreText({innerHTML: "THANK YOU" + window.player.title.toUpperCase() + "!", style: style}, xloc + 160, 66).object,
852+
pushPreText({innerHTML: "THANK YOU " + window.player.title.toUpperCase() + "!", style: style}, xloc + 160, 66).object,
853853
pushPreText({innerHTML: "BUT OUR PRINCESS IS IN<BR>ANOTHER CASTLE!", style: style}, xloc + 148, 50).object
854854
];
855855
}

mario.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<script src="maps.js"></script>
1717
<script src="mario.js"></script>
1818
<script src="quadrants.js"></script>
19-
<script src="sounds.js"></script>
2019
<script src="sprites.js"></script>
2120
<script src="things.js"></script>
2221
<script src="toned.js"></script>
@@ -26,6 +25,7 @@
2625

2726
<!-- Refactored libraries/frameworks under /src -->
2827
<script src="src/TimeHandlr/TimeHandlr.js"></script>
28+
<script src="src/AudioPlayr/AudioPlayr.js"></script>
2929

3030
</head>
3131
<body onload="FullScreenMario()">

mario.js

+60-5
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ function FullScreenMario() {
5252
window.gameon = true;
5353
setMap(1,1);
5454

55-
// Load sounds after setting the map, since it uses clearAllTimeouts
56-
startLoadingSounds();
57-
5855
log("It took " + (Date.now() - time_start) + " milliseconds to start.");
5956
}
6057

@@ -153,6 +150,65 @@ function resetEvents() {
153150
});
154151
}
155152

153+
// Sounds are done with AudioPlayr.js
154+
function resetSounds() {
155+
window.sounds = {};
156+
window.theme = false;
157+
window.muted = (localStorage && localStorage.muted == "true");
158+
159+
window.AudioPlayer = new AudioPlayr({
160+
directory: "Sounds",
161+
getVolumeLocal: function() { return .49; },
162+
getThemeDefault: function() { return area.theme; },
163+
library: {
164+
Sounds: [
165+
"Bowser Falls",
166+
"Bowser Fires",
167+
"Break Block",
168+
"Bump",
169+
"Coin",
170+
"Ending",
171+
"Fireball",
172+
"Firework",
173+
"Flagpole",
174+
"Gain Life",
175+
"Game Over 2",
176+
"Game Over",
177+
"Hurry",
178+
"Into the Tunnel",
179+
"Jump Small",
180+
"Jump Super",
181+
"Kick",
182+
"Level Complete",
183+
"Player Dies",
184+
"Pause",
185+
"Pipe",
186+
"Power Down",
187+
"Powerup Appears",
188+
"Powerup",
189+
"Stage Clear",
190+
"Vine Emerging",
191+
"World Clear",
192+
"You Dead"
193+
],
194+
Themes: [
195+
"Castle",
196+
"Overworld",
197+
"Underwater",
198+
"Underworld",
199+
"Star",
200+
"Sky",
201+
"Hurry Castle",
202+
"Hurry Overworld",
203+
"Hurry Underwater",
204+
"Hurry Underworld",
205+
"Hurry Star",
206+
"Hurry Sky"
207+
]
208+
}
209+
});
210+
}
211+
156212
// Variables regarding the state of the game
157213
// This is called in setMap to reset everything
158214
function resetGameState(nocount) {
@@ -170,8 +226,7 @@ function resetGameState(nocount) {
170226
// Keep a history of pressed keys
171227
window.gamehistory = [];
172228
// Clear audio
173-
pauseAllSounds();
174-
sounds = {};
229+
AudioPlayer.pause();
175230
}
176231

177232
function scrollWindow(x, y) {

0 commit comments

Comments
 (0)