Removed unused states and templating of main.js
authorJustin Worthe <justin.worthe@gmail.com>
Sun, 21 Sep 2014 06:00:06 +0000 (08:00 +0200)
committerJustin Worthe <justin.worthe@gmail.com>
Sun, 21 Sep 2014 06:00:06 +0000 (08:00 +0200)
Gruntfile.js
game/main.js
game/plugins/orientation.js [deleted file]
game/states/boot.js
game/states/gameover.js [deleted file]
game/states/load.js [moved from game/states/preload.js with 96% similarity]
game/states/menu.js [deleted file]
game/states/play.js
templates/_main.js.tpl [deleted file]

index c08fca4..1dfd9b1 100644 (file)
@@ -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
index e67845c..16071ff 100644 (file)
@@ -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 (file)
index 8ab922b..0000000
+++ /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;
index 80b7d4b..eade2ff 100644 (file)
@@ -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 (file)
index 7ffb7ed..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-'use strict';
-
-function GameOver() {}
-
-GameOver.prototype = {
-  preload: function () {
-  },
-  create: function () {
-  },
-  update: function () {
-  }
-};
-
-module.exports = GameOver;
similarity index 96%
rename from game/states/preload.js
rename to game/states/load.js
index 95ceb96..3ad43ef 100644 (file)
@@ -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 (file)
index c5a609f..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-'use strict';
-
-function Menu() {}
-
-Menu.prototype = {
-  preload: function() {
-  },
-  create: function() {
-  },
-  update: function() {
-  }
-};
-
-module.exports = Menu;
index 42d9a8f..5151438 100644 (file)
@@ -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 (file)
index 6a559db..0000000
+++ /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