From bbf3b9b79f009a3846e072f67970aa215fe12221 Mon Sep 17 00:00:00 2001 From: landgreen Date: Tue, 15 Oct 2019 05:59:10 -0700 Subject: [PATCH] working on aeire level and suckerBoss --- js/level.js | 45 ++++++++++++++++++++------------------------- js/mobs.js | 28 +++++++++++++--------------- js/player.js | 12 ++++++------ js/spawn.js | 29 +++++++++++------------------ 4 files changed, 50 insertions(+), 64 deletions(-) diff --git a/js/level.js b/js/level.js index c96b091..c4e60cf 100644 --- a/js/level.js +++ b/js/level.js @@ -13,17 +13,18 @@ const level = { // game.zoomScale = 1400 //1400 if (game.levelsCleared === 0) { document.title = "n-gon"; - // this.intro(); //starting level + // game.levelsCleared = 4; //for testing to simulate possible mobs spawns + // b.giveGuns(1) // set a starting gun for testing + // b.giveGuns("all", 1000) + // mech.fieldUpgrades[5]() //give a field power up for testing + this.intro(); //starting level // this.testingMap(); // this.bosses(); - this.aerie(); + // this.aerie(); // this.rooftops(); // this.warehouse(); // this.highrise(); // this.office(); - // 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 @@ -498,11 +499,7 @@ const level = { spawn.bodyRect(-240, -2115, 30, 36); //door to starting room spawn.bodyRect(-240, -2080, 30, 35); //door to starting room spawn.bodyRect(-240, -2045, 30, 35); //door to starting room - - spawn.mapRect(1950, -2000, 600, 50); - - spawn.bodyRect(200, -2150, 200, 220, 0.8); spawn.mapRect(700, -2275, 700, 50); spawn.bodyRect(1050, -2350, 30, 30, 0.8); @@ -527,8 +524,6 @@ const level = { spawn.bodyRect(3500, -850, 75, 125, 0.8); spawn.mapRect(3450, -1000, 50, 580); //left building wall spawn.bodyRect(3460, -420, 30, 144); - - spawn.mapRect(5450, -775, 100, 875); //right building wall spawn.bodyRect(4850, -750, 300, 25, 0.8); spawn.bodyRect(3925, -1400, 100, 150, 0.8); @@ -540,11 +535,9 @@ const level = { spawn.mapRect(4500, -700, 50, 600); spawn.bodyRect(4510, -100, 30, 100, 0.8); spawn.mapRect(4500, -925, 100, 50); - spawn.spawnStairs(3800, 0, 3, 150, 206); //stairs top exit spawn.mapRect(3400, -275, 450, 275); //exit platform - spawn.randomSmallMob(2200, -1775); spawn.randomSmallMob(4000, -825); spawn.randomSmallMob(-350, -2400); @@ -568,7 +561,7 @@ const level = { }, aerie() { // game.setZoom(3000); - game.levelsCleared = 5; //for testing to simulate possible mobs spawns + // game.levelsCleared = 4; //for testing to simulate possible mobs spawns game.zoomTransition(2100) //1400 is normal const backwards = (Math.random() < 0.75) ? false : true; @@ -588,10 +581,10 @@ const level = { level.enter.y = mech.spawnPos.y + 20; this.addZone(level.exit.x, level.exit.y, 100, 30, "nextLevel"); powerUps.spawnStartingPowerUps(1075, -550); - spawn.debris(-250, 50, 1650, 5); //20 debris per level - spawn.debris(2475, 0, 750, 5); //20 debris per level - spawn.debris(3450, 0, 2000, 10); //20 debris per level - spawn.debris(3500, -2350, 1500, 5); //20 debris per level + spawn.debris(-250, 50, 1650, 3); //20 debris per level + spawn.debris(2475, 0, 750, 3); //20 debris per level + spawn.debris(3450, 0, 2000, 18); //20 debris per level + spawn.debris(3500, -2350, 1500, 3); //20 debris per level document.body.style.backgroundColor = "#dcdcde"; //foreground @@ -687,12 +680,12 @@ const level = { spawn.bodyRect(2450, 150, 150, 150, 0.4); spawn.mapRect(1550, 300, 4600, 200); //ground //floor below right tall tower - spawn.bodyRect(3000, 50, 200, 275, 0.8); - spawn.bodyRect(4000, 50, 200, 200, 0.8); - spawn.bodyRect(4500, 50, 375, 250, 0.8); - spawn.bodyRect(4900, -100, 300, 400, 0.4); + spawn.bodyRect(3000, 50, 150, 250, 0.8); + spawn.bodyRect(4000, 50, 200, 150, 0.8); + spawn.bodyRect(4500, 50, 300, 200, 0.8); + spawn.bodyRect(4900, -100, 300, 300, 0.4); spawn.boost(5350, 275, 2850); - spawn.mapRect(6050, -450, 100, 800); + spawn.mapRect(6050, -700, 600, 1200); //right tall tower spawn.mapRect(3700, -3200, 100, 800); spawn.mapRect(4700, -2910, 100, 510); @@ -713,9 +706,11 @@ const level = { spawn.randomSmallMob(5600, 100); spawn.randomMob(4275, -2600, 0.8); spawn.randomMob(1050, -700, 0.8) - spawn.randomMob(6050, -500, 0.7); + spawn.randomMob(6050, -850, 0.7); spawn.randomMob(2150, -300, 0.6) spawn.randomMob(3900, -2700, 0.8); + spawn.randomMob(3600, -500, 0.8); + spawn.randomMob(3400, -200, 0.8); spawn.randomMob(1650, -1300, 0.7) spawn.randomMob(-4100, -50, 0.7); spawn.randomMob(4100, -50, 0.5); @@ -991,7 +986,7 @@ const level = { //building 2 spawn.mapRect(-4450, -600, 2300, 750); spawn.mapRect(-2225, -500, 175, 550); - spawn.boost(-2800, -600, 1000); + spawn.boost(-2800, -600, 1150); spawn.mapRect(-3450, -1325, 550, 50); spawn.mapRect(-3425, -2200, 525, 50); spawn.mapRect(-2600, -1750, 450, 50); diff --git a/js/mobs.js b/js/mobs.js index 7855c7f..90b44b4 100644 --- a/js/mobs.js +++ b/js/mobs.js @@ -554,7 +554,7 @@ const mobs = { // ctx.fillStyle = "rgba(0,0,0,0.1)"; // ctx.fill(); // }, - curl(range = 1000) { + curl(range = 1000, mag = -10) { //cause all mobs, and bodies to rotate in a circle applyCurl = function (center, array) { for (let i = 0; i < array.length; ++i) { @@ -563,28 +563,26 @@ const mobs = { //if too close, like center mob or shield, don't curl // if too far don't curl if (radius2 < range * range && radius2 > 10000) { - const curlVector = Matter.Vector.perp(Matter.Vector.normalise(sub)) - + const curlVector = Matter.Vector.mult(Matter.Vector.perp(Matter.Vector.normalise(sub)), mag) //apply curl force - const mag = Matter.Vector.mult(curlVector, 10) Matter.Body.setVelocity(array[i], { - x: array[i].velocity.x * 0.94 + mag.x * 0.06, - y: array[i].velocity.y * 0.94 + mag.y * 0.06 + x: array[i].velocity.x * 0.94 + curlVector.x * 0.06, + y: array[i].velocity.y * 0.94 + curlVector.y * 0.06 }) - - //draw curl - ctx.beginPath(); - ctx.moveTo(array[i].position.x, array[i].position.y); - ctx.lineTo(array[i].position.x + curlVector.x * 100, array[i].position.y + curlVector.y * 100); - ctx.lineWidth = 2; - ctx.strokeStyle = "#000"; - ctx.stroke(); + // //draw curl + // ctx.beginPath(); + // ctx.moveTo(array[i].position.x, array[i].position.y); + // ctx.lineTo(array[i].position.x + curlVector.x * 10, array[i].position.y + curlVector.y * 10); + // ctx.lineWidth = 2; + // ctx.strokeStyle = "#000"; + // ctx.stroke(); } } } applyCurl(this.position, mob); applyCurl(this.position, body); - applyCurl(this.position, [player]); + applyCurl(this.position, powerUp); + // applyCurl(this.position, [player]); //draw limit // ctx.beginPath(); // ctx.arc(this.position.x, this.position.y, range, 0, 2 * Math.PI); diff --git a/js/player.js b/js/player.js index 303297c..2a57a4f 100644 --- a/js/player.js +++ b/js/player.js @@ -851,7 +851,7 @@ const mech = { game.makeTextLog("Inertia Negation Field
(right mouse or space bar)

field slows objects in range
decreased field shielding efficiency

", 1200); //
field does not shield player mech.setHoldDefaults(); - mech.grabRange = 900 + mech.grabRange = 900; mech.fieldShieldingScale = 12; // mech.fieldArc = 1; //field covers full 360 degrees // mech.calculateFieldThreshold(); //run after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) @@ -1063,10 +1063,10 @@ const mech = { mech.holdingTarget = null; //clears holding target (this is so you only pick up right after the field button is released and a hold target exists) } if (mech.fieldMeter > 0.1) { - const grabRange1 = 100 + 95 * Math.sin(game.cycle / 23) - const grabRange2 = 105 + 85 * Math.sin(game.cycle / 37) - const grabRange3 = 90 + 90 * Math.sin(game.cycle / 47) - mech.grabRange = Math.max(grabRange1, grabRange2, grabRange3) + const grabRange1 = 80 + 80 * Math.sin(game.cycle / 23) + const grabRange2 = 80 + 80 * Math.sin(game.cycle / 37) + const grabRange3 = 80 + 80 * Math.sin(game.cycle / 47) + const netGrabRange = Math.max(grabRange1, grabRange2, grabRange3) ctx.fillStyle = "rgba(110,170,200," + (0.15 + 0.15 * Math.random()) + ")"; ctx.beginPath(); ctx.arc(mech.pos.x, mech.pos.y, grabRange1, 0, 2 * Math.PI); @@ -1077,7 +1077,7 @@ const mech = { ctx.beginPath(); ctx.arc(mech.pos.x, mech.pos.y, grabRange3, 0, 2 * Math.PI); ctx.fill(); - mech.pushMobs360(mech.grabRange); + mech.pushMobs360(netGrabRange); } mech.drawFieldMeter() } diff --git a/js/spawn.js b/js/spawn.js index c504ff5..03f71bf 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -482,25 +482,18 @@ const spawn = { let me = mob[mob.length - 1]; me.stroke = "transparent"; //used for drawSneaker me.eventHorizon = 900; //required for black hole - me.seeAtDistance2 = (me.eventHorizon + 500) * (me.eventHorizon + 500); //vision limit is event horizon - me.accelMag = 0.00011 * game.accelScale; - me.collisionFilter.mask = 0x001101 + me.seeAtDistance2 = (me.eventHorizon + 1000) * (me.eventHorizon + 1000); //vision limit is event horizon + me.accelMag = 0.00006 * game.accelScale; + me.collisionFilter.mask = 0x001100 // me.frictionAir = 0.005; - me.memory = 1000; + me.memory = 1600; 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 - // for (let i = 0; i < 70; i++) { - // const index = body.length - // spawn.bodyRect(this.position.x + 30 * (Math.random() - 0.5), this.position.y + 30 * (Math.random() - 0.5), 15 + 40 * Math.random(), 15 + 40 * Math.random()); - // body[index].collisionFilter.category = 0x010000; - // body[index].collisionFilter.mask = 0x111000; - // body[index].classType = "body"; - // World.add(engine.world, body[index]); //add to world - // } + if (game.levelsCleared > 6) { - for (let i = 0; i < 4; ++i) { + for (let i = 0; i < (game.levelsCleared - 5); ++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, @@ -511,7 +504,7 @@ const spawn = { }; me.do = function () { //keep it slow, to stop issues from explosion knock backs - if (this.speed > 6) { + if (this.speed > 2) { Matter.Body.setVelocity(this, { x: this.velocity.x * 0.95, y: this.velocity.y * 0.95 @@ -526,7 +519,7 @@ const spawn = { this.force.y += forceMag * Math.sin(angle); //eventHorizon waves in and out - eventHorizon = this.eventHorizon * (1 + 0.5 * Math.sin(game.cycle * 0.006)) + eventHorizon = this.eventHorizon * (1 + 0.4 * Math.sin(game.cycle * 0.006)) // zoom camera in and out with the event horizon //draw darkness @@ -552,7 +545,7 @@ const spawn = { 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); + mech.damage(0.00015 * 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.3 * Math.cos(angle) * player.mass * game.g * (mech.onGround ? 1.7 : 1); @@ -1074,7 +1067,7 @@ const spawn = { me.stroke = "rgb(220,220,255)"; Matter.Body.setDensity(me, 0.0001) //very low density to not mess with the original mob's motion me.shield = true; - me.collisionFilter.mask = 0x001100; //don't collide with bodies, map, player, and mobs, only bullets + me.collisionFilter.mask = 0x000100; //don't collide with bodies, map, player, and mobs, only bullets consBB[consBB.length] = Constraint.create({ //attach shield to last spawned mob bodyA: me, @@ -1101,7 +1094,7 @@ const spawn = { Matter.Body.setDensity(me, 0.00005) //very low density to not mess with the original mob's motion me.frictionAir = 0; me.shield = true; - me.collisionFilter.mask = 0x001100; //don't collide with bodies, map, and mobs, only bullets and player + me.collisionFilter.mask = 0x000100; //don't collide with bodies, map, and mobs, only bullets and player //constrain to all mob nodes in boss for (let i = 0; i < nodes; ++i) { consBB[consBB.length] = Constraint.create({