From cc34e23555855a48cda5c9bde3d214d1aaedb5ea Mon Sep 17 00:00:00 2001 From: landgreen Date: Thu, 19 Sep 2019 05:57:22 -0700 Subject: [PATCH] added localized invisibility field --- js/index.js | 21 +-------------------- js/level.js | 2 +- js/mobs.js | 10 ++++++---- js/player.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 25 deletions(-) diff --git a/js/index.js b/js/index.js index e87e868..bfafe9a 100644 --- a/js/index.js +++ b/js/index.js @@ -2,17 +2,6 @@ /* TODO: ******************************************* ***************************************************** -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 @@ -46,15 +35,11 @@ game mechanics low friction ground bouncy ground - give each foot a sensor to check for ground collisions - feet with not go into the ground even on slanted ground - this might be not worth it, but it might look really cool - track foot positions with velocity better as the player walks/crouch/runs add bullet on damage effects effects could: - add to the array mod.do new mob behaviors + add to the array mob.do new mob behaviors add a damage over time add a freeze change mob traits @@ -75,10 +60,6 @@ add bullet on damage effects remove standing on player actions replace with check if player feet are in an area. -unused ideas -passive: walk through blocks (difficult to implement) - - diff --git a/js/level.js b/js/level.js index 43cacc7..061f594 100644 --- a/js/level.js +++ b/js/level.js @@ -15,7 +15,7 @@ const level = { document.title = "n-gon"; this.intro(); //starting level // b.giveGuns(0) // set a starting gun for testing - // mech.fieldUpgrades[5]() //give a field power up for testing + mech.fieldUpgrades[6]() //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/mobs.js b/js/mobs.js index baab3b7..bb66987 100644 --- a/js/mobs.js +++ b/js/mobs.js @@ -98,10 +98,12 @@ const mobs = { }, seePlayerFreq: 20 + Math.round(Math.random() * 20), //how often NPC checks to see where player is, lower numbers have better vision foundPlayer() { - this.locatePlayer(); - if (!this.seePlayer.yes) { - this.alertNearByMobs(); - this.seePlayer.yes = true; + if (!mech.isStealth) { + this.locatePlayer(); + if (!this.seePlayer.yes) { + this.alertNearByMobs(); + this.seePlayer.yes = true; + } } }, lostPlayer() { diff --git a/js/player.js b/js/player.js index c6c787a..846b144 100644 --- a/js/player.js +++ b/js/player.js @@ -470,6 +470,7 @@ const mech = { index: 0 }, isHolding: false, + isStealth: false, throwCharge: 0, fireCDcycle: 0, fieldCDcycle: 0, @@ -493,6 +494,7 @@ const mech = { this.fieldMeter = 1; this.fieldRegen = 0.0015; this.fieldCDcycle = 0; + this.isStealth = false; this.holdingMassScale = 0.5; this.throwChargeRate = 2; this.throwChargeMax = 50; @@ -1035,6 +1037,49 @@ const mech = { mech.drawFieldMeter() } }, + () => { + mech.fieldMode = 6; + game.makeTextLog("Metamaterial Refractive Optics
(left mouse or space bar)

localized invisibility field

", 1000); + mech.setHoldDefaults(); + mech.fieldArc = 1; //field covers full 360 degrees + mech.calculateFieldThreshold(); + + mech.hold = function () { + mech.isStealth = false //isStealth is checked in mob foundPlayer() + + if (mech.isHolding) { + mech.drawHold(mech.holdingTarget); + mech.holding(); + mech.throw(); + } else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { + const DRAIN = 0.0015 //mech.fieldRegen = 0.0015 + if (mech.fieldMeter > DRAIN) { + mech.fieldMeter -= DRAIN; + mech.isStealth = true //isStealth is checked in mob foundPlayer() + + //draw stealth field + // ctx.fillStyle = "rgba(255,255,155,0.9)"; + // ctx.fillStyle = "rgba(255,255,255,1)"; + ctx.fill(); + ctx.beginPath(); + ctx.arc(mech.pos.x, mech.pos.y + 25, 110, 0, 2 * Math.PI); + ctx.globalCompositeOperation = "destination-in"; + ctx.fill(); + ctx.globalCompositeOperation = "source-over"; + + mech.grabPowerUp(); + mech.lookForPickUp(); + } else { + mech.fieldCDcycle = game.cycle + 120; + } + } 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