X-Git-Url: http://git.megabrutal.com/?p=shapeshift.git;a=blobdiff_plain;f=shapeshift.js;fp=shapeshift.js;h=37481aaab41c2f94088815ffebe602a3e738b873;hp=44d42fda5f84286c9d04b0ce43e8beb141435604;hb=dca5c89e801b197f5b724394deddbda523ceb304;hpb=9646274677048d57e16a58389ae8f14e29459bb0 diff --git a/shapeshift.js b/shapeshift.js index 44d42fd..37481aa 100644 --- a/shapeshift.js +++ b/shapeshift.js @@ -63,6 +63,26 @@ } }, false); + class Player extends Phaser.Sprite { + constructor(x, y, sprite) { + super(game, x, y, sprite); + this.anchor.setTo(.4,.5); + this.scale.x = 0.5; + this.scale.y = this.scale.x; + this.pushed = 0; + this.shape = SHAPE_GIRL; + this.learnedBird = false; + } + + enablePhysics() { + game.physics.arcade.enable(this); + this.body.bounce.y = 0.2; + this.body.bounce.x = 0.2; + this.body.gravity.y = 300; + this.body.collideWorldBounds = true; + } + } + class Guard extends Phaser.Sprite { constructor(x, y, sprite, dialogues) { //var guard = game.add.sprite(x, y, sprite); @@ -114,18 +134,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();