Browse files

demo tweaks

  • Loading branch information...
1 parent 826d24a commit 1f25906316ebd20f3b1065dbc5b70cb2b8232faf @kig committed Feb 24, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 positional_audio.js
View
12 positional_audio.js
@@ -433,29 +433,39 @@ Demo.prototype = {
}
},
+ accel : 0,
update : function(t, dt) {
this.updateCameraTarget();
var cp = this.camera.position;
var camZ = cp.z, camX = cp.x, camY = cp.y;
var vz = Math.cos(this.xangle);
var vx = Math.sin(this.xangle);
- var speed = 1/10;
+ var speed = 1/60 + Math.min(1/10, 1/2000 * this.accel);
+ var ac = -1;
if (this.keyForward) {
camX += vx*dt*speed;
camZ += vz*dt*speed;
+ ac = 1;
}
if (this.keyBackward) {
camX -= vx*dt*speed;
camZ -= vz*dt*speed;
+ ac = 1;
}
if (this.keyLeft) {
camZ -= vx*dt*speed;
camX -= -vz*dt*speed;
+ ac = 1;
}
if (this.keyRight) {
camZ += vx*dt*speed;
camX += -vz*dt*speed;
+ ac = 1;
}
+ this.accel += ac;
+ if (ac < 0)
+ this.accel = 0;
+
this.camera.lookAt(this.camera.target.position);
this.setListenerPosition(this.camera, camX, camY, camZ, dt/1000);

0 comments on commit 1f25906

Please sign in to comment.