From 340012e4947ce835240268a20b3ce8fe04292210 Mon Sep 17 00:00:00 2001 From: Pontus Alexander Date: Thu, 19 Mar 2020 23:35:52 +0100 Subject: [PATCH] Sync with published result of episode 19. --- public/js/Level.js | 3 ++- public/js/MusicController.js | 2 +- public/js/MusicPlayer.js | 6 +++--- public/js/loaders/music.js | 6 +++--- public/levels/1-1.json | 1 - 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/public/js/Level.js b/public/js/Level.js index f37e110d..6a11403b 100644 --- a/public/js/Level.js +++ b/public/js/Level.js @@ -8,9 +8,10 @@ export default class Level { this.gravity = 1500; this.totalTime = 0; + this.music = new MusicController(); + this.comp = new Compositor(); this.entities = new Set(); - this.music = new MusicController(); this.entityCollider = new EntityCollider(this.entities); this.tileCollider = new TileCollider(); diff --git a/public/js/MusicController.js b/public/js/MusicController.js index 8a8c6b73..f946b4c8 100644 --- a/public/js/MusicController.js +++ b/public/js/MusicController.js @@ -6,4 +6,4 @@ export default class MusicController { setPlayer(player) { this.player = player; } -} \ No newline at end of file +} diff --git a/public/js/MusicPlayer.js b/public/js/MusicPlayer.js index 7bbab794..e38ff6fd 100644 --- a/public/js/MusicPlayer.js +++ b/public/js/MusicPlayer.js @@ -1,12 +1,12 @@ export default class MusicPlayer { - constructor(audio) { + constructor() { this.tracks = new Map(); } addTrack(name, url) { const audio = new Audio(); - audio.src = url; audio.loop = true; + audio.src = url; this.tracks.set(name, audio); } @@ -14,4 +14,4 @@ export default class MusicPlayer { const audio = this.tracks.get(name); audio.play(); } -} +} \ No newline at end of file diff --git a/public/js/loaders/music.js b/public/js/loaders/music.js index 3b9a96b4..94f9d3d8 100644 --- a/public/js/loaders/music.js +++ b/public/js/loaders/music.js @@ -1,12 +1,12 @@ -import MusicPlayer from '../MusicPlayer.js'; import {loadJSON} from '../loaders.js'; +import MusicPlayer from '../MusicPlayer.js'; export function loadMusicSheet(name) { return loadJSON(`/music/${name}.json`) .then(musicSheet => { const musicPlayer = new MusicPlayer(); - for (const [key, value] of Object.entries(musicSheet)) { - musicPlayer.addTrack(key, value.url); + for (const [name, track] of Object.entries(musicSheet)) { + musicPlayer.addTrack(name, track.url); } return musicPlayer; }); diff --git a/public/levels/1-1.json b/public/levels/1-1.json index 9ff57cce..34bc3f28 100644 --- a/public/levels/1-1.json +++ b/public/levels/1-1.json @@ -1,6 +1,5 @@ { "spriteSheet": "overworld", - "musicSheet": "overworld", "patterns": {