working on challenge run power up selection
This commit is contained in:
@@ -87,7 +87,7 @@
|
||||
</details>
|
||||
</div> -->
|
||||
<div id="build-grid"></div>
|
||||
<button type="button" id="build-button">builds</button>
|
||||
<button type="button" id="build-button">challenge run</button>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
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
|
||||
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<br><strong>hold left mouse</strong> to charge and <strong>repel</strong> 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)
|
||||
|
||||
57
js/index.js
57
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 = '<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++) {
|
||||
text += `<div class="build-grid-module" onclick="build.choosePowerUp(${i},'field')" ><div class="circle-grid field"></div> <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> <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++) {
|
||||
text += `<div class="build-grid-module" onclick="build.choosePowerUp(${i},'gun')"><div class="circle-grid gun"></div> <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> <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++) {
|
||||
text += `<div class="build-grid-module" onclick="build.choosePowerUp(${i},'mod')"><div class="circle-grid mod"></div> <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> <strong style='font-size:1.3em;'>${b.mods[i].name}</strong><br> ${b.mods[i].description}</div>`
|
||||
}
|
||||
el.innerHTML = text
|
||||
el.style.display = "grid"
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -441,7 +441,6 @@ const mech = {
|
||||
dmg *= 0.93
|
||||
}
|
||||
}
|
||||
console.log(dmg, "after")
|
||||
this.health -= dmg;
|
||||
if (this.health < 0) {
|
||||
this.health = 0;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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; */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user