X-Git-Url: http://git.megabrutal.com/?p=ld40.git;a=blobdiff_plain;f=ld40.js;h=7bd582e1413288af1753a4c0c22bfebe3fec2a60;hp=dffcd503ababccef2f6f680c10315ebcbc47f79e;hb=731aa57b3da0e89209ae2aaf19ee4960a7ae564f;hpb=238b09df43c9772cd33c469b837edad3c9ca7955 diff --git a/ld40.js b/ld40.js index dffcd50..7bd582e 100644 --- a/ld40.js +++ b/ld40.js @@ -14,6 +14,7 @@ const WAIT_MONSTERSHOOT = 500; const WAIT_MONSTERSPAWN = 20000; const WAIT_DETERMINATION = 4000; + const WAIT_DEATH = 4000; const WALL_THICKNESS = 16; const WALL_BORDER = 8; const WALL_BORDERBOTTOM = 48; @@ -48,11 +49,16 @@ this.lasttime_shoot = 0; this.lasttime_mode = 0; this.lasttime_damage = 0; + this.lasttime_death = 0; this.speed = SPEED_PLAYER; this.switchmode(MODE_DETERMINATION); this.weapon = new JusticeBlaster(game, this); this.weapon.bulletSpeed = SPEED_PPROJECTILE; this.healthBar = new HealthBar(60, game.world.height - (WALL_BORDERBOTTOM / 2)); + this.soulbreakEmitter = this.game.add.emitter(0, 0, 8); + this.soulbreakEmitter.gravity = 1000; + this.soulbreakEmitter.setXSpeed(-300, 300); + this.soulbreakEmitter.makeParticles('soulbreak'); } enablePhysics() { @@ -81,6 +87,10 @@ this.health = 0; this.healthBar.update(this.love, this.maxHealth, this.health); super.kill(); + this.soulbreakEmitter.x = this.x; + this.soulbreakEmitter.y = this.y; + this.soulbreakEmitter.explode(2000, 8); + this.lasttime_death = this.game.time.now; } loveUp() { @@ -252,6 +262,13 @@ class GamePlay extends Phaser.State { + constructor() { + + super(); + game.state.add('GameOver', GameOver, false); + + } + preload() { game.load.image('wall', 'wall.png'); @@ -259,6 +276,7 @@ game.load.image('monster', 'monster.png'); game.load.image('determination', 'determination.png'); game.load.image('projectile', 'projectile.png'); + game.load.image('soulbreak', 'soulbreak.png'); } @@ -318,5 +336,30 @@ if ((game.time.now - player.lastmovetime) > WAIT_KEY) player.body.velocity.x = player.body.velocity.y = 0; + if ((!player.alive) && (game.time.now > (player.lasttime_death + WAIT_DEATH))) + { + game.state.start('GameOver'); + } + + } + } + + class GameOver extends Phaser.State { + + create() { + + this.game.add.text(this.game.world.width / 2, 0, "GAME\nOVER", { align: 'center', fill: 'white', font: 'Ubuntu Mono', fontSize: 160, fontWeight: 'bold' }).anchor.setTo(0.5, 0); + this.game.add.text(this.game.world.width / 2, this.game.world.height * 0.75, "Stay determined...", { align: 'center', fill: 'white', font: 'Ubuntu Mono', fontSize: 24, fontWeight: 'bold' }).anchor.setTo(0.5, 0); + } + + update() { + + if (this.game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)) + { + this.game.state.start('GamePlay'); + } + + } + }