Commit e0aa6b81 by Oriol Gómez

keycodes

parent a4e61a1e
node_modules
www/js/compiled.js
compiled.js
This source diff could not be displayed because it is too large. You can view the blob instead.
export default class InputHandler {
constructor(world, doGyro=false) {
this.world = world;
this.input = new KeyboardInput();
if (doGyro == true) {
var id = document.getElementById("touchArea");
//this.touchInput = new Hammer(id);
this.gn = new GyroNorm();
}
this.turnLeft = false;
this.turnRight = false;
this.doGyro = doGyro;
this.init();
}
init() {
if (this.doGyro == true) {
this.touchInput.on("tap", function(event) {
that.world.player.startAccelerating();
});
var that = this;
this.gn.init().then(function() {
that.gn.start(function(data) {
if (data.dm.gx < -2) {
that.world.player.startTurning(-1);
}
else if (data.dm.gx > 2) {
that.world.player.startTurning(1);
}
else {
that.world.player.stopTurning();
}
});
});
}
this.input.init();
}
update() {
if (this.input.isJustPressed(KeyEvent.DOM_VK_C)) {
speech.speak(this.world.player.x + ", " + this.world.player.y + ", " + this.world.player.z);
}
if (this.input.isJustPressed(KeyEvent.DOM_VK_Q)) {
this.world.endGame();
}
if (this.input.isJustPressed(KeyEvent.DOM_VK_SPACE)) {
this.world.player.startAccelerating();
}
if (this.input.isJustPressed(KeyEvent.DOM_VK_LEFT)) {
this.world.player.startTurning(-1);
}
if (this.input.isJustReleased(KeyEvent.DOM_VK_LEFT)) {
this.world.player.stopTurning();
}
if (this.input.isJustPressed(KeyEvent.DOM_VK_RIGHT)) {
this.world.player.startTurning(1);
}
if (this.input.isJustReleased(KeyEvent.DOM_VK_RIGHT)) {
this.world.player.stopTurning();
}
}
}
\ No newline at end of file
'use strict';
if (typeof KeyEvent == "undefined") {
export var KeyEvent = {
var KeyEvent = {
DOM_VK_CANCEL: 3,
DOM_VK_HELP: 6,
DOM_VK_BACK_SPACE: 8,
......@@ -118,4 +118,5 @@ if (typeof KeyEvent == "undefined") {
DOM_VK_QUOTE: 222,
DOM_VK_META: 224
};
}
\ No newline at end of file
}
export {KeyEvent}
\ No newline at end of file
//import {create,canPlay} from 'sono/core/sono';
//import {cloneBuffer} from 'sono/core/utils/utils'
import sono from 'sono';
import {isElectron} from 'header';
var playOnceTimer;
class SoundObjectItem {
constructor(file, callback=0, tag=0) {
console.log(file);
......@@ -222,7 +221,9 @@ class SoundObject {
this.oneShotSound.stop();
this.oneShotSound.play();
var that = this;
this.oneShotSound.on("ended", function() { that.oneShotSound.destroy(); });
this.oneShotSound.on("ended", function() {
if (that.oneShotSound.playing==false) that.oneShotSound.destroy();
});
}
......
......@@ -5,7 +5,7 @@ this.elapsed;
this.paused=true;
this.lastTime=0;
this.pauseWhen=0;
this.started=false;
this.started=true;
}
isActive() {
return !paused & started;
......
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