'use strict';
-var BonusPill = function(game, x, y, frame) {
- Phaser.Sprite.call(this, game, x, y, 'bonus-pill', frame);
- this.scale = {x: 0.01, y: 0.01};
- this.anchor = {x: 0.5, y: 0.5};
+var EntityBase = require('../entities/entityBase');
+
+var BonusPill = function(game, x, y) {
+ EntityBase.call(this, game, x, y, 'bonus-pill');
this.score = 10;
};
-BonusPill.prototype = Object.create(Phaser.Sprite.prototype);
+BonusPill.prototype = Object.create(EntityBase.prototype);
BonusPill.prototype.constructor = BonusPill;
-BonusPill.prototype.getBounds = function() {
- return new Phaser.Rectangle(this.x, this.y, 0.2, 0.2);
-};
-
module.exports = BonusPill;
--- /dev/null
+'use strict';
+
+var EntityBase = function(game, x, y, key) {
+ Phaser.Sprite.call(this, game, x, y, key);
+ this.scale = {x: 0.01, y: 0.01};
+ this.anchor = {x: 0.5, y: 0.5};
+};
+EntityBase.prototype = Object.create(Phaser.Sprite.prototype);
+
+EntityBase.prototype.getBounds = function() {
+ return new Phaser.Rectangle(this.x, this.y, 0.5, 0.5);
+};
+
+module.exports = EntityBase;
\ No newline at end of file
'use strict';
-var Pill = function(game, x, y, frame) {
- Phaser.Sprite.call(this, game, x, y, 'pill', frame);
- this.scale = {x: 0.01, y: 0.01};
- this.anchor = {x: 0.5, y: 0.5};
+var EntityBase = require('../entities/entityBase');
+
+var Pill = function(game, x, y) {
+ EntityBase.call(this, game, x, y, 'pill');
this.score = 1;
};
-Pill.prototype = Object.create(Phaser.Sprite.prototype);
+Pill.prototype = Object.create(EntityBase.prototype);
Pill.prototype.constructor = Pill;
-Pill.prototype.getBounds = function() {
- return new Phaser.Rectangle(this.x, this.y, 0.2, 0.2);
-};
-
module.exports = Pill;
'use strict';
-var Player = function(game, x, y, key, frame, soundKey) {
+var EntityBase = require('../entities/entityBase');
+
+var Player = function(game, x, y, key, soundKey) {
var player = this;
- Phaser.Sprite.call(this, game, x, y, key, frame);
+ EntityBase.call(this, game, x, y, key);
this.animations.add('active', [0]);
this.animations.add('waiting', [1]);
this.animations.add('activePoison', [2]);
};
};
-Player.prototype = Object.create(Phaser.Sprite.prototype);
+Player.prototype = Object.create(EntityBase.prototype);
Player.prototype.constructor = Player;
Player.prototype.update = function() {
this.lastTween = null;
};
-Player.prototype.getBounds = function() {
- return new Phaser.Rectangle(this.x, this.y, 0.2, 0.2);
-};
-
module.exports = Player;
'use strict';
-var PoisonPill = function(game, x, y, frame) {
- Phaser.Sprite.call(this, game, x, y, 'poison-pill', frame);
- this.scale = {x: 0.01, y: 0.01};
- this.anchor = {x: 0.5, y: 0.5};
+var EntityBase = require('../entities/entityBase');
- this.score = 1;
+var PoisonPill = function(game, x, y) {
+ EntityBase.call(this, game, x, y, 'poison-pill');
};
-PoisonPill.prototype = Object.create(Phaser.Sprite.prototype);
+PoisonPill.prototype = Object.create(EntityBase.prototype);
PoisonPill.prototype.constructor = PoisonPill;
-PoisonPill.prototype.getBounds = function() {
- return new Phaser.Rectangle(this.x, this.y, 0.2, 0.2);
-};
-
module.exports = PoisonPill;
'use strict';
-var Wall = function(game, x, y, frame) {
- Phaser.Sprite.call(this, game, x, y, 'wall', frame);
- this.scale = {x: 0.01, y: 0.01};
- this.anchor = {x: 0.5, y: 0.5};
+var EntityBase = require('../entities/entityBase');
+
+var Wall = function(game, x, y) {
+ EntityBase.call(this, game, x, y, 'wall');
};
-Wall.prototype = Object.create(Phaser.Sprite.prototype);
+Wall.prototype = Object.create(EntityBase.prototype);
Wall.prototype.constructor = Wall;
module.exports = Wall;
this.pills.add(new BonusPill(this.game, x, y));
break;
case 'A':
- this.playerA = new Player(this.game, x, y, 'player-a', 0, 'omSound');
+ this.playerA = new Player(this.game, x, y, 'player-a', 'omSound');
this.players.add(this.playerA);
break;
case 'B':
- this.playerB = new Player(this.game, x, y, 'player-b', 0, 'nomSound');
+ this.playerB = new Player(this.game, x, y, 'player-b', 'nomSound');
this.players.add(this.playerB);
break;
case '|':