Skip to content

Commit

Permalink
Sync with published result of episode 19.
Browse files Browse the repository at this point in the history
  • Loading branch information
pomle committed Mar 19, 2020
1 parent 723e231 commit 340012e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion public/js/Level.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion public/js/MusicController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ export default class MusicController {
setPlayer(player) {
this.player = player;
}
}
}
6 changes: 3 additions & 3 deletions public/js/MusicPlayer.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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);
}

playTrack(name) {
const audio = this.tracks.get(name);
audio.play();
}
}
}
6 changes: 3 additions & 3 deletions public/js/loaders/music.js
Original file line number Diff line number Diff line change
@@ -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;
});
Expand Down
1 change: 0 additions & 1 deletion public/levels/1-1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"spriteSheet": "overworld",

"musicSheet": "overworld",

"patterns": {
Expand Down

0 comments on commit 340012e

Please sign in to comment.