working on challenge run power up selection

This commit is contained in:
landgreen
2019-12-03 06:09:58 -08:00
parent b8f032f8db
commit f972ee247b
7 changed files with 60 additions and 21 deletions

View File

@@ -87,7 +87,7 @@
</details> </details>
</div> --> </div> -->
<div id="build-grid"></div> <div id="build-grid"></div>
<button type="button" id="build-button">builds</button> <button type="button" id="build-button">challenge run</button>

View File

@@ -67,7 +67,7 @@ const b = {
}, },
{ {
name: "auto-loading heuristics", name: "auto-loading heuristics",
description: "your <strong>rate of fire</strong> is 15% higher", description: "<strong>delay</strong> between your shots is 15% <strong>shorter</strong>",
have: false, //1 have: false, //1
effect: () => { //good for guns with extra ammo: needles, M80, rapid fire, flak, super balls effect: () => { //good for guns with extra ammo: needles, M80, rapid fire, flak, super balls
b.modFireRate = 0.85 b.modFireRate = 0.85
@@ -707,7 +707,7 @@ const b = {
name: "rail gun", //1 name: "rail gun", //1
description: "magnetically launch a dense rod<br><strong>hold left mouse</strong> to charge and <strong>repel</strong> enemies", description: "magnetically launch a dense rod<br><strong>hold left mouse</strong> to charge and <strong>repel</strong> enemies",
ammo: 0, ammo: 0,
ammoPack: 12, ammoPack: 11,
have: false, have: false,
isStarterGun: false, isStarterGun: false,
fire() { fire() {
@@ -790,7 +790,7 @@ const b = {
} }
//gently push away mobs while charging //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) { for (let i = 0, len = mob.length; i < len; ++i) {
const SUB = Matter.Vector.sub(mob[i].position, mech.pos) const SUB = Matter.Vector.sub(mob[i].position, mech.pos)
const DISTANCE = Matter.Vector.magnitude(SUB) const DISTANCE = Matter.Vector.magnitude(SUB)

View File

@@ -119,13 +119,52 @@ map: 0x000001 0x111111
const build = { const build = {
isShowingBuilds: false, isShowingBuilds: false,
list: [], list: [],
choosePowerUp(index, type) { choosePowerUp(who, index, type) {
build.list[build.list.length] = { //check if matching a current power up
index: index, for (let i = 0; i < build.list.length; i++) {
type: type 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", () => { document.getElementById("build-button").addEventListener("click", () => {
@@ -136,15 +175,15 @@ document.getElementById("build-button").addEventListener("click", () => {
document.body.style.overflow = "hidden" document.body.style.overflow = "hidden"
document.getElementById("controls").style.display = 'inline' document.getElementById("controls").style.display = 'inline'
} else { } else {
let text = '<p>click on 5 powers, then click begin <button type="button" id="build-begin-button">Begin</button></p>' let text = '<p>choose up to 5 powers<br> <button type="button" id="build-begin-button" onclick="build.startBuildRun()">Begin Run</button></p>'
for (let i = 1, len = mech.fieldUpgrades.length; i < len; i++) { for (let i = 1, len = mech.fieldUpgrades.length; i < len; i++) {
text += `<div class="build-grid-module" onclick="build.choosePowerUp(${i},'field')" ><div class="circle-grid field"></div> &nbsp; <strong style='font-size:1.3em;'>${mech.fieldUpgrades[i].name}</strong><br> ${mech.fieldUpgrades[i].description}</div>` text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'field')" ><div class="circle-grid field"></div> &nbsp; <strong style='font-size:1.3em;'>${mech.fieldUpgrades[i].name}</strong><br> ${mech.fieldUpgrades[i].description}</div>`
} }
for (let i = 0, len = b.guns.length; i < len; i++) { for (let i = 0, len = b.guns.length; i < len; i++) {
text += `<div class="build-grid-module" onclick="build.choosePowerUp(${i},'gun')"><div class="circle-grid gun"></div> &nbsp; <strong style='font-size:1.3em;'>${b.guns[i].name}</strong><br> ${b.guns[i].description}</div>` text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'gun')"><div class="circle-grid gun"></div> &nbsp; <strong style='font-size:1.3em;'>${b.guns[i].name}</strong><br> ${b.guns[i].description}</div>`
} }
for (let i = 0, len = b.mods.length; i < len; i++) { for (let i = 0, len = b.mods.length; i < len; i++) {
text += `<div class="build-grid-module" onclick="build.choosePowerUp(${i},'mod')"><div class="circle-grid mod"></div> &nbsp; <strong style='font-size:1.3em;'>${b.mods[i].name}</strong><br> ${b.mods[i].description}</div>` text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'mod')"><div class="circle-grid mod"></div> &nbsp; <strong style='font-size:1.3em;'>${b.mods[i].name}</strong><br> ${b.mods[i].description}</div>`
} }
el.innerHTML = text el.innerHTML = text
el.style.display = "grid" el.style.display = "grid"

View File

@@ -20,8 +20,8 @@ const level = {
// b.giveMod(13) // b.giveMod(13)
// spawn.pickList = ["ghoster", "ghoster"] // spawn.pickList = ["ghoster", "ghoster"]
// this.intro(); //starting level this.intro(); //starting level
this.testingMap(); // this.testingMap();
// this.bosses(); // this.bosses();
// this.aerie(); // this.aerie();
// this.rooftops(); // this.rooftops();

View File

@@ -441,7 +441,6 @@ const mech = {
dmg *= 0.93 dmg *= 0.93
} }
} }
console.log(dmg, "after")
this.health -= dmg; this.health -= dmg;
if (this.health < 0) { if (this.health < 0) {
this.health = 0; this.health = 0;

View File

@@ -152,12 +152,12 @@ const powerUps = {
if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "ammo"); if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "ammo");
return; 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"); powerUps.spawn(x, y, "gun");
if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "gun"); if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "gun");
return; return;
} }
if (Math.random() < 0.004 * (8 - b.modCount)) { if (Math.random() < 0.004 * (7 - b.modCount)) {
powerUps.spawn(x, y, "mod"); powerUps.spawn(x, y, "mod");
if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "mod"); if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "mod");
return; return;
@@ -172,13 +172,13 @@ const powerUps = {
if (mech.fieldMode === 0) { if (mech.fieldMode === 0) {
powerUps.spawn(x, y, "field") powerUps.spawn(x, y, "field")
if (Math.random() < b.modMoreDrops) 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") powerUps.spawn(x, y, "mod")
if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "mod") if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "mod")
} else if (Math.random() < 0.3) { } else if (Math.random() < 0.3) {
powerUps.spawn(x, y, "field"); powerUps.spawn(x, y, "field");
if (Math.random() < b.modMoreDrops) 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") powerUps.spawn(x, y, "gun")
if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "gun") if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "gun")
} else if (mech.health < 0.6) { } else if (mech.health < 0.6) {

View File

@@ -57,6 +57,7 @@ summary {
border: 0px; border: 0px;
/* border-radius: 8px; */ /* border-radius: 8px; */
background-color: #b6bfca; background-color: #b6bfca;
/* #b6bfca; */
display: none; display: none;
/* display: grid; */ /* display: grid; */
@@ -77,7 +78,7 @@ summary {
/* margin: 4px; */ /* margin: 4px; */
line-height: 150%; line-height: 150%;
border-radius: 6px; border-radius: 6px;
background: #eee; background: #fff;
font-size: 0.65em; font-size: 0.65em;
/* display: flex; */ /* display: flex; */
} }