From 26df511b76a96d528661d5f77100a98f030e6c9a Mon Sep 17 00:00:00 2001 From: landgreen Date: Wed, 25 Sep 2019 06:46:12 -0700 Subject: [PATCH] field balance --- js/level.js | 2 +- js/player.js | 56 +++++++++++++++++++++++++++------------------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/js/level.js b/js/level.js index 40a5f0b..789f6f1 100644 --- a/js/level.js +++ b/js/level.js @@ -24,7 +24,7 @@ const level = { // game.levelsCleared = 3; //for testing to simulate possible mobs spawns // b.giveGuns(0) // set a starting gun for testing - mech.fieldUpgrades[7]() //give a field power up for testing + mech.fieldUpgrades[3]() //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 diff --git a/js/player.js b/js/player.js index 092934a..1296d1f 100644 --- a/js/player.js +++ b/js/player.js @@ -818,7 +818,8 @@ const mech = { }, () => { mech.fieldMode = 1; - game.makeTextLog("Time Dilation Field
(right mouse or space bar)

field slows objects in range
field does not shield player

", 1200); + game.makeTextLog("Time Dilation Field
(right mouse or space bar)

field slows objects in range

", 1200); + //
field does not shield player mech.setHoldDefaults(); mech.fieldArc = 1; //field covers full 360 degrees mech.calculateFieldThreshold(); @@ -924,11 +925,11 @@ const mech = { }, () => { mech.fieldMode = 3; - game.makeTextLog("Negative Mass Field
(right mouse or space bar)

nullifies gravity around player
can hold more massive objects
field does not shield player

", 1200); + game.makeTextLog("Negative Mass Field
(right mouse or space bar)

field nullifies gravity
player can hold more massive objects

", 1200); mech.setHoldDefaults(); mech.holdingMassScale = 0.05; //can hold heavier blocks // mech.fieldArc = 1; //field covers full 360 degrees - mech.grabRange = 150; + mech.grabRange = 160; mech.fieldArc = 0.1; mech.calculateFieldThreshold(); @@ -939,7 +940,7 @@ const mech = { mech.holding(); mech.throw(); } else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //push away - const DRAIN = 0.0025 //mech.fieldRegen = 0.0015 + const DRAIN = 0.002 //mech.fieldRegen = 0.0015 if (mech.fieldMeter > DRAIN) { mech.fieldMeter -= DRAIN; mech.grabPowerUp(); @@ -950,12 +951,13 @@ const mech = { sub = Matter.Vector.sub(who[i].position, mech.pos); dist = Matter.Vector.magnitude(sub); if (dist < range) { - who[i].force.y -= who[i].mass * game.g; + who[i].force.y -= who[i].mass * (game.g * 1.03); //add a bit more then standard gravity } } } - // zeroG(powerUp); /no point to zero G power ups because the field just sucks them in. + zeroG(powerUp); zeroG(body); + // zeroG(mob); //mobs are too irregular to make this work? player.force.y -= player.mass * mech.gravity; // + 0.005 * Math.sin(game.cycle / 10); //wobble @@ -975,7 +977,6 @@ const mech = { mech.drawField(); mech.pushMobs(); - } else { //trigger cool down mech.fieldCDcycle = game.cycle + 120; @@ -1111,11 +1112,12 @@ const mech = { }, () => { mech.fieldMode = 7; - game.makeTextLog("Thermal Radiation Field
(right mouse or space bar)

field damages all targets within range, including player
field does not shield player

", 1200); + game.makeTextLog("Thermal Radiation Field
(right mouse or space bar)

field size grows while field is active
damages all targets within range, including player

", 1200); + //
field does not shield player
// game.makeTextLog("Thermal Radiation Field
(right mouse or space bar)

field damages and pushes all targets within range
field damages player
field does not shield player

", 1200); mech.setHoldDefaults(); - mech.grabRange = 160; - mech.fieldArc = 0.11; //0.2 is normal + // mech.grabRange = 160; + mech.fieldArc = 1; //0.2 is normal mech.rangeSmoothing = 0 // mech.fieldRegen = 0.0008 //0.0015; mech.hold = function () { @@ -1126,17 +1128,17 @@ const mech = { } else if ((keys[32] || game.mouseDownRight && mech.fieldCDcycle < game.cycle)) { //not hold but field button is pressed mech.grabPowerUp(); mech.lookForPickUp(); - //draw grab field - ctx.beginPath(); - ctx.arc(this.pos.x, this.pos.y, this.grabRange - 20, this.angle - Math.PI * this.fieldArc, this.angle + Math.PI * this.fieldArc, false); - let EYE_RADIUS = 13; - ctx.lineTo(mech.pos.x + EYE_RADIUS * Math.cos(this.angle), mech.pos.y + EYE_RADIUS * Math.sin(this.angle)); - if (this.holdingTarget) { - ctx.fillStyle = "rgba(150,150,150," + (0.05 + 0.1 * Math.random()) + ")"; - } else { - ctx.fillStyle = "rgba(150,150,150," + (0.15 + 0.15 * Math.random()) + ")"; - } - ctx.fill(); + // //draw grab field + // ctx.beginPath(); + // ctx.arc(this.pos.x, this.pos.y, this.grabRange - 20, this.angle - Math.PI * this.fieldArc, this.angle + Math.PI * this.fieldArc, false); + // let EYE_RADIUS = 13; + // ctx.lineTo(mech.pos.x + EYE_RADIUS * Math.cos(this.angle), mech.pos.y + EYE_RADIUS * Math.sin(this.angle)); + // if (this.holdingTarget) { + // ctx.fillStyle = "rgba(150,150,150," + (0.05 + 0.1 * Math.random()) + ")"; + // } else { + // ctx.fillStyle = "rgba(150,150,150," + (0.15 + 0.15 * Math.random()) + ")"; + // } + // ctx.fill(); if (mech.health > 0.1) { const DRAIN = 0.0011 //mech.fieldRegen = 0.0015 @@ -1145,13 +1147,13 @@ const mech = { mech.damage(0.0001) //draw damage field - mech.rangeSmoothing = mech.rangeSmoothing * 0.997 + (1350 + 60 * Math.cos(game.cycle / 20)) * 0.003 - let gradient = ctx.createRadialGradient(this.pos.x, this.pos.y, 0, this.pos.x, this.pos.y, mech.rangeSmoothing); + mech.grabRange = mech.grabRange * 0.997 + (1350 + 150 * Math.cos(game.cycle / 30)) * 0.003 + let gradient = ctx.createRadialGradient(this.pos.x, this.pos.y, 0, this.pos.x, this.pos.y, mech.grabRange); gradient.addColorStop(0, 'rgba(255,255,255,0)'); gradient.addColorStop(1, 'rgba(255,0,50,0.5)'); // gradient.addColorStop(1, 'rgba(255,0,0,0.05)'); ctx.beginPath(); - ctx.arc(this.pos.x, this.pos.y, mech.rangeSmoothing, 0, 2 * Math.PI); + ctx.arc(this.pos.x, this.pos.y, mech.grabRange, 0, 2 * Math.PI); ctx.fillStyle = gradient //rgba(255,0,0,0.2) ctx.fill(); @@ -1160,7 +1162,7 @@ const mech = { if (mob[i].alive) { sub = Matter.Vector.sub(this.pos, mob[i].position); dist = Matter.Vector.magnitude(sub); - if (dist < mech.rangeSmoothing) { + if (dist < mech.grabRange) { mob[i].damage(0.01); mob[i].locatePlayer(); // mech.fieldMeter -= DRAIN * 0.1; //extra drain for each additional target @@ -1174,10 +1176,10 @@ const mech = { } } } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle) { //holding, but field button is released - mech.rangeSmoothing = 0 + mech.grabRange = 0 mech.pickUp(); } else { - mech.rangeSmoothing = 0 + mech.grabRange = 0 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) } mech.drawFieldMeter()