Skip to content

Commit 584a4a4

Browse files
committed
removed changes to files causing conflict
1 parent c04edfd commit 584a4a4

File tree

5 files changed

+33
-41
lines changed

5 files changed

+33
-41
lines changed

src/audio.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/audio.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as THREE from "three";
2+
3+
export const addAudioListenerToCamera = (camera) => {
4+
camera.camera.add(createAudioListener());
5+
};
6+
7+
const songUrl = require("./sounds/bg1.mp3");
8+
const songUrl1 = require("./sounds/tile.mp3");
9+
10+
export const createAudioListener = () => {
11+
const listener = new THREE.AudioListener();
12+
13+
const audioLoader = new THREE.AudioLoader();
14+
15+
const sound = new THREE.Audio(listener);
16+
17+
audioLoader.load(songUrl, (buffer) => {
18+
sound.setBuffer(buffer);
19+
sound.setLoop(true);
20+
sound.setVolume(0.3);
21+
sound.play();
22+
});
23+
24+
return listener;
25+
};
26+
27+
export const tile_sound = () => {
28+
const audio = new Audio(songUrl1);
29+
audio.play();
30+
}

src/game.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from "three";
1818
import * as THREE from "three";
1919
import { addAudioListenerToCamera } from "./audio";
20-
import { addAudioListenerToCamera1 } from "./audio";
20+
import { tile_sound } from "./audio";
2121

2222
import { GameCamera } from "./game-camera";
2323
import { MovingTile } from "./moving-tile";
@@ -65,7 +65,7 @@ export class Game {
6565
this.renderer.domElement.addEventListener("click", this.onClick.bind(this));
6666

6767
this.animate();
68-
addAudioListenerToCamera(this.camera); //bg music
68+
addAudioListenerToCamera(this.camera);
6969

7070
}
7171

@@ -75,7 +75,7 @@ export class Game {
7575
this.cutBox();
7676
this.moveUp();
7777
this.clicked = false
78-
addAudioListenerToCamera1();
78+
tile_sound();
7979
}
8080

8181
onWindowResize() {

src/sounds/bg.wav

-7.57 MB
Binary file not shown.

src/sounds/bg1.ogg

-2.67 MB
Binary file not shown.

0 commit comments

Comments
 (0)