Commit c7d6178a authored by Oriol Gómez's avatar Oriol Gómez

remeow

parent 78ae2dfe
import uniqueRandom from 'unique-random';
import {speech} from './tts';
class Cone {
constructor(world,x,z) {
this.world=world;
......@@ -7,7 +8,10 @@ class Cone {
this.z =z;
this.sound=this.world.player.sounds.play("loop_cone");
this.sound.sound.pos(this.x,this.y,this.z);
this.sound.sound.sound.loop=true;
this.sound.sound.sound.sound.loop=true;
}
collide() {
speech.speak("collide");
}
get position() {
return [this.x, this.y, this.z];
......
......@@ -28,7 +28,7 @@ export default class Game {
update() {
this.world.update();
if (this.input.isJustPressed(KeyEvent.DOM_VK_UP))
this.world.player.movetest(1);
speech.speak(Math.round(this.world.player.x)+", "+Math.round(this.world.player.z));
if (this.input.isJustPressed(KeyEvent.DOM_VK_DOWN))
this.world.player.movetest(2);
if (this.input.isJustPressed(KeyEvent.DOM_VK_RIGHT))
......
export var gameID="";
import SoundSource from './sonoSource';
import {SoundSource} from './sonoSource';
import Game from './game';
export var version="1.0";
export var version2="";
......@@ -19,9 +19,6 @@ fetch('http://oriolgomez.com/versions.php?id='+gameID)
resolve(data);
});
});
//const game=new Game();
//game.start();
console.log(SoundSource);
//let fuckyou=new SoundSource("menu_music",0,0,0);
//fuckyou.play();
const game=new Game();
game.start();
}
......@@ -11,7 +11,7 @@ export default class Player {
this.zTimer=new OldTimer();
this.z = 0;
this.alpha = 0;
this.speed =0.02;
this.speed =0.04;
this.moving = true;
this.sounds = new SoundHandler(true);
this.stepCounter = 0;
......@@ -35,6 +35,7 @@ export default class Player {
update() {
if (this.moving) {
this.move();
}
}
move() {
......@@ -44,6 +45,11 @@ export default class Player {
this.stepCounter = 0;
this.sounds.playStatic('run_1');
this.checkWalls();
for (const i of this.world.contents.static) {
if (Math.round(this.x)==i.x && Math.round(this.z)==i.z) {
i.collide();
}
}
}
}
checkWalls() {
......
......@@ -16,7 +16,7 @@ maxDistance:50,
* @return {object} A Sound Source object
*/
export class SoundSource {
constructor(file, x = 0, y = 0, z = 0) {
constructor(file, x = 0, y = 0, z = 0,loop=true) {
this.x = x;
this.y = y;
this.z = z;
......
import SoundSource from './sonoSource.js';
import {SoundSource} from './sonoSource.js';
import {son} from './sonoObject.js';
class SoundHandler {
......@@ -16,11 +16,11 @@ class SoundHandler {
this.directional = directional;
}
playStatic(file, loop = 1, slot = -1,stream=false) {
playStatic(file, loop = 1, slot = -1,) {
if (slot = -1) {
slot = this.findFreeStaticSlot();
}
this.staticSounds[slot] = new SoundItem(file, this.directional,stream);
this.staticSounds[slot] = new SoundItem(file, false);
if (loop == 1) {
this.staticSounds[slot].sound.loop = true;
}
......@@ -65,7 +65,7 @@ class SoundHandler {
return -1;
}
play(file) {
play(file,loop=true) {
let slot = 0,
reuse = 0;
if (this.reuseSounds) {
......@@ -78,11 +78,11 @@ class SoundHandler {
}
if (typeof this.dynamicSounds[slot] === 'undefined') {
if (reuse == false) {
this.dynamicSounds[slot] = new SoundItem(file, this.directional);
this.dynamicSounds[slot] = new SoundItem(file, this.directional,loop);
}
} else if (reuse == false) {
this.dynamicSounds[slot].sound.destroy();
this.dynamicSounds[slot] = new SoundItem(file, directional);
this.dynamicSounds[slot] = new SoundItem(file, this.directional,loop);
}
this.dynamicSounds[slot].sound.play();
return this.dynamicSounds[slot];
......@@ -109,14 +109,13 @@ class SoundHandler {
}
}
class SoundItem {
constructor(file, threeD = false,stream=false) {
constructor(file, threeD = false,loop=true) {
this.file = file;
this.threeD = threeD;
if (this.threeD == true) {
console.log("3d");
this.sound = new SoundSource(file, 0, 0, 0);
this.sound = new SoundSource(file, 0, 0, 0,loop);
} else {
this.sound = son.create(file,stream);
this.sound = son.create(file);
}
}
......
......@@ -20,9 +20,9 @@ export default class World {
this.back=son.create("beep_back");
this.backPan=this.back.sound.effects.add(panner());
this.sidesPan.set(-1);
this.frontPan.setPosition(this.player.x,3,0);
this.backPan.setPosition(this.player.x,0,-3);
this.contents.static.push(new Cone(this,20,35));
this.frontPan.set(0);
this.backPan.set(0);
this.contents.static.push(new Cone(this,25,49));
}
update() {
this.player.update();
......@@ -33,7 +33,7 @@ this.contents.static.push(new Cone(this,20,35));
render() {
panner.setListenerPosition(this.player.x,this.player.y,this.player.z);
panner.setListenerOrientation(Math.sin(this.player.alpha), 0, Math.cos(this.player.alpha));
// panner.setListenerOrientation(Math.sin(this.player.alpha), 0, Math.cos(this.player.alpha));
for (const i of this.contents.dynamic) {
if (typeof i.sound !== undefined) {
i.sounds.update({x: i.x, y: i.y, z: i.z});
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment