diff --git a/index.html b/index.html index 32ed923..b943379 100644 --- a/index.html +++ b/index.html @@ -87,7 +87,7 @@ -->
- + diff --git a/js/bullets.js b/js/bullets.js index 673d39e..a528fd2 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -67,7 +67,7 @@ const b = { }, { name: "auto-loading heuristics", - description: "your rate of fire is 15% higher", + description: "delay between your shots is 15% shorter", have: false, //1 effect: () => { //good for guns with extra ammo: needles, M80, rapid fire, flak, super balls b.modFireRate = 0.85 @@ -707,7 +707,7 @@ const b = { name: "rail gun", //1 description: "magnetically launch a dense rod
hold left mouse to charge and repel enemies", ammo: 0, - ammoPack: 12, + ammoPack: 11, have: false, isStarterGun: false, fire() { @@ -790,7 +790,7 @@ const b = { } //gently push away mobs while charging - const RANGE = 350 * this.charge + const RANGE = 270 * this.charge for (let i = 0, len = mob.length; i < len; ++i) { const SUB = Matter.Vector.sub(mob[i].position, mech.pos) const DISTANCE = Matter.Vector.magnitude(SUB) diff --git a/js/index.js b/js/index.js index 0cee5b9..254298a 100644 --- a/js/index.js +++ b/js/index.js @@ -119,13 +119,52 @@ map: 0x000001 0x111111 const build = { isShowingBuilds: false, list: [], - choosePowerUp(index, type) { - build.list[build.list.length] = { - index: index, - type: type + choosePowerUp(who, index, type) { + //check if matching a current power up + for (let i = 0; i < build.list.length; i++) { + if (build.list[i].index === index && build.list[i].type === type) { //if already click, toggle off + build.list.splice(i, 1); + who.style.backgroundColor = "#fff" + return + } + } + + //check if trying to get a second field + if (type === "field") { + for (let i = 0; i < build.list.length; i++) { + if (build.list[i].type === "field") { //if already click, toggle off + build.list[i].who.style.backgroundColor = "#fff" + build.list.splice(i, 1); + } + } + } + + if (build.list.length < 5) { //add to build array + // who.style.border = "2px solid #333" + who.style.backgroundColor = "#868f9a" + build.list[build.list.length] = { + who: who, + index: index, + type: type + } } - console.log(build.list) }, + startBuildRun() { + spawn.setSpawnList(); + spawn.setSpawnList(); + game.startGame(); + game.difficulty = 6; + level.isBuildRun = true; + for (let i = 0; i < build.list.length; i++) { + if (build.list[i].type === "field") { + mech.fieldUpgrades[build.list[i].index].effect(); + } else if (build.list[i].type === "gun") { + b.giveGuns(build.list[i].index) + } else if (build.list[i].type === "mod") { + b.giveMod(build.list[i].index) + } + } + } } document.getElementById("build-button").addEventListener("click", () => { @@ -136,15 +175,15 @@ document.getElementById("build-button").addEventListener("click", () => { document.body.style.overflow = "hidden" document.getElementById("controls").style.display = 'inline' } else { - let text = '

click on 5 powers, then click begin

' + let text = '

choose up to 5 powers

' for (let i = 1, len = mech.fieldUpgrades.length; i < len; i++) { - text += `
  ${mech.fieldUpgrades[i].name}
${mech.fieldUpgrades[i].description}
` + text += `
  ${mech.fieldUpgrades[i].name}
${mech.fieldUpgrades[i].description}
` } for (let i = 0, len = b.guns.length; i < len; i++) { - text += `
  ${b.guns[i].name}
${b.guns[i].description}
` + text += `
  ${b.guns[i].name}
${b.guns[i].description}
` } for (let i = 0, len = b.mods.length; i < len; i++) { - text += `
  ${b.mods[i].name}
${b.mods[i].description}
` + text += `
  ${b.mods[i].name}
${b.mods[i].description}
` } el.innerHTML = text el.style.display = "grid" diff --git a/js/level.js b/js/level.js index 264394f..6ccc961 100644 --- a/js/level.js +++ b/js/level.js @@ -20,8 +20,8 @@ const level = { // b.giveMod(13) // spawn.pickList = ["ghoster", "ghoster"] - // this.intro(); //starting level - this.testingMap(); + this.intro(); //starting level + // this.testingMap(); // this.bosses(); // this.aerie(); // this.rooftops(); diff --git a/js/player.js b/js/player.js index d825954..18f87e9 100644 --- a/js/player.js +++ b/js/player.js @@ -441,7 +441,6 @@ const mech = { dmg *= 0.93 } } - console.log(dmg, "after") this.health -= dmg; if (this.health < 0) { this.health = 0; diff --git a/js/powerups.js b/js/powerups.js index 7f18594..b1e5cab 100644 --- a/js/powerups.js +++ b/js/powerups.js @@ -152,12 +152,12 @@ const powerUps = { if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "ammo"); return; } - if (Math.random() < 0.004 * (5 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun to drop + if (Math.random() < 0.004 * (4 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun to drop powerUps.spawn(x, y, "gun"); if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "gun"); return; } - if (Math.random() < 0.004 * (8 - b.modCount)) { + if (Math.random() < 0.004 * (7 - b.modCount)) { powerUps.spawn(x, y, "mod"); if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "mod"); return; @@ -172,13 +172,13 @@ const powerUps = { if (mech.fieldMode === 0) { powerUps.spawn(x, y, "field") if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "field") - } else if (Math.random() < 0.042 * (b.mods.length - b.modCount)) { + } else if (Math.random() < 0.3) { powerUps.spawn(x, y, "mod") if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "mod") } else if (Math.random() < 0.3) { powerUps.spawn(x, y, "field"); if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "field"); - } else if (Math.random() < 0.05 * (7 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun to drop + } else if (Math.random() < 0.3) { powerUps.spawn(x, y, "gun") if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "gun") } else if (mech.health < 0.6) { diff --git a/style.css b/style.css index f6d2d04..99e1002 100644 --- a/style.css +++ b/style.css @@ -57,6 +57,7 @@ summary { border: 0px; /* border-radius: 8px; */ background-color: #b6bfca; + /* #b6bfca; */ display: none; /* display: grid; */ @@ -77,7 +78,7 @@ summary { /* margin: 4px; */ line-height: 150%; border-radius: 6px; - background: #eee; + background: #fff; font-size: 0.65em; /* display: flex; */ }