summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gruntfile.js21
-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
-rw-r--r--templates/_main.js.tpl15
9 files changed, 6 insertions, 120 deletions
diff --git a/Gruntfile.js b/Gruntfile.js
index c08fca4..1dfd9b1 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -56,7 +56,6 @@ module.exports = function (grunt) {
copy: {
dist: {
files: [
- // includes files within path and its sub-directories
{ expand: true, src: ['assets/**'], dest: 'dist/' },
{ expand: true, flatten: true, src: ['vendor/*.js'], dest: 'dist/js/' },
{ expand: true, src: ['css/**'], dest: 'dist/' },
@@ -72,25 +71,7 @@ module.exports = function (grunt) {
}
});
- grunt.registerTask('build', ['buildBootstrapper', 'browserify','copy']);
+ grunt.registerTask('build', ['browserify','copy']);
grunt.registerTask('serve', ['build', 'connect:livereload', 'open', 'watch']);
grunt.registerTask('default', ['serve']);
- grunt.registerTask('prod', ['build', 'copy']);
-
- grunt.registerTask('buildBootstrapper', 'builds the bootstrapper file correctly', function() {
- var stateFiles = grunt.file.expand('game/states/*.js');
- var gameStates = [];
- var statePattern = new RegExp(/(\w+).js$/);
- stateFiles.forEach(function(file) {
- var state = file.match(statePattern)[1];
- if (!!state) {
- gameStates.push({shortName: state, stateName: _.capitalize(state) + 'State'});
- }
- });
- config.gameStates = gameStates;
- console.log(config);
- var bootstrapper = grunt.file.read('templates/_main.js.tpl');
- bootstrapper = grunt.template.process(bootstrapper,{data: config});
- grunt.file.write('game/main.js', bootstrapper);
- });
}; \ No newline at end of file
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);
diff --git a/templates/_main.js.tpl b/templates/_main.js.tpl
deleted file mode 100644
index 6a559db..0000000
--- a/templates/_main.js.tpl
+++ /dev/null
@@ -1,15 +0,0 @@
-'use strict';
-
-//global variables
-window.onload = function () {
- var game = new Phaser.Game(<%= gameWidth %>, <%= gameHeight %>, Phaser.AUTO, '<%= _.slugify(projectName) %>');
-
- var Orientation = require('./plugins/orientation');
- game.orientation = new Orientation();
-
- // Game States
- <% _.forEach(gameStates, function(gameState) { %>game.state.add('<%= gameState.shortName %>', require('./states/<%= gameState.shortName %>'));
- <% }); %>
-
- game.state.start('boot');
-}; \ No newline at end of file