summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/main.js9
-rw-r--r--game/plugins/orientation.js40
-rw-r--r--game/states/boot.js2
-rw-r--r--game/states/gameover.js14
-rw-r--r--game/states/load.js (renamed from game/states/preload.js)6
-rw-r--r--game/states/menu.js14
-rw-r--r--game/states/play.js5
7 files changed, 5 insertions, 85 deletions
diff --git a/game/main.js b/game/main.js
index e67845c..16071ff 100644
--- a/game/main.js
+++ b/game/main.js
@@ -1,18 +1,11 @@
'use strict';
-//global variables
window.onload = function () {
var game = new Phaser.Game(1750, 1100, Phaser.AUTO, 'interactive-pacbot');
- var Orientation = require('./plugins/orientation');
- game.orientation = new Orientation();
-
- // Game States
game.state.add('boot', require('./states/boot'));
- game.state.add('gameover', require('./states/gameover'));
- game.state.add('menu', require('./states/menu'));
+ game.state.add('load', require('./states/load'));
game.state.add('play', require('./states/play'));
- game.state.add('preload', require('./states/preload'));
game.state.start('boot');
diff --git a/game/plugins/orientation.js b/game/plugins/orientation.js
deleted file mode 100644
index 8ab922b..0000000
--- a/game/plugins/orientation.js
+++ /dev/null
@@ -1,40 +0,0 @@
-'use strict';
-
-var Orientation = function() {
- var self = this;
-
- self.onLeft = new Phaser.Signal();
- self.onRight = new Phaser.Signal();
- self.onUp = new Phaser.Signal();
- self.onDown = new Phaser.Signal();
-
- self.previousEvent = {
- gamma: 0,
- beta: 0
- };
-
- self.threshhold = 15;
-
- if (window.DeviceOrientationEvent) {
- window.addEventListener('deviceorientation', function(eventData) {
- if (eventData.gamma < -self.threshhold && self.previousEvent.gamma >= -self.threshhold) {
- self.onLeft.dispatch();
- }
- if (eventData.gamma > self.threshhold && self.previousEvent.gamma <= self.threshhold) {
- self.onRight.dispatch();
- }
- if (eventData.beta < -self.threshhold && self.previousEvent.beta >= -self.threshhold) {
- self.onUp.dispatch();
- }
- if (eventData.beta > self.threshhold && self.previousEvent.beta <= self.threshhold) {
- self.onDown.dispatch();
- }
-
- self.previousEvent.gamma = eventData.gamma;
- self.previousEvent.beta = eventData.beta;
- });
- }
-};
-
-
-module.exports = Orientation;
diff --git a/game/states/boot.js b/game/states/boot.js
index 80b7d4b..eade2ff 100644
--- a/game/states/boot.js
+++ b/game/states/boot.js
@@ -9,7 +9,7 @@ Boot.prototype = {
},
create: function() {
this.game.input.maxPointers = 1;
- this.game.state.start('preload');
+ this.game.state.start('load');
}
};
diff --git a/game/states/gameover.js b/game/states/gameover.js
deleted file mode 100644
index 7ffb7ed..0000000
--- a/game/states/gameover.js
+++ /dev/null
@@ -1,14 +0,0 @@
-'use strict';
-
-function GameOver() {}
-
-GameOver.prototype = {
- preload: function () {
- },
- create: function () {
- },
- update: function () {
- }
-};
-
-module.exports = GameOver;
diff --git a/game/states/preload.js b/game/states/load.js
index 95ceb96..3ad43ef 100644
--- a/game/states/preload.js
+++ b/game/states/load.js
@@ -1,11 +1,11 @@
'use strict';
-function Preload() {
+function Load() {
this.asset = null;
this.ready = false;
}
-Preload.prototype = {
+Load.prototype = {
preload: function() {
this.asset = this.add.sprite(this.width/2,this.height/2, 'preloader');
this.asset.anchor.setTo(0.5, 0.5);
@@ -49,4 +49,4 @@ Preload.prototype = {
}
};
-module.exports = Preload;
+module.exports = Load;
diff --git a/game/states/menu.js b/game/states/menu.js
deleted file mode 100644
index c5a609f..0000000
--- a/game/states/menu.js
+++ /dev/null
@@ -1,14 +0,0 @@
-'use strict';
-
-function Menu() {}
-
-Menu.prototype = {
- preload: function() {
- },
- create: function() {
- },
- update: function() {
- }
-};
-
-module.exports = Menu;
diff --git a/game/states/play.js b/game/states/play.js
index 42d9a8f..5151438 100644
--- a/game/states/play.js
+++ b/game/states/play.js
@@ -257,11 +257,6 @@ Play.prototype = {
this.game.input.gamepad.start();
- this.game.orientation.onLeft.add(this.moveActivePlayer.bind(this, -1, 0), this);
- this.game.orientation.onRight.add(this.moveActivePlayer.bind(this, 1, 0), this);
- this.game.orientation.onUp.add(this.moveActivePlayer.bind(this, 0, -1), this);
- this.game.orientation.onDown.add(this.moveActivePlayer.bind(this, 0, 1), this);
-
this.game.input.keyboard.addKey(this.playerBControls.poison).onDown.add(this.togglePoisonPill.bind(this, this.playerB), this);
this.game.input.keyboard.addKey(this.playerAControls.poison).onDown.add(this.togglePoisonPill.bind(this, this.playerA), this);