Commit 78ae2dfe by ogomez92

constructors

parent 8b7d6049
import uniqueRandom from 'unique-random';
class Cone {
constructor(world,x,z) {
this.world=world;
this.x =x;
this.y =0;
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;
}
get position() {
return [this.x, this.y, this.z];
}
}
export {Cone}
\ No newline at end of file
......@@ -18,7 +18,7 @@ export default class Game {
this.timer = Timer({
update: () => this.update(),
render: () => this.world.render()
});
},1/60);
}
start() {
......
export var gameID="";
import SoundSource from './sonoSource';
import Game from './game';
export var version="1.0";
export var version2="";
......@@ -18,7 +19,9 @@ fetch('http://oriolgomez.com/versions.php?id='+gameID)
resolve(data);
});
});
console.log("setup success");
const game=new Game();
game.start();
//const game=new Game();
//game.start();
console.log(SoundSource);
//let fuckyou=new SoundSource("menu_music",0,0,0);
//fuckyou.play();
}
......@@ -13,15 +13,14 @@ export default class Player {
this.alpha = 0;
this.speed =0.02;
this.moving = true;
this.sounds = new SoundHandler();
this.sounds = new SoundHandler(true);
this.stepCounter = 0;
this.nextStep = uniqueRandom(1, 1);
this.world=world;
this.x=this.world.size/2;
this.z=this.world.size/2;
this.y=0;
console.log(this.x,this.y,this.z);
}
}
get position() {
return [this.x, this.y, this.z];
......@@ -39,7 +38,7 @@ export default class Player {
}
}
move() {
this.position = [this.x + (Math.sin(this.alpha) * (this.speed/2)), 0, this.z + (Math.cos(this.alpha) * (this.speed/2))];
this.position = [this.x + (Math.sin(this.alpha) * (this.speed)), 0, this.z + (Math.cos(this.alpha) * (this.speed))];
this.stepCounter += this.speed;
if (this.stepCounter >= 1) {
this.stepCounter = 0;
......@@ -53,7 +52,7 @@ this.xWall=0;
this.wallMultiplier=50;
this.frontRay=new Ray(this);
let result=this.frontRay.scanWall(100,this.alpha);
speech.speak(result.distance);
//speech.speak(result.distance);
/*
if (this.zWall>2 && this.zWall<11) {
if (this.zTimer.elapsed>this.zWall*this.wallMultiplier) {
......
import {speech} from './tts';
class Ray {
constructor(player) {
this.result={
......@@ -38,7 +37,6 @@ let count=0;
this.z=this.z + (Math.cos(this.alpha));
this.distanceToWall++;
//the following if condition checks if either x or z are more than 0 or max grid size.
console.log("check "+count+": "+this.z);
if (this.x<1 || this.x>this.player.world.size || this.z<1 || this.z>this.player.world.size) {
foundWall=true;
this.result={
......
......@@ -16,14 +16,13 @@ maxDistance:50,
* @return {object} A Sound Source object
*/
export class SoundSource {
constructor(file, x = 0, y = 0, z = 0, loop = true) {
constructor(file, x = 0, y = 0, z = 0) {
this.x = x;
this.y = y;
this.z = z;
this.loop = loop;
this.sound = son.create(file);
this.sound.sound.loop = loop;
this.pan = this.sound.sound.effects.add(panner());
this.pan = this.sound.sound.effects.add(panner());
this.pos(this.x, this.y, this.z);
this.rate = 1;
this.speed = 0;
......@@ -31,7 +30,6 @@ export class SoundSource {
this.maxRate = 1.2;
this.toDestroy = false;
this.rateShiftSpeed = 0.015;
// This.sound.currentPosition = getRandomArbitrary(0, this.sound.duration);
this.sound.currentPosition = 0;
}
......@@ -51,10 +49,10 @@ export class SoundSource {
this.y = y;
this.z = z;
this.pan.setPosition(x, y, z);
console.log("pan: "+this.x+" "+this.z);
}
/** Empty update method */
update() {
}
}
}
\ No newline at end of file
import {SoundSource} from './sonoSource.js';
import SoundSource from './sonoSource.js';
import {son} from './sonoObject.js';
class SoundHandler {
......@@ -113,6 +113,7 @@ class SoundItem {
this.file = file;
this.threeD = threeD;
if (this.threeD == true) {
console.log("3d");
this.sound = new SoundSource(file, 0, 0, 0);
} else {
this.sound = son.create(file,stream);
......
......@@ -2,6 +2,7 @@ import SoundSource from './sonoSource';
import panner from 'sono/effects/panner';
import {son} from './sonoObject';
import Player from './player';
import {Cone} from './cone';
export default class World {
constructor(game) {
this.game = game;
......@@ -21,7 +22,7 @@ export default class World {
this.sidesPan.set(-1);
this.frontPan.setPosition(this.player.x,3,0);
this.backPan.setPosition(this.player.x,0,-3);
//this.back.play();
this.contents.static.push(new Cone(this,20,35));
}
update() {
this.player.update();
......
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