From cf159f26fd7ffe900ac90ce524ec28662a6a1cf4 Mon Sep 17 00:00:00 2001 From: landgreen Date: Thu, 26 Sep 2019 19:02:34 -0700 Subject: [PATCH] playing with kinetic field --- js/level.js | 2 +- js/player.js | 36 +++++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/js/level.js b/js/level.js index 789f6f1..f4661c4 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[3]() //give a field power up for testing + mech.fieldUpgrades[2]() //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 b641747..8e10a00 100644 --- a/js/player.js +++ b/js/player.js @@ -881,8 +881,8 @@ const mech = { mech.throwChargeRate = 3; //0.5 mech.throwChargeMax = 150; //50 //passive field does extra damage - mech.grabRange = 180; - mech.fieldArc = 0.08; + // mech.grabRange = 200; + mech.fieldArc = 0.01; mech.fieldDamage = 2; mech.hold = function () { @@ -925,12 +925,12 @@ const mech = { }, () => { mech.fieldMode = 3; - game.makeTextLog("Negative Mass Field
(right mouse or space bar)

field nullifies gravity
player can hold more massive objects

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

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

", 1200); mech.setHoldDefaults(); - mech.holdingMassScale = 0.05; //can hold heavier blocks + mech.holdingMassScale = 0.05; //can hold heavier blocks with lower cost to jumping // mech.fieldArc = 1; //field covers full 360 degrees - mech.grabRange = 160; - mech.fieldArc = 0.1; + mech.grabRange = 155; + mech.fieldArc = 0.08; mech.calculateFieldThreshold(); mech.hold = function () { @@ -940,9 +940,22 @@ const mech = { mech.holding(); mech.throw(); } else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //push away - const DRAIN = 0.002 //mech.fieldRegen = 0.0015 + const DRAIN = 0.0006 //mech.fieldRegen = 0.0015 if (mech.fieldMeter > DRAIN) { mech.fieldMeter -= DRAIN; + + //draw 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 = 13; + ctx.lineTo(mech.pos.x + eye * Math.cos(this.angle), mech.pos.y + eye * 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(); + mech.grabPowerUp(); mech.lookForPickUp(); //look for nearby objects to make zero-g @@ -964,18 +977,19 @@ const mech = { //allow player to fly up and down a bit flyForce = 0.003; - if (keys[83] || keys[40]) { + if (keys[83] || keys[40]) { //down player.force.y += flyForce Matter.Body.setVelocity(player, { //friction, only when flying x: player.velocity.x, y: player.velocity.y * 0.96 }); - } else if (keys[87] || keys[38]) { + } else if (keys[87] || keys[38]) { //up player.force.y -= flyForce Matter.Body.setVelocity(player, { //friction, only when flying x: player.velocity.x, y: player.velocity.y * 0.96 }); + // mech.fieldMeter -= DRAIN; //extra energy used to fly upwards } //add extra friction for horizontal motion @@ -994,8 +1008,8 @@ const mech = { ctx.fill(); ctx.globalCompositeOperation = "source-over"; - mech.drawField(); - mech.pushMobs(); + // mech.drawField(); + // mech.pushMobs(); } else { //trigger cool down mech.fieldCDcycle = game.cycle + 120;