From 869e8af738a500f060bba33d8580d16727bbf29d Mon Sep 17 00:00:00 2001 From: landgreen Date: Tue, 17 Sep 2019 05:58:19 -0700 Subject: [PATCH] field emitter power ups rework (trigger effects with just right click) --- js/bullets.js | 2 +- js/index.js | 43 ++--- js/level.js | 1 + js/player.js | 463 ++++++++++++++++++++++++++++++++------------------ 4 files changed, 309 insertions(+), 200 deletions(-) diff --git a/js/bullets.js b/js/bullets.js index f64a44b..e1a9ea2 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -773,7 +773,7 @@ const b = { const me = bullet.length; const dir = mech.angle; bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 20, 4.5, b.fireAttributes(dir)); - b.fireProps(mech.crouch ? 60 : 35, mech.crouch ? 30 : 17, dir, me); //cd , speed + b.fireProps(mech.crouch ? 60 : 35, mech.crouch ? 25 : 14, dir, me); //cd , speed b.drawOneBullet(bullet[me].vertices); Matter.Body.setDensity(bullet[me], 0.000001); bullet[me].endCycle = game.cycle + 100; diff --git a/js/index.js b/js/index.js index c3f9706..e87e868 100644 --- a/js/index.js +++ b/js/index.js @@ -2,9 +2,20 @@ /* TODO: ******************************************* ***************************************************** -run fast when shift is pressed - drains fieldMeter - walking animation isn't going to look good +general gun power ups + +explosion radius + +dmg + life steal + ice bullets (reduce mob velocity on dmg) + +bullet size + get bonus ammo / reduced ammo use + +reduced cs on fire (faster fire rate) + orbiting orb fires at random targets + missiles at random targets + +have mob acceleration and look frequency scale with difficulty level + this will speed up the responses of later mobs + this should provide a feeling of difficulty without inflating the life of mobs give mobs more animal-like behaviors like rainworld @@ -18,32 +29,6 @@ give mobs more animal-like behaviors this might be hard to code isolated mobs try to group up. -general gun power ups - +explosion radius - +dmg - life steal - ice bullets (reduce mob velocity on dmg) - +bullet size - get bonus ammo / reduced ammo use - +reduced cs on fire (faster fire rate) - orbiting orb fires at random targets - missiles at random targets - -specific gun power ups - laser: less energy use - rapid fire: less drag, less gravity, less randomness - one shot: larger bullet - super balls: fire 4 balls - spray: less drag +range - needles: +dmg, or faster fire rate - missiles: larger explosion radius - flak: + more projectiles per shot - M80: larger explosion radius - grenades: larger explosion radius - spore: quicker hatching, more spores spawn, +dmg - drones: last longer - wave beam: longer range - game mechanics mechanics that support the physics engine add rope/constraint diff --git a/js/level.js b/js/level.js index c3b1955..eaae19a 100644 --- a/js/level.js +++ b/js/level.js @@ -14,6 +14,7 @@ const level = { if (game.levelsCleared === 0) { this.intro(); //starting level // b.giveGuns(0) // set a starting gun for testing + // mech.fieldUpgrades[3]() //give a field power up for testing // game.levelsCleared = 3; //for testing to simulate possible mobs spawns // this.bosses(); // this.testingMap(); diff --git a/js/player.js b/js/player.js index 45bf004..b4f4069 100644 --- a/js/player.js +++ b/js/player.js @@ -507,17 +507,16 @@ const mech = { this.gravity = 0.0019; // this.phaseBlocks(0x011111) }, - drawFieldMeter() { + drawFieldMeter(range = 60) { if (this.fieldMeter < 1) { mech.fieldMeter += mech.fieldRegen; ctx.fillStyle = "rgba(0, 0, 0, 0.4)"; - ctx.fillRect(this.pos.x - this.radius, this.pos.y - 50, 60, 10); - 110, 170, 200 + ctx.fillRect(this.pos.x - this.radius, this.pos.y - 50, range, 10); ctx.fillStyle = "rgb(50,220,255)"; ctx.fillRect( this.pos.x - this.radius, this.pos.y - 50, - 60 * this.fieldMeter, + range * this.fieldMeter, 10 ); } else { @@ -816,17 +815,24 @@ const mech = { }, () => { mech.fieldMode = 1; - game.makeTextLog("

Time Dilation Field


active ability: hold left and right mouse to slow time
passive bonus: +field regeneration", 1000); //
passive bonus: can phase through blocks + game.makeTextLog("

Time Dilation Field

field emitter slows time around the player", 1000); mech.setHoldDefaults(); - mech.fieldRegen = 0.01; //0.0015 + mech.fieldArc = 1; //field covers full 360 degrees + mech.calculateFieldThreshold(); + mech.hold = function () { if (mech.isHolding) { mech.drawHold(mech.holdingTarget); mech.holding(); mech.throw(); - } else if (game.mouseDown && (keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //both mouse keys down - if (mech.fieldMeter > mech.fieldRegen * 1.15) { - mech.fieldMeter -= mech.fieldRegen * 1.15; + } else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //both mouse keys down + const DRAIN = 0.0035 //mech.fieldRegen = 0.0015 + if (mech.fieldMeter > DRAIN) { + mech.fieldMeter -= DRAIN; + mech.grabPowerUp(); + // mech.pushMobs(); + mech.lookForPickUp(130); + const range = 900; //draw slow field ctx.beginPath(); @@ -854,11 +860,6 @@ const mech = { } else { mech.fieldCDcycle = game.cycle + 120; } - } else if ((keys[32] || game.mouseDownRight) && mech.fieldMeter > 0.1) { //field button is pressed - mech.drawField(); - mech.grabPowerUp(); - mech.pushMobs(); - mech.lookForPickUp(130); } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle) { //holding, but field button is released mech.pickUp(); } else { @@ -869,16 +870,15 @@ const mech = { }, () => { mech.fieldMode = 2; - game.makeTextLog("

Kinetic Energy Field


passive bonus: +field emitter damage
passive bonus: +throw energy", 1000); + game.makeTextLog("

Kinetic Energy Field

field emitter does damage on contact
blocks are thrown at a higher velocity", 1000); mech.setHoldDefaults(); - // mech.fieldRegen = 0.0008; // 0.0015 is normal //throw quicker and harder - mech.throwChargeRate = 4; //0.5 - mech.throwChargeMax = 300; //50 + mech.throwChargeRate = 3; //0.5 + mech.throwChargeMax = 150; //50 //passive field does extra damage mech.grabRange = 180; mech.fieldArc = 0.08; - mech.fieldDamage = 2.5; + mech.fieldDamage = 2; mech.hold = function () { if (mech.isHolding) { @@ -920,89 +920,24 @@ const mech = { }, () => { mech.fieldMode = 3; - game.makeTextLog("

Mass Recycler


active ability: hold left and right mouse to convert blocks into health
negative effect: -energy regen", 1000); - mech.setHoldDefaults(); - mech.fieldRegen = 0.0005; //0.0015 - mech.hold = function () { - // health drain - // if (game.cycle % 360 === 0 && mech.health > 0.2) { - // mech.health = mech.health * 0.97 - 0.01; - // if (mech.health < 0) { - // mech.health = 0; - // mech.death(); - // return; - // } - // mech.displayHealth(); - // } - if (mech.isHolding) { - mech.drawHold(mech.holdingTarget); - mech.holding(); - mech.throw(); - } else if (game.mouseDown && (keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //both mouse keys down - if (mech.fieldMeter > mech.fieldRegen) { - // mech.fieldMeter -= mech.fieldRegen - const range = 165; - //draw range - ctx.globalCompositeOperation = "screen" //"lighter" // "destination-atop" //"difference" //"color-burn"; - ctx.beginPath(); - ctx.arc(mech.pos.x, mech.pos.y, range, 0, 2 * Math.PI); - ctx.lineWidth = 1; - ctx.fillStyle = "rgba(150,210,180," + (0.9 + Math.random() * 0.1) + ")"; - ctx.fill(); - ctx.globalCompositeOperation = "source-over"; - ctx.strokeStyle = "#364"; - ctx.stroke(); - - //find all blocks in range - for (let i = 0, len = body.length; i < len; i++) { - if (!body[i].isNotHoldable) { - dist = Matter.Vector.magnitude(Matter.Vector.sub(body[i].position, mech.pos)) - const healCost = Math.sqrt(0.003 * body[i].mass) + 0.04 - if (dist < range && mech.fieldMeter > healCost + 0.2) { // convert block to heal power up - // mech.fieldCDcycle = game.cycle + 4; - mech.fieldMeter -= healCost - powerUps.spawnHeal(body[i].position.x, body[i].position.y, 120 * healCost); - Matter.World.remove(engine.world, body[i]); - body.splice(i, 1); - break - } - } - } - } else { - mech.fieldCDcycle = game.cycle + 120; - } - } else if ((keys[32] || game.mouseDownRight) && mech.fieldMeter > 0.2) { //field button is pressed - mech.drawField(); - mech.grabPowerUp(); - mech.pushMobs(); - mech.lookForPickUp(130); - } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle) { //holding, but field button is released - mech.pickUp(); - } else { - 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() - } - }, - () => { - mech.fieldMode = 4; - game.makeTextLog("

Negative Mass Field


active ability: hold left and right mouse to nullify gravity
passive bonuses: +field size, +hold larger blocks", 1000); + game.makeTextLog("

Negative Mass Field

field emitter nullifies gravity around player
field emitter can hold more massive objects", 1000); mech.setHoldDefaults(); + mech.holdingMassScale = 0.05; //can hold heavier blocks mech.fieldArc = 1; //field covers full 360 degrees mech.calculateFieldThreshold(); - mech.holdingMassScale = 0.05; //can hold heavier blocks - // mech.gravity = 0.0015; //passive reduce gravity from default 0.0019 mech.hold = function () { - const range = 200 + 35 * Math.sin(game.cycle / 20) + const range = 400 if (mech.isHolding) { mech.drawHold(mech.holdingTarget); mech.holding(); mech.throw(); - } else if (game.mouseDown && (keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //both mouse keys down //push away - if (mech.fieldMeter > 0.005) { - mech.fieldMeter -= 0.005; - + } else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //both mouse keys down //push away + const DRAIN = 0.0025 //mech.fieldRegen = 0.0015 + if (mech.fieldMeter > DRAIN) { + mech.fieldMeter -= DRAIN; + mech.grabPowerUp(); + mech.lookForPickUp(); //look for nearby objects to make zero-g function zeroG(who) { for (let i = 0, len = who.length; i < len; ++i) { @@ -1013,7 +948,7 @@ const mech = { } } } - zeroG(powerUp); + // zeroG(powerUp); zeroG(body); player.force.y -= player.mass * mech.gravity; // + 0.005 * Math.sin(game.cycle / 10); //wobble @@ -1027,7 +962,7 @@ const mech = { ctx.beginPath(); ctx.arc(mech.pos.x, mech.pos.y + 15, range, 0, 2 * Math.PI); ctx.globalCompositeOperation = "color-burn"; - ctx.fillStyle = "rgb(90,90,100)"; + ctx.fillStyle = "rgb(120,120,130)"; ctx.fill(); ctx.globalCompositeOperation = "source-over"; @@ -1035,12 +970,6 @@ const mech = { //trigger cooldown mech.fieldCDcycle = game.cycle + 120; } - } else if ((keys[32] || game.mouseDownRight) && mech.fieldMeter > 0.2 && mech.fieldCDcycle < game.cycle) { //not hold but field button is pressed - mech.grabRange = range - mech.drawField(); - mech.grabPowerUp(); - mech.pushMobs(); - mech.lookForPickUp(); } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle && mech.fieldCDcycle < game.cycle) { //holding, but field button is released mech.pickUp(); } else { @@ -1049,76 +978,270 @@ const mech = { mech.drawFieldMeter() } }, + () => { + mech.fieldMode = 4; + game.makeTextLog("

Zero-Point Energy Field

energy regeneration is improved
field emitter is extended to a circle around the player", 1000); + mech.setHoldDefaults(); + mech.fieldRegen = 0.01; //0.0015 + mech.fieldArc = 1; //field covers full 360 degrees + mech.calculateFieldThreshold(); + + mech.hold = function () { + mech.grabRange = 200 + 35 * Math.sin(game.cycle / 20) + + if (mech.isHolding) { + mech.drawHold(mech.holdingTarget); + mech.holding(); + mech.throw(); + } else if ((keys[32] || game.mouseDownRight && mech.fieldMeter > 0.1)) { //not hold but field button is pressed + mech.drawField(); + mech.grabPowerUp(); + mech.pushMobs(); + mech.lookForPickUp(); + } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle) { //holding, but field button is released + mech.pickUp(); + } else { + 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() + } + }, + // () => { + // mech.fieldMode = 1; + // game.makeTextLog("

Time Dilation Field


active ability: hold left and right mouse to slow time
passive bonus: +field regeneration", 1000); //
passive bonus: can phase through blocks + // mech.setHoldDefaults(); + // mech.fieldRegen = 0.01; //0.0015 + // mech.hold = function () { + // if (mech.isHolding) { + // mech.drawHold(mech.holdingTarget); + // mech.holding(); + // mech.throw(); + // } else if (game.mouseDown && (keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //both mouse keys down + // if (mech.fieldMeter > mech.fieldRegen * 1.15) { + // mech.fieldMeter -= mech.fieldRegen * 1.15; + // const range = 900; + // //draw slow field + // ctx.beginPath(); + // ctx.arc(mech.pos.x, mech.pos.y, range, 0, 2 * Math.PI); + // ctx.fillStyle = "#f5f5ff"; + // ctx.globalCompositeOperation = "difference"; + // ctx.fill(); + // ctx.globalCompositeOperation = "source-over"; + + // function slow(who, friction = 0) { + // for (let i = 0, len = who.length; i < len; ++i) { + // dist = Matter.Vector.magnitude(Matter.Vector.sub(who[i].position, mech.pos)) + // if (dist < range) { + // Matter.Body.setAngularVelocity(who[i], who[i].angularVelocity * friction) + // Matter.Body.setVelocity(who[i], { + // x: who[i].velocity.x * friction, + // y: who[i].velocity.y * friction + // }); + // } + // } + // } + // slow(mob); + // slow(body); + // slow(bullet); + // } else { + // mech.fieldCDcycle = game.cycle + 120; + // } + // } else if ((keys[32] || game.mouseDownRight) && mech.fieldMeter > 0.1) { //field button is pressed + // mech.drawField(); + // mech.grabPowerUp(); + // mech.pushMobs(); + // mech.lookForPickUp(130); + // } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle) { //holding, but field button is released + // mech.pickUp(); + // } else { + // 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() + // } + // }, + // () => { + // mech.fieldMode = 2; + // game.makeTextLog("

Kinetic Energy Field


passive bonus: +field emitter damage
passive bonus: +throw energy", 1000); + // mech.setHoldDefaults(); + // // mech.fieldRegen = 0.0008; // 0.0015 is normal + // //throw quicker and harder + // mech.throwChargeRate = 4; //0.5 + // mech.throwChargeMax = 300; //50 + // //passive field does extra damage + // mech.grabRange = 180; + // mech.fieldArc = 0.08; + // mech.fieldDamage = 2.5; + + // mech.hold = function () { + // if (mech.isHolding) { + // mech.drawHold(mech.holdingTarget); + // mech.holding(); + // mech.throw(); + // } else if ((keys[32] || game.mouseDownRight) && mech.fieldMeter > 0.15) { //not hold but field button is pressed + // //draw field + // const range = mech.grabRange - 20; + // ctx.beginPath(); + // ctx.arc(mech.pos.x, mech.pos.y, range, mech.angle - Math.PI * mech.fieldArc, mech.angle + Math.PI * mech.fieldArc, false); + // let eye = 13; + // ctx.lineTo(mech.pos.x + eye * Math.cos(mech.angle), mech.pos.y + eye * Math.sin(mech.angle)); + // if (mech.holdingTarget) { + // ctx.fillStyle = "rgba(255,50,150," + (0.05 + 0.1 * Math.random()) + ")"; + // } else { + // ctx.fillStyle = "rgba(255,50,150," + (0.15 + 0.15 * Math.random()) + ")"; + // } + // ctx.fill(); + // //draw random lines in field for cool effect + // let offAngle = mech.angle + 2 * Math.PI * mech.fieldArc * (Math.random() - 0.5); + // ctx.beginPath(); + // eye = 15; + // ctx.moveTo(mech.pos.x + eye * Math.cos(mech.angle), mech.pos.y + eye * Math.sin(mech.angle)); + // ctx.lineTo(mech.pos.x + range * Math.cos(offAngle), mech.pos.y + range * Math.sin(offAngle)); + // ctx.strokeStyle = "rgba(120,170,255,0.4)"; + // ctx.stroke(); + + // mech.grabPowerUp(); + // mech.pushMobs(); + // mech.lookForPickUp(); + // } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle) { //holding, but field button is released + // mech.pickUp(); + // } else { + // 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() + // } + // }, + // () => { + // mech.fieldMode = 3; + // game.makeTextLog("

Mass Recycler


active ability: hold left and right mouse to convert blocks into health
negative effect: -energy regen", 1000); + // mech.setHoldDefaults(); + // mech.fieldRegen = 0.0005; //0.0015 + // mech.hold = function () { + // // health drain + // // if (game.cycle % 360 === 0 && mech.health > 0.2) { + // // mech.health = mech.health * 0.97 - 0.01; + // // if (mech.health < 0) { + // // mech.health = 0; + // // mech.death(); + // // return; + // // } + // // mech.displayHealth(); + // // } + // if (mech.isHolding) { + // mech.drawHold(mech.holdingTarget); + // mech.holding(); + // mech.throw(); + // } else if (game.mouseDown && (keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //both mouse keys down + // if (mech.fieldMeter > mech.fieldRegen) { + // // mech.fieldMeter -= mech.fieldRegen + // const range = 165; + // //draw range + // ctx.globalCompositeOperation = "screen" //"lighter" // "destination-atop" //"difference" //"color-burn"; + // ctx.beginPath(); + // ctx.arc(mech.pos.x, mech.pos.y, range, 0, 2 * Math.PI); + // ctx.lineWidth = 1; + // ctx.fillStyle = "rgba(150,210,180," + (0.9 + Math.random() * 0.1) + ")"; + // ctx.fill(); + // ctx.globalCompositeOperation = "source-over"; + // ctx.strokeStyle = "#364"; + // ctx.stroke(); + + // //find all blocks in range + // for (let i = 0, len = body.length; i < len; i++) { + // if (!body[i].isNotHoldable) { + // dist = Matter.Vector.magnitude(Matter.Vector.sub(body[i].position, mech.pos)) + // const healCost = Math.sqrt(0.003 * body[i].mass) + 0.04 + // if (dist < range && mech.fieldMeter > healCost + 0.2) { // convert block to heal power up + // // mech.fieldCDcycle = game.cycle + 4; + // mech.fieldMeter -= healCost + // powerUps.spawnHeal(body[i].position.x, body[i].position.y, 120 * healCost); + // Matter.World.remove(engine.world, body[i]); + // body.splice(i, 1); + // break + // } + // } + // } + // } else { + // mech.fieldCDcycle = game.cycle + 120; + // } + // } else if ((keys[32] || game.mouseDownRight) && mech.fieldMeter > 0.2) { //field button is pressed + // mech.drawField(); + // mech.grabPowerUp(); + // mech.pushMobs(); + // mech.lookForPickUp(130); + // } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle) { //holding, but field button is released + // mech.pickUp(); + // } else { + // 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() + // } + // }, + // () => { + // mech.fieldMode = 4; + // game.makeTextLog("

Negative Mass Field


active ability: hold left and right mouse to nullify gravity
passive bonuses: +field size, +hold larger blocks", 1000); + // mech.setHoldDefaults(); + // mech.fieldArc = 1; //field covers full 360 degrees + // mech.calculateFieldThreshold(); + // mech.holdingMassScale = 0.05; //can hold heavier blocks + // // mech.gravity = 0.0015; //passive reduce gravity from default 0.0019 + + // mech.hold = function () { + // const range = 200 + 35 * Math.sin(game.cycle / 20) + // if (mech.isHolding) { + // mech.drawHold(mech.holdingTarget); + // mech.holding(); + // mech.throw(); + // } else if (game.mouseDown && (keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //both mouse keys down //push away + // if (mech.fieldMeter > 0.005) { + // mech.fieldMeter -= 0.005; + + // //look for nearby objects to make zero-g + // function zeroG(who) { + // for (let i = 0, len = who.length; i < len; ++i) { + // 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; + // } + // } + // } + // zeroG(powerUp); + // zeroG(body); + + // player.force.y -= player.mass * mech.gravity; // + 0.005 * Math.sin(game.cycle / 10); //wobble + // //add player vertical friction to reduce map jump craziness + // Matter.Body.setVelocity(player, { + // x: player.velocity.x, + // y: player.velocity.y * 0.99 + // }); + + // //draw zero-G range + // ctx.beginPath(); + // ctx.arc(mech.pos.x, mech.pos.y + 15, range, 0, 2 * Math.PI); + // ctx.globalCompositeOperation = "color-burn"; + // ctx.fillStyle = "rgb(90,90,100)"; + // ctx.fill(); + // ctx.globalCompositeOperation = "source-over"; + + // } else { + // //trigger cooldown + // mech.fieldCDcycle = game.cycle + 120; + // } + // } else if ((keys[32] || game.mouseDownRight) && mech.fieldMeter > 0.2 && mech.fieldCDcycle < game.cycle) { //not hold but field button is pressed + // mech.grabRange = range + // mech.drawField(); + // mech.grabPowerUp(); + // mech.pushMobs(); + // mech.lookForPickUp(); + // } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle && mech.fieldCDcycle < game.cycle) { //holding, but field button is released + // mech.pickUp(); + // } else { + // 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() + // } + // }, ], - // () => { - // mech.fieldMode = 4; - // game.makeTextLog("

Negative Mass Field


active ability: hold left and right mouse to push things away
passive bonuses: +field size, -player gravity", 1000); //
passive bonus: can phase through blocks - // mech.setHoldDefaults(); - // mech.fieldArc = 1; - // mech.calculateFieldThreshold(); - // mech.holdingMassScale = 0.05; - // mech.gravity = 0.0015; //passive reduce gravity from default 0.0019 - - // mech.hold = function () { - // if (mech.isHolding) { - // mech.drawHold(mech.holdingTarget); - // mech.holding(); - // mech.throw(); - // } else if (game.mouseDown && (keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //both mouse keys down //push away - // if (mech.fieldMeter > 0.004) { - // mech.fieldMeter -= 0.004; - // const range = 450 + 100 * Math.sin(game.cycle / 20) - - // //draw push - // ctx.beginPath(); - // ctx.arc(mech.pos.x, mech.pos.y, range, 0, 2 * Math.PI); - // ctx.globalCompositeOperation = "color-burn"; - // ctx.fillStyle = "rgb(90,90,100)"; - // ctx.fill(); - // ctx.globalCompositeOperation = "source-over"; - - // function pushAway(who) { - // for (let i = 0, len = who.length; i < len; ++i) { - // sub = Matter.Vector.sub(who[i].position, mech.pos); - // dist = Matter.Vector.magnitude(sub); - // if (dist < range) { - // knock = Matter.Vector.mult(Matter.Vector.normalise(sub), who[i].mass / 200); - // who[i].force.x += knock.x; - // who[i].force.y += knock.y; - // // player.force.x -= knock.x / 10; - // // player.force.y -= knock.y / 10; - // } - // } - // } - // pushAway(body); - // pushAway(mob); - // pushAway(bullet); - // pushAway(powerUp); - // } else { - // mech.fieldCDcycle = game.cycle + 120; - // } - // } else if ((keys[32] || game.mouseDownRight) && mech.fieldMeter > 0.2) { //not hold but field button is pressed - // mech.grabRange = 200 + 50 * Math.sin(game.cycle / 20) - // mech.drawField(); - // mech.grabPowerUp(); - // mech.pushMobs(); - // mech.lookForPickUp(); - // } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle) { //holding, but field button is released - // mech.pickUp(); - // } else { - // 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() - // } - // }, - // ], - // phaseBlocks(mask = 0x010111) { - // level.bodyCollisionFilterMask = mask; - // for (let i = 0, len = body.length; i < len; i++) { - // body[i].collisionFilter.category = 0x0000001; - // body[i].collisionFilter.mask = mask; - // } - // }, drawLeg(stroke) { // if (game.mouseInGame.x > this.pos.x) { if (mech.angle > -Math.PI / 2 && mech.angle < Math.PI / 2) {