Skip to content

Commit b8f6acb

Browse files
committed
move music away from preload
1 parent 06e17ce commit b8f6acb

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

game/preload.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ var dirtBagShakeSound;
1616
var itemAtlas;
1717
var fullAtlas;
1818

19-
var MusicPlayer;
2019
function preload() {
2120
// Load the default image
2221
//loadDefaultImage();
@@ -74,15 +73,6 @@ function preload() {
7473
gameUIFont = loadFont('CalibrationGothicNbpLatin-rYmy.ttf');
7574
//console.log("font:", gameUIFont);
7675

77-
// tell p5 which formats to expect
78-
soundFormats('wav');
79-
80-
// loadSound paths are relative to your sketch.html
81-
const mainTheme = loadSound('audio/music/bgtheme.wav');
82-
const battle = loadSound('audio/music/battletheme.wav');
83-
const ambiance = loadSound('audio/music/WorkingAmbianceSample.wav');
84-
85-
MusicPlayer = new MusicSystem(mainTheme, [battle, ambiance]);
8676
//load sounds
8777
let keys = Object.keys(soundDic);
8878
for(let i = 0; i < keys.length; i++){

game/sketch.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var dirtBagUI = {};
1212
var Debuging = false;
1313

1414

15+
var MusicPlayer;
1516

1617
function setup() {
1718
// Create a responsive canvas
@@ -22,6 +23,17 @@ function setup() {
2223
background(220);
2324
angleMode(DEGREES);
2425

26+
27+
28+
// tell p5 which formats to expect
29+
soundFormats('wav');
30+
31+
// loadSound paths are relative to your sketch.html
32+
const mainTheme = loadSound('audio/music/bgtheme.wav');
33+
const battle = loadSound('audio/music/battletheme.wav');
34+
const ambiance = loadSound('audio/music/WorkingAmbianceSample.wav');
35+
36+
MusicPlayer = new MusicSystem(mainTheme, [battle, ambiance]);
2537
// Prevent right-click context menu on p5.js canvases
2638
const canvases = document.getElementsByClassName("p5Canvas");
2739
for (let element of canvases) {

0 commit comments

Comments
 (0)