X-Git-Url: http://git.megabrutal.com/?p=ld40.git;a=blobdiff_plain;f=ld40.js;h=e981a9ef0768c78a6868a9e8c0ffdbae3f066660;hp=6a1eb77ea15a4a09b5d5c371c93c5941f4eb4ced;hb=7ce54d871c6931882855c54de3c0c24cc8023140;hpb=01e611f58651bb1b04da7694016fe45cebf861b0 diff --git a/ld40.js b/ld40.js index 6a1eb77..e981a9e 100644 --- a/ld40.js +++ b/ld40.js @@ -44,7 +44,7 @@ this.lasttime_shoot = 0; this.lasttime_mode = 0; this.lasttime_damage = 0; - this.speed = 150; + this.speed = SPEED_PLAYER; this.switchmode(MODE_DETERMINATION); this.weapon = new JusticeBlaster(game, this); this.weapon.bulletSpeed = SPEED_PPROJECTILE; @@ -73,6 +73,12 @@ } } + kill() { + this.health = 0; + this.healthBar.update(this.love, this.maxHealth, this.health); + super.kill(); + } + loveUp() { this.love++ this.maxHealth += this.love; @@ -263,9 +269,7 @@ nexttime_determination = Math.random() * WAIT_DETERMINATION; monsters = game.add.group(); - monsters.add(new Monster(400, 500)); - monsters.children.forEach(function(monster) { monster.enablePhysics(); }); - nexttime_monsterspawn = WAIT_MONSTERSPAWN; + nexttime_monsterspawn = WAIT_MONSTERSPAWN / 4; player = new Player(game.world.width / 2, game.world.height / 2); player.enablePhysics(); @@ -273,8 +277,6 @@ game.camera.follow(player); cursors = game.input.keyboard.createCursorKeys(); - keyboard_handler = keyPress_default; - } function update () { @@ -296,16 +298,11 @@ var monster = new Monster(Math.random() * game.world.width, Math.random() * game.world.height); monster.enablePhysics(); monsters.add(monster); - nexttime_monsterspawn = game.time.now + (WAIT_MONSTERSPAWN / player.love) + (Math.random() * WAIT_MONSTERSPAWN); + var waittime = WAIT_MONSTERSPAWN - ((Math.random() * 2000) * player.love); + nexttime_monsterspawn = game.time.now + waittime; + console.log('Next monster in ' + waittime); } if ((game.time.now - player.lastmovetime) > WAIT_KEY) player.body.velocity.x = player.body.velocity.y = 0; - if (keyboard_handler) keyboard_handler(); - - } - - function keyPress_default() { - - // Maybe needed later. }