diff --git a/js/level.js b/js/level.js index 9c8ace1..c96b091 100644 --- a/js/level.js +++ b/js/level.js @@ -21,8 +21,9 @@ const level = { // this.warehouse(); // this.highrise(); // this.office(); - b.giveGuns(1) // set a starting gun for testing - mech.fieldUpgrades[5]() //give a field power up for testing + // b.giveGuns(1) // set a starting gun for testing + b.giveGuns("all", 1000) + // mech.fieldUpgrades[5]() //give a field power up for testing } else { spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns this[this.levels[this.onLevel]](); //picks the current map from the the levels array @@ -724,7 +725,7 @@ const level = { spawn.randomBoss(350, -500, 1) spawn.randomBoss(4000, -350, 0.6); spawn.randomBoss(2750, -550, 0.1); - if (game.levelsCleared > 2) spawn.suckerBoss(3000, -1000); + if (game.levelsCleared > 2) spawn.suckerBoss(3000 + 1000 * Math.random(), -500 * Math.random()); //add mini boss, giant hopper? or a black hole that spawns hoppers? }, diff --git a/js/mobs.js b/js/mobs.js index 5dcb893..7855c7f 100644 --- a/js/mobs.js +++ b/js/mobs.js @@ -554,10 +554,8 @@ const mobs = { // ctx.fillStyle = "rgba(0,0,0,0.1)"; // ctx.fill(); // }, - curl() { + curl(range = 1000) { //cause all mobs, and bodies to rotate in a circle - const range = 1000 - applyCurl = function (center, array) { for (let i = 0; i < array.length; ++i) { const sub = Matter.Vector.sub(center, array[i].position) @@ -570,8 +568,8 @@ const mobs = { //apply curl force const mag = Matter.Vector.mult(curlVector, 10) Matter.Body.setVelocity(array[i], { - x: array[i].velocity.x * 0.99 + mag.x * 0.01, - y: array[i].velocity.y * 0.99 + mag.y * 0.01 + x: array[i].velocity.x * 0.94 + mag.x * 0.06, + y: array[i].velocity.y * 0.94 + mag.y * 0.06 }) //draw curl @@ -586,13 +584,12 @@ const mobs = { } applyCurl(this.position, mob); applyCurl(this.position, body); - - + applyCurl(this.position, [player]); //draw limit - ctx.beginPath(); - ctx.arc(this.position.x, this.position.y, range, 0, 2 * Math.PI); - ctx.fillStyle = "rgba(55,255,255, 0.1)"; - ctx.fill(); + // ctx.beginPath(); + // ctx.arc(this.position.x, this.position.y, range, 0, 2 * Math.PI); + // ctx.fillStyle = "rgba(55,255,255, 0.1)"; + // ctx.fill(); }, pullPlayer() { if (this.seePlayer.yes && Matter.Vector.magnitudeSquared(Matter.Vector.sub(this.position, player.position)) < 1000000) { diff --git a/js/spawn.js b/js/spawn.js index 52474bb..c504ff5 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -487,7 +487,7 @@ const spawn = { me.collisionFilter.mask = 0x001101 // me.frictionAir = 0.005; me.memory = 1000; - Matter.Body.setDensity(me, 0.3); //extra dense //normal is 0.001 //makes effective life much larger + Matter.Body.setDensity(me, 0.05); //extra dense //normal is 0.001 //makes effective life much larger me.onDeath = function () { //applying forces to player doesn't seem to work inside this method, not sure why if (Math.random() < 0.35 || mech.fieldMode === 0) powerUps.spawn(this.position.x, this.position.y, "field"); //boss spawns field upgrades @@ -499,6 +499,15 @@ const spawn = { // body[index].classType = "body"; // World.add(engine.world, body[index]); //add to world // } + if (game.levelsCleared > 6) { + for (let i = 0; i < 4; ++i) { + spawn.sucker(this.position.x + (Math.random() - 0.5) * radius * 2, this.position.y + (Math.random() - 0.5) * radius * 2, 20); + Matter.Body.setVelocity(mob[mob.length - 1], { + x: (Math.random() - 0.5) * 25, + y: (Math.random() - 0.5) * 25 + }); + } + } }; me.do = function () { //keep it slow, to stop issues from explosion knock backs @@ -518,34 +527,36 @@ const spawn = { //eventHorizon waves in and out eventHorizon = this.eventHorizon * (1 + 0.5 * Math.sin(game.cycle * 0.006)) + // zoom camera in and out with the event horizon + //draw darkness ctx.beginPath(); ctx.arc(this.position.x, this.position.y, eventHorizon * 0.2, 0, 2 * Math.PI); - ctx.fillStyle = "rgba(0,0,0,0.9)"; + ctx.fillStyle = "rgba(0,20,40,0.6)"; ctx.fill(); ctx.beginPath(); ctx.arc(this.position.x, this.position.y, eventHorizon * 0.4, 0, 2 * Math.PI); - ctx.fillStyle = "rgba(0,0,0,0.7)"; + ctx.fillStyle = "rgba(0,20,40,0.4)"; ctx.fill(); ctx.beginPath(); ctx.arc(this.position.x, this.position.y, eventHorizon * 0.6, 0, 2 * Math.PI); - ctx.fillStyle = "rgba(0,0,0,0.5)"; + ctx.fillStyle = "rgba(0,20,40,0.3)"; ctx.fill(); ctx.beginPath(); ctx.arc(this.position.x, this.position.y, eventHorizon * 0.8, 0, 2 * Math.PI); - ctx.fillStyle = "rgba(0,0,0,0.3)"; + ctx.fillStyle = "rgba(0,20,40,0.2)"; ctx.fill(); ctx.beginPath(); ctx.arc(this.position.x, this.position.y, eventHorizon, 0, 2 * Math.PI); - ctx.fillStyle = "rgba(0,0,0,0.1)"; + ctx.fillStyle = "rgba(0,20,40,0.05)"; ctx.fill(); //when player is inside event horizon if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon) { mech.damage(0.0002 * game.dmgScale); if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01 const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x); - player.force.x -= 1.5 * Math.cos(angle) * player.mass * game.g * (mech.onGround ? 1.7 : 1); - player.force.y -= 1.5 * Math.sin(angle) * player.mass * game.g; + player.force.x -= 1.3 * Math.cos(angle) * player.mass * game.g * (mech.onGround ? 1.7 : 1); + player.force.y -= 1.2 * Math.sin(angle) * player.mass * game.g; //draw line to player ctx.beginPath(); ctx.moveTo(this.position.x, this.position.y); @@ -559,6 +570,7 @@ const spawn = { ctx.fill(); } this.healthBar(); + this.curl(eventHorizon); } } }, @@ -939,8 +951,7 @@ const spawn = { me.g = 0.0004; //required if using 'gravity' me.leaveBody = false; // me.dropPowerUp = false; - me.onDeath = function () { - //run this function on death + me.onDeath = function () { //run this function on death for (let i = 0; i < Math.ceil(this.mass * 0.2 + Math.random() * 3); ++i) { spawn.spawns(this.position.x + (Math.random() - 0.5) * radius * 2, this.position.y + (Math.random() - 0.5) * radius * 2); Matter.Body.setVelocity(mob[mob.length - 1], { @@ -1010,7 +1021,6 @@ const spawn = { this.seePlayerCheck(); this.attraction(); this.laserBeam(); - // this.curl(); }; //snake tail