- if (game.time.now > nexttime_monsterspawn)
- {
- 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);
+ update() {
+
+ game.physics.arcade.collide(player, walls);
+ game.physics.arcade.overlap(player, determinations, function(p,d) { p.overlap_determination(d); });
+ game.physics.arcade.overlap(player, monsters, function(p,m) { m.overlap_player(p); });
+
+ if (game.time.now > nexttime_determination)
+ {
+ var determination = new Determination((Math.random() * (game.world.width - ((WALL_THICKNESS + WALL_BORDER) * 4))) + ((WALL_THICKNESS + WALL_BORDER) * 2), (Math.random() * (game.world.height - ((WALL_THICKNESS + WALL_BORDER) * 4) - WALL_BORDERBOTTOM)) + ((WALL_THICKNESS + WALL_BORDER) * 2));
+ determination.enablePhysics();
+ determinations.add(determination);
+ nexttime_determination = game.time.now + (WAIT_DETERMINATION / 2) + (Math.random() * WAIT_DETERMINATION);
+ }
+
+ if (game.time.now > nexttime_monsterspawn)
+ {
+ var monster = new Monster(Math.random() * game.world.width, Math.random() * game.world.height);
+ monster.enablePhysics();
+ monsters.add(monster);
+ 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;
+
+ }
+ }
+
+ 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);
+