X-Git-Url: http://git.megabrutal.com/?p=shapeshift.git;a=blobdiff_plain;f=shapeshift.js;h=14b4fda470cdcb3ee4ed6b72c01fde2a890ac306;hp=44d42fda5f84286c9d04b0ce43e8beb141435604;hb=HEAD;hpb=9646274677048d57e16a58389ae8f14e29459bb0 diff --git a/shapeshift.js b/shapeshift.js index 44d42fd..14b4fda 100644 --- a/shapeshift.js +++ b/shapeshift.js @@ -63,15 +63,12 @@ } }, false); - class Guard extends Phaser.Sprite { - constructor(x, y, sprite, dialogues) { - //var guard = game.add.sprite(x, y, sprite); + class Entity extends Phaser.Sprite { + constructor(x, y, sprite) { super(game, x, y, sprite); this.anchor.setTo(.5,.5); this.scale.x = 0.5; this.scale.y = this.scale.x; - this.dialogues = dialogues; - guards.add(this); } enablePhysics() { @@ -83,6 +80,25 @@ } } + class Player extends Entity { + constructor(x, y, sprite) { + super(x, y, sprite); + this.anchor.setTo(.4,.5); + this.pushed = 0; + this.shape = SHAPE_GIRL; + this.learnedBird = false; + } + } + + class Guard extends Entity { + constructor(x, y, sprite, dialogues) { + //var guard = game.add.sprite(x, y, sprite); + super(x, y, sprite); + this.dialogues = dialogues; + guards.add(this); + } + } + function sign(n) { if (n >= 0) { return 1 } else { return -1 }; } @@ -114,18 +130,10 @@ ground.body.immovable = true; - player = game.add.sprite(64, game.world.height - 200, 'player_girl'); - player.anchor.setTo(.4,.5); - player.scale.x = 0.5; - player.scale.y = player.scale.x; - game.physics.arcade.enable(player); - player.body.bounce.y = 0.2; - player.body.bounce.x = 0.2; - player.body.gravity.y = 300; - player.body.collideWorldBounds = true; - player.pushed = 0; - player.shape = SHAPE_GIRL; - player.learnedBird = false; + //player = game.add.sprite(64, game.world.height - 200, 'player_girl'); + player = new Player(64, game.world.height - 200, 'player_girl'); + player.enablePhysics(); + game.add.existing(player); game.camera.follow(player); guards = game.add.group();