diff options
Diffstat (limited to 'game')
-rw-r--r-- | game/main.js | 16 | ||||
-rw-r--r-- | game/states/boot.js | 16 | ||||
-rw-r--r-- | game/states/gameover.js | 14 | ||||
-rw-r--r-- | game/states/menu.js | 14 | ||||
-rw-r--r-- | game/states/play.js | 14 | ||||
-rw-r--r-- | game/states/preload.js | 29 |
6 files changed, 103 insertions, 0 deletions
diff --git a/game/main.js b/game/main.js new file mode 100644 index 0000000..0f5208f --- /dev/null +++ b/game/main.js @@ -0,0 +1,16 @@ +'use strict'; + +//global variables +window.onload = function () { + var game = new Phaser.Game(800, 600, Phaser.AUTO, 'interactive-pacbot'); + + // 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('play', require('./states/play')); + game.state.add('preload', require('./states/preload')); + + + game.state.start('boot'); +};
\ No newline at end of file diff --git a/game/states/boot.js b/game/states/boot.js new file mode 100644 index 0000000..91cbb25 --- /dev/null +++ b/game/states/boot.js @@ -0,0 +1,16 @@ +'use strict'; + +function Boot() { +} + +Boot.prototype = { + preload: function() { + this.load.image('preloader', 'assets/preloader.gif'); + }, + create: function() { + this.game.input.maxPointers = 1; + this.game.state.start('preload'); + } +}; + +module.exports = Boot; diff --git a/game/states/gameover.js b/game/states/gameover.js new file mode 100644 index 0000000..7ffb7ed --- /dev/null +++ b/game/states/gameover.js @@ -0,0 +1,14 @@ +'use strict'; + +function GameOver() {} + +GameOver.prototype = { + preload: function () { + }, + create: function () { + }, + update: function () { + } +}; + +module.exports = GameOver; diff --git a/game/states/menu.js b/game/states/menu.js new file mode 100644 index 0000000..c5a609f --- /dev/null +++ b/game/states/menu.js @@ -0,0 +1,14 @@ +'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 new file mode 100644 index 0000000..1e9e3e1 --- /dev/null +++ b/game/states/play.js @@ -0,0 +1,14 @@ +'use strict'; + +function Play() {} + +Play.prototype = { + preload: function() { + }, + create: function() { + }, + update: function() { + } +}; + +module.exports = Play; diff --git a/game/states/preload.js b/game/states/preload.js new file mode 100644 index 0000000..877027f --- /dev/null +++ b/game/states/preload.js @@ -0,0 +1,29 @@ +'use strict'; + +function Preload() { + this.asset = null; + this.ready = false; +} + +Preload.prototype = { + preload: function() { + this.asset = this.add.sprite(this.width/2,this.height/2, 'preloader'); + this.asset.anchor.setTo(0.5, 0.5); + + this.load.onLoadComplete.addOnce(this.onLoadComplete, this); + this.load.setPreloadSprite(this.asset); + }, + create: function() { + this.asset.cropEnabled = false; + }, + update: function() { + if(!!this.ready) { + this.game.state.start('menu'); + } + }, + onLoadComplete: function() { + this.ready = true; + } +}; + +module.exports = Preload; |