diff --git a/js/index.js b/js/index.js index b55f68b..ef817b5 100644 --- a/js/index.js +++ b/js/index.js @@ -5,7 +5,6 @@ add a key that player picks up and needs to set on the exit door to open it add Boss levels - add modular difficulty settings take reduced dmg diff --git a/js/level.js b/js/level.js index 29c2457..5effb5d 100644 --- a/js/level.js +++ b/js/level.js @@ -16,7 +16,7 @@ const level = { // b.giveGuns("all", 1000) // b.giveGuns(9) // set a starting gun for testing // mech.fieldUpgrades[2].effect(); //give a field power up for testing - // b.giveMod(8) + // b.giveMod(7) this.intro(); //starting level // this.testingMap(); diff --git a/js/player.js b/js/player.js index a4be717..426f467 100644 --- a/js/player.js +++ b/js/player.js @@ -359,12 +359,34 @@ const mech = { alive: true, death() { if (b.modIsImmortal) { //if player has the immortality buff, spawn on the same level with randomized stats - //remove mods - b.setModDefaults(); - game.updateModHUD(); spawn.setSpawnList(); //new mob types game.clearNow = true; //triggers a map reset + //count mods + let totalMods = -2; //lose the immortality mod and one more, so -2 + for (let i = 0; i < b.mods.length; i++) { + if (b.mods[i].have) totalMods++ + } + + function randomizeMods() { + b.setModDefaults(); //remove all mods + for (let i = 0; i < totalMods; i++) { + //find what mods I don't have + let options = []; + for (let i = 0; i < b.mods.length; i++) { + if (!b.mods[i].have) options.push(i); + } + //add a new mods + if (options.length > 0) { + const choose = Math.floor(Math.random() * options.length) + let newMod = options[choose] + b.giveMod(newMod) + options.splice(choose, 1); + } + } + game.updateModHUD(); + } + function randomizeField() { if (game.levelsCleared > 5 && Math.random() < 0.9) { mech.fieldUpgrades[Math.floor(Math.random() * (mech.fieldUpgrades.length))].effect(); @@ -396,7 +418,7 @@ const mech = { //randomize ammo for (let i = 0, len = b.inventory.length; i < len; i++) { if (b.guns[b.inventory[i]].ammo !== Infinity) { - b.guns[b.inventory[i]].ammo = Math.max(0, Math.floor(5 * b.guns[b.inventory[i]].ammo * (Math.random() - 0.25))) + b.guns[b.inventory[i]].ammo = Math.max(0, Math.floor(6 * b.guns[b.inventory[i]].ammo * (Math.random() - 0.3))) } } game.makeGunHUD(); //update gun HUD @@ -406,16 +428,17 @@ const mech = { ctx.fillStyle = "rgba(255,255,255,0)"; ctx.fillRect(0, 0, canvas.width, canvas.height); } - + randomizeMods() randomizeGuns() randomizeField() randomizeHealth() - for (let i = 0; i < 7; i++) { + for (let i = 0; i < 6; i++) { setTimeout(function () { + randomizeMods() randomizeGuns() randomizeField() randomizeHealth() - game.makeTextLog(`probability amplitude will synchronize in ${7-i} seconds`, 1000); + game.makeTextLog(`probability amplitude will synchronize in ${6-i} seconds`, 1000); game.wipe = function () { //set wipe to have trails ctx.fillStyle = `rgba(255,255,255,${(i+1)*(i+1)*0.003})`; ctx.fillRect(0, 0, canvas.width, canvas.height); @@ -718,11 +741,16 @@ const mech = { } }, drawField() { - //draw field + if (mech.holdingTarget) { + ctx.fillStyle = "rgba(110,170,200," + (mech.fieldMeter * (0.05 + 0.05 * Math.random())) + ")"; + ctx.strokeStyle = "rgba(110, 200, 235, " + (0.3 + 0.08 * Math.random()) + ")" //"#9bd" //"rgba(110, 200, 235, " + (0.5 + 0.1 * Math.random()) + ")" + } else { + ctx.fillStyle = "rgba(110,170,200," + (0.02 + mech.fieldMeter * (0.15 + 0.15 * Math.random())) + ")"; + ctx.strokeStyle = "rgba(110, 200, 235, " + (0.6 + 0.2 * Math.random()) + ")" //"#9bd" //"rgba(110, 200, 235, " + (0.5 + 0.1 * Math.random()) + ")" + } const range = this.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); - ctx.strokeStyle = "#9bd" //"rgba(110, 200, 235, " + (0.5 + 0.1 * Math.random()) + ")" ctx.lineWidth = 2; ctx.lineCap = "butt" ctx.stroke(); @@ -736,14 +764,8 @@ const mech = { cp1x = mech.pos.x + 0.6 * range * Math.cos(a) cp1y = mech.pos.y + 0.6 * range * Math.sin(a) ctx.quadraticCurveTo(cp1x, cp1y, mech.pos.x + 1 * range * Math.cos(mech.angle - Math.PI * mech.fieldArc), mech.pos.y + 1 * range * Math.sin(mech.angle - Math.PI * mech.fieldArc)) - // ctx.lineTo(mech.pos.x + eye * Math.cos(mech.angle), mech.pos.y + eye * Math.sin(mech.angle)); - - if (mech.holdingTarget) { - ctx.fillStyle = "rgba(110,170,200," + (mech.fieldMeter * (0.05 + 0.05 * Math.random())) + ")"; - } else { - ctx.fillStyle = "rgba(110,170,200," + (0.02 + mech.fieldMeter * (0.15 + 0.15 * Math.random())) + ")"; - } ctx.fill(); + // ctx.lineTo(mech.pos.x + eye * Math.cos(mech.angle), mech.pos.y + eye * Math.sin(mech.angle)); //draw random lines in field for cool effect let offAngle = mech.angle + 1.7 * Math.PI * mech.fieldArc * (Math.random() - 0.5); @@ -755,8 +777,7 @@ const mech = { ctx.lineWidth = 1; ctx.stroke(); }, - grabPowerUp() { - //look for power ups to grab + grabPowerUp() { //look for power ups to grab with field if (mech.fieldCDcycle < mech.cycle) { const grabPowerUpRange2 = (this.grabRange + 220) * (this.grabRange + 220) for (let i = 0, len = powerUp.length; i < len; ++i) { @@ -785,8 +806,7 @@ const mech = { } } }, - pushMobs() { - // push all mobs in range + pushMobs() { // push all mobs in range and in direction looking for (let i = 0, len = mob.length; i < len; ++i) { if (this.lookingAt(mob[i]) && Matter.Vector.magnitude(Matter.Vector.sub(mob[i].position, this.pos)) < this.grabRange && Matter.Query.ray(map, mob[i].position, this.pos).length === 0) { const fieldBlockCost = Math.max(0.02, mob[i].mass * 0.012) //0.012 @@ -811,8 +831,7 @@ const mech = { } } }, - pushMobs360(range = this.grabRange * 0.75) { - // push all mobs in range + pushMobs360(range = this.grabRange * 0.75) { // push all mobs in range in any direction for (let i = 0, len = mob.length; i < len; ++i) { if (Matter.Vector.magnitude(Matter.Vector.sub(mob[i].position, this.pos)) < range && Matter.Query.ray(map, mob[i].position, this.pos).length === 0) { const fieldBlockCost = Math.max(0.02, mob[i].mass * 0.012) @@ -928,7 +947,7 @@ const mech = { }, hold() {}, fieldText() { - game.makeTextLog(`${mech.fieldUpgrades[mech.fieldMode].name}
(right click or space bar)

${mech.fieldUpgrades[mech.fieldMode].description}`, 1000); + game.makeTextLog(`
  ${mech.fieldUpgrades[mech.fieldMode].name}
(right click or space bar)

${mech.fieldUpgrades[mech.fieldMode].description}`, 1000); document.getElementById("field").innerHTML = mech.fieldUpgrades[mech.fieldMode].name //add field }, fieldUpgrades: [{ diff --git a/js/powerups.js b/js/powerups.js index 554a827..5212b12 100644 --- a/js/powerups.js +++ b/js/powerups.js @@ -11,7 +11,7 @@ const powerUps = { let heal = (this.size / 40) ** 2 heal = Math.min(1 - mech.health, heal) mech.addHealth(heal); - if (!game.lastLogTime && heal > 0) game.makeTextLog(" heal " + (heal * 100).toFixed(0) + "%", 300) + if (!game.lastLogTime && heal > 0) game.makeTextLog(" heal " + (heal * 100).toFixed(0) + "%", 300) } }, ammo: { @@ -41,13 +41,13 @@ const powerUps = { } if (target.ammo === Infinity) { mech.fieldMeter = 1; - if (!game.lastLogTime) game.makeTextLog("+energy", 300); + if (!game.lastLogTime) game.makeTextLog("+energy", 300); } else { //ammo given scales as mobs take more hits to kill const ammo = Math.ceil((target.ammoPack * (0.6 + 0.04 * Math.random())) / b.dmgScale); target.ammo += ammo; game.updateGunHUD(); - if (!game.lastLogTime) game.makeTextLog("+" + ammo + " ammo for " + target.name + "", 300); + if (!game.lastLogTime) game.makeTextLog("+" + ammo + " ammo for " + target.name + "", 300); } } }, @@ -91,16 +91,16 @@ const powerUps = { } //give a random mod from the mods I don't have if (options.length > 0) { + if (options.length === 1) powerUps.haveAllMods = true let newMod = options[Math.floor(Math.random() * options.length)] b.giveMod(newMod) - game.makeTextLog(`${b.mods[newMod].name}

${b.mods[newMod].description}`, 1000); - if (options.length < 2) powerUps.haveAllMods = true + game.makeTextLog(`
 ${b.mods[newMod].name}

${b.mods[newMod].description}`, 1000); } } }, gun: { name: "gun", - color: "#37a", + color: "#26a", size() { return 35; }, @@ -118,7 +118,7 @@ const powerUps = { if (options.length > 0) { let newGun = options[Math.floor(Math.random() * options.length)]; if (b.activeGun === null) b.activeGun = newGun //if no active gun switch to new gun - game.makeTextLog(`${b.guns[newGun].name}
(left click)

${b.guns[newGun].description}`, 900); + game.makeTextLog(`
  ${b.guns[newGun].name}
(left click)

${b.guns[newGun].description}`, 900); b.guns[newGun].have = true; b.inventory.push(newGun); b.guns[newGun].ammo += b.guns[newGun].ammoPack * 2; @@ -129,7 +129,7 @@ const powerUps = { const ammo = Math.ceil(b.guns[ammoTarget].ammoPack * 2); b.guns[ammoTarget].ammo += ammo; game.updateGunHUD(); - game.makeTextLog("+" + ammo + " ammo for " + b.guns[ammoTarget].name + "", 300); + game.makeTextLog("+" + ammo + " ammo for " + b.guns[ammoTarget].name + "", 300); } } }, @@ -146,7 +146,7 @@ const powerUps = { powerUps.spawn(x, y, "gun"); return; } - if (Math.random() < 0.008 && !powerUps.haveAllMods) { + if (Math.random() < 0.007 && !powerUps.haveAllMods) { powerUps.spawn(x, y, "mod"); return; } @@ -160,11 +160,11 @@ const powerUps = { powerUps.spawn(x, y, "field") } else if (Math.random() < 0.35 && !powerUps.haveAllMods) { powerUps.spawn(x, y, "mod") - } else if (Math.random() < 0.27) { + } else if (Math.random() < 0.25) { powerUps.spawn(x, y, "field"); - } else if (Math.random() < 0.04 * (7 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun to drop + } else if (Math.random() < 0.05 * (7 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun to drop powerUps.spawn(x, y, "gun") - } else if (mech.health < 0.5) { + } else if (mech.health < 0.6) { powerUps.spawn(x, y, "heal"); } else { powerUps.spawn(x, y, "ammo"); diff --git a/style.css b/style.css index 7c394ca..39da874 100644 --- a/style.css +++ b/style.css @@ -196,12 +196,16 @@ summary { user-select: none; } +em { + opacity: 0.7; +} + .color-f { color: #0bf; } .color-b { - color: #023; + color: #024; } .color-d { @@ -227,6 +231,27 @@ summary { font-size: 90%; } +.circle { + width: 25px; + height: 25px; + border-radius: 50%; + display: inline-block; +} + +.field { + background: #0bf; +} + +.mod { + background: #96e; +} + +.gun { + background: #149; +} + + + .box { padding: 3px 8px 3px 8px; border: 2px solid #444; @@ -234,9 +259,6 @@ summary { background-color: rgba(255, 255, 255, 0.5); } -em { - opacity: 0.7; -} .wrapper { display: grid;