shields are

shields are more rare, but much stronger, negative mass field is combined with Gauss rifle mod, negative mass field moves player faster, new mod piezoelectric plating,You may now choose to cancel the power up selection screen.  (no recursive mods in custon yet, it's an annoying UI rewrite)
This commit is contained in:
landgreen
2020-01-03 09:29:25 -08:00
parent 47eeafab08
commit 42b2cde9a2
9 changed files with 706 additions and 641 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -79,7 +79,7 @@ function mobCollisionChecks(event) {
for (let i = 0, j = pairs.length; i != j; i++) { for (let i = 0, j = pairs.length; i != j; i++) {
//body + player collision //body + player collision
if (game.isBodyDamage && mech.damageImmune < mech.cycle) { if (game.isBodyDamage) {
if (pairs[i].bodyA === playerBody || pairs[i].bodyA === playerHead) { if (pairs[i].bodyA === playerBody || pairs[i].bodyA === playerHead) {
collidePlayer(pairs[i].bodyB) collidePlayer(pairs[i].bodyB)
} else if (pairs[i].bodyB === playerBody || pairs[i].bodyB === playerHead) { } else if (pairs[i].bodyB === playerBody || pairs[i].bodyB === playerHead) {
@@ -91,7 +91,6 @@ function mobCollisionChecks(event) {
if (obj.classType === "body" && obj.speed > speedThreshold && obj.mass > massThreshold) { //dmg from hitting a body if (obj.classType === "body" && obj.speed > speedThreshold && obj.mass > massThreshold) { //dmg from hitting a body
const v = Vector.magnitude(Vector.sub(player.velocity, obj.velocity)); const v = Vector.magnitude(Vector.sub(player.velocity, obj.velocity));
if (v > speedThreshold) { if (v > speedThreshold) {
mech.damageImmune = mech.cycle + 30; //player is immune to collision damage for 30 cycles
let dmg = Math.sqrt((v - speedThreshold + 0.1) * (obj.mass - massThreshold)) * 0.01; let dmg = Math.sqrt((v - speedThreshold + 0.1) * (obj.mass - massThreshold)) * 0.01;
dmg = Math.min(Math.max(dmg, 0.02), 0.15); dmg = Math.min(Math.max(dmg, 0.02), 0.15);
mech.damage(dmg); mech.damage(dmg);
@@ -105,21 +104,6 @@ function mobCollisionChecks(event) {
return; return;
} }
} }
// else if (obj.isStatic && player.speed > speedThreshold * 2) { //falling dmg / hitting map dmg
// mech.damageImmune = mech.cycle + 30;
// console.log(player.speed)
// let dmg = Math.min(Math.max(player.speed * 0.001, 0.02), 0.2);
// mech.damage(dmg);
// game.drawList.push({
// //add dmg to draw queue
// x: pairs[i].activeContacts[0].vertex.x,
// y: pairs[i].activeContacts[0].vertex.y,
// radius: dmg * 500,
// color: game.mobDmgColor,
// time: game.drawTime
// });
// return;
// }
} }
//mob + (player,bullet,body) collisions //mob + (player,bullet,body) collisions
@@ -135,9 +119,9 @@ function mobCollisionChecks(event) {
function collideMob(obj) { function collideMob(obj) {
//player + mob collision //player + mob collision
if (obj === playerBody || obj === playerHead) { if (mech.collisionImmune < mech.cycle) {
if (mech.damageImmune < mech.cycle) { if (obj === playerBody || obj === playerHead) {
mech.damageImmune = mech.cycle + 30; //player is immune to collision damage for 30 cycles mech.collisionImmune = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles
mob[k].foundPlayer(); mob[k].foundPlayer();
let dmg = Math.min(Math.max(0.025 * Math.sqrt(mob[k].mass), 0.05), 0.3) * game.dmgScale; //player damage is capped at 0.3*dmgScale of 1.0 let dmg = Math.min(Math.max(0.025 * Math.sqrt(mob[k].mass), 0.05), 0.3) * game.dmgScale; //player damage is capped at 0.3*dmgScale of 1.0
mech.damage(dmg); mech.damage(dmg);
@@ -163,23 +147,24 @@ function mobCollisionChecks(event) {
}); });
} }
//extra kick between player and mob //this section would be better with forces but they don't work...
let angle = Math.atan2(player.position.y - mob[k].position.y, player.position.x - mob[k].position.x);
Matter.Body.setVelocity(player, {
x: player.velocity.x + 8 * Math.cos(angle),
y: player.velocity.y + 8 * Math.sin(angle)
});
Matter.Body.setVelocity(mob[k], {
x: mob[k].velocity.x - 8 * Math.cos(angle),
y: mob[k].velocity.y - 8 * Math.sin(angle)
});
return;
} }
//extra kick between player and mob //this section would be better with forces but they don't work...
let angle = Math.atan2(player.position.y - mob[k].position.y, player.position.x - mob[k].position.x);
Matter.Body.setVelocity(player, {
x: player.velocity.x + 8 * Math.cos(angle),
y: player.velocity.y + 8 * Math.sin(angle)
});
Matter.Body.setVelocity(mob[k], {
x: mob[k].velocity.x - 8 * Math.cos(angle),
y: mob[k].velocity.y - 8 * Math.sin(angle)
});
return;
} }
//mob + bullet collisions //mob + bullet collisions
if (obj.classType === "bullet" && obj.speed > obj.minDmgSpeed) { if (obj.classType === "bullet" && obj.speed > obj.minDmgSpeed) {
// const dmg = b.dmgScale * (obj.dmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity))); // const dmg = b.dmgScale * (obj.dmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity)));
let dmg = b.dmgScale * (obj.dmg + b.modExtraDmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity))) let dmg = b.dmgScale * (obj.dmg + b.modExtraDmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity)))
if (mob[k].shield) dmg *= 0.3
if (b.isModCrit && !mob[k].seePlayer.recall) dmg *= 5 if (b.isModCrit && !mob[k].seePlayer.recall) dmg *= 5
mob[k].foundPlayer(); mob[k].foundPlayer();
mob[k].damage(dmg); mob[k].damage(dmg);

View File

@@ -2,11 +2,25 @@
/* TODO: ******************************************* /* TODO: *******************************************
***************************************************** *****************************************************
mod: fields do damage on blocking
name: something about radiation?
mod: do something at the end of each level
heal to full
should still be effected by the heal reduction at higher difficulty
give ammo to current gun
give goals/quests for each level
how to track goals?
take no damage
don't shoot
selection options for field to stay with current selection options for field to stay with current
custom mode grey out mods that are bad, like selection based mods custom mode grey out mods that are bad, like selection based mods
not important not important
custom mode can't use recursive mods
field graphics too dark at high energy field graphics too dark at high energy
not important not important
@@ -19,9 +33,10 @@ game setting for slower computers
fewer debris fewer debris
fewer mobs fewer mobs
mod: guardian mod: gain energy after taking damage
recursive use piezoelectric name (already used)
spawns at start of level
mod: ground stomp on enterLand()
mod: if you fire when out of ammo you gain 1 ammo pack at the cost of mod: if you fire when out of ammo you gain 1 ammo pack at the cost of
10% max health 10% max health
@@ -153,6 +168,7 @@ const build = {
list: [], list: [],
choosePowerUp(who, index, type) { choosePowerUp(who, index, type) {
//check if matching a current power up //check if matching a current power up
// if (type === "field" || type === "gun") {
for (let i = 0; i < build.list.length; i++) { 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 if (build.list[i].index === index && build.list[i].type === type) { //if already click, toggle off
build.list.splice(i, 1); build.list.splice(i, 1);
@@ -160,7 +176,6 @@ const build = {
return return
} }
} }
//check if trying to get a second field //check if trying to get a second field
if (type === "field") { if (type === "field") {
for (let i = 0; i < build.list.length; i++) { for (let i = 0; i < build.list.length; i++) {
@@ -170,15 +185,47 @@ const build = {
} }
} }
} }
// } else { //type is mod
// //count each mod type to check for recursion caps
// let counts = []
// for (let i = 0; i < build.list.length; i++) {
// if (build.list[i].type === "mod") {
// if (!counts[build.list[i].index]) {
// counts[build.list[i].index] = 1
// } else {
// counts[build.list[i].index] = counts[build.list[i].index] + 1
// }
// }
// }
// for (let i = 0; i < build.list.length; i++) {
// //if above max count, toggle off
// if (build.list[i].index === index && build.list[i].type === type &&
// counts[index] >= b.mods[index].maxCount) {
// //remove all versions of mod
// who.style.backgroundColor = "#fff"
// return
// }
// }
// }
if (build.list.length < 5) { //add to build array if (build.list.length < 5) { //add to build array
who.style.backgroundColor = "#919ba8" //"#868f9a" who.style.backgroundColor = "#919ba8" //"#868f9a"
build.list[build.list.length] = { build.list[build.list.length] = {
who: who, who: who,
index: index, index: index,
type: type type: type,
} }
} }
console.log(build.list)
},
removeMod(index) {
for (let i = build.list.length - 1; i > -1; i--) {
if (build.list[i].type === "mod" && build.list[i].index === index) build.list.splice(i, 1);
}
}, },
startBuildRun() { startBuildRun() {
spawn.setSpawnList(); spawn.setSpawnList();

View File

@@ -14,9 +14,9 @@ const level = {
start() { start() {
if (level.levelsCleared === 0) { if (level.levelsCleared === 0) {
// game.difficulty = 6; //for testing to simulate possible mobs spawns // game.difficulty = 6; //for testing to simulate possible mobs spawns
// b.giveGuns(0) // b.giveGuns(15)
// mech.setField(2) // mech.setField(3)
// b.giveMod(20) // b.giveMod(10);
level.intro(); //starting level level.intro(); //starting level
// level.testingMap(); // level.testingMap();
@@ -114,7 +114,7 @@ const level = {
// spawn.lineBoss(-500, -600, spawn.allowedBossList[Math.floor(Math.random() * spawn.allowedBossList.length)]); // spawn.lineBoss(-500, -600, spawn.allowedBossList[Math.floor(Math.random() * spawn.allowedBossList.length)]);
// spawn.bodyRect(-135, -50, 50, 50); // spawn.bodyRect(-135, -50, 50, 50);
// spawn.bodyRect(-140, -100, 50, 50); // spawn.bodyRect(-140, -100, 50, 50);
powerUps.spawn(420, -400, "field", false); powerUps.spawn(420, -400, "gun", false);
// powerUps.spawn(420, -400, "field", false); // powerUps.spawn(420, -400, "field", false);
// powerUps.spawn(420, -400, "field", false); // powerUps.spawn(420, -400, "field", false);
// powerUps.spawn(420, -400, "field", false); // powerUps.spawn(420, -400, "field", false);

View File

@@ -961,7 +961,7 @@ const mobs = {
if (this.dropPowerUp) { if (this.dropPowerUp) {
powerUps.spawnRandomPowerUp(this.position.x, this.position.y, this.mass, radius); powerUps.spawnRandomPowerUp(this.position.x, this.position.y, this.mass, radius);
if (Math.random() < b.modSpores) { if (Math.random() < b.modSpores) {
for (let i = 0, len = Math.floor(3 + this.mass * Math.random()); i < len; i++) { for (let i = 0, len = Math.floor(4 + this.mass * Math.random()); i < len; i++) {
b.spore(this) //spawn drone b.spore(this) //spawn drone
} }
} }

View File

@@ -55,7 +55,7 @@ const mech = {
cycle: 0, cycle: 0,
width: 50, width: 50,
radius: 30, radius: 30,
fillColor: "#fff", fillColor: "#fff", //changed by mod piezoelectric plating (damage immunity)
fillColorDark: "#ccc", fillColorDark: "#ccc",
height: 42, height: 42,
yOffWhen: { yOffWhen: {
@@ -207,7 +207,6 @@ const mech = {
mech.hardLandCD = mech.cycle + Math.min(momentum / 6 - 6, 40) mech.hardLandCD = mech.cycle + Math.min(momentum / 6 - 6, 40)
if (game.isBodyDamage && player.velocity.y > 26 && momentum > 165 * b.modSquirrelFx) { //falling damage if (game.isBodyDamage && player.velocity.y > 26 && momentum > 165 * b.modSquirrelFx) { //falling damage
mech.damageImmune = mech.cycle + 30; //player is immune to collision damage for 30 cycles
let dmg = Math.sqrt(momentum - 165) * 0.01 let dmg = Math.sqrt(momentum - 165) * 0.01
dmg = Math.min(Math.max(dmg, 0.02), 0.20); dmg = Math.min(Math.max(dmg, 0.02), 0.20);
mech.damage(dmg); mech.damage(dmg);
@@ -440,6 +439,7 @@ const mech = {
mech.displayHealth(); mech.displayHealth();
}, },
defaultFPSCycle: 0, //tracks when to return to normal fps defaultFPSCycle: 0, //tracks when to return to normal fps
collisionImmune: 0, //used in engine
damage(dmg) { damage(dmg) {
if (b.isModEntanglement && b.inventory[0] === b.activeGun) { if (b.isModEntanglement && b.inventory[0] === b.activeGun) {
for (let i = 0, len = b.inventory.length; i < len; i++) { for (let i = 0, len = b.inventory.length; i < len; i++) {
@@ -513,7 +513,6 @@ const mech = {
// }; // };
// requestAnimationFrame(normalFPS); // requestAnimationFrame(normalFPS);
}, },
damageImmune: 0,
hitMob(i, dmg) { hitMob(i, dmg) {
//prevents damage happening too quick //prevents damage happening too quick
}, },
@@ -588,11 +587,13 @@ const mech = {
mech.knee.y = (l / d) * (mech.foot.y - mech.hip.y) + (h / d) * (mech.foot.x - mech.hip.x) + mech.hip.y; mech.knee.y = (l / d) * (mech.foot.y - mech.hip.y) + (h / d) * (mech.foot.x - mech.hip.x) + mech.hip.y;
}, },
draw() { draw() {
// mech.fillColor = (mech.collisionImmune < mech.cycle) ? "#fff" : "rgba(255,255,255,0.1)" //"#cff"
ctx.fillStyle = mech.fillColor; ctx.fillStyle = mech.fillColor;
mech.walk_cycle += mech.flipLegs * mech.Vx; mech.walk_cycle += mech.flipLegs * mech.Vx;
//draw body //draw body
ctx.save(); ctx.save();
ctx.globalAlpha = (mech.collisionImmune < mech.cycle) ? 1 : 0.7
ctx.translate(mech.pos.x, mech.pos.y); ctx.translate(mech.pos.x, mech.pos.y);
mech.calcLeg(Math.PI, -3); mech.calcLeg(Math.PI, -3);
mech.drawLeg("#4a4a4a"); mech.drawLeg("#4a4a4a");
@@ -654,8 +655,10 @@ const mech = {
mech.fieldCDcycle = 0; mech.fieldCDcycle = 0;
mech.isStealth = false; mech.isStealth = false;
player.collisionFilter.mask = cat.body | cat.map | cat.mob | cat.mobBullet | cat.mobShield player.collisionFilter.mask = cat.body | cat.map | cat.mob | cat.mobBullet | cat.mobShield
mech.holdingMassScale = 0.5;
mech.fieldShieldingScale = 1; //scale energy loss after collision with mob mech.fieldShieldingScale = 1; //scale energy loss after collision with mob
mech.holdingMassScale = 0.5;
mech.throwChargeRate = 2;
mech.throwChargeMax = 50;
mech.grabRange = 175; mech.grabRange = 175;
mech.fieldArc = 0.2; //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) mech.fieldArc = 0.2; //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
mech.calculateFieldThreshold(); //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) mech.calculateFieldThreshold(); //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
@@ -1311,9 +1314,12 @@ const mech = {
}, },
{ {
name: "negative mass field", name: "negative mass field",
description: "use <strong class='color-f'>energy</strong> to nullify &nbsp; <strong style='letter-spacing: 10px;'>gravity</strong><br><em>can fire bullets while active</em>", description: "use <strong class='color-f'>energy</strong> to nullify &nbsp; <strong style='letter-spacing: 12px;'>gravity</strong><br><strong>launch</strong> larger blocks at much higher speeds",
effect: () => { effect: () => {
mech.fieldFire = true; mech.fieldFire = true;
mech.throwChargeRate = 4;
mech.throwChargeMax = 150;
mech.holdingMassScale = 0.05; //can hold heavier blocks with lower cost to jumping
mech.hold = function () { mech.hold = function () {
if (mech.isHolding) { if (mech.isHolding) {
@@ -1321,11 +1327,11 @@ const mech = {
mech.holding(); mech.holding();
mech.throwBlock(); mech.throwBlock();
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) { //push away } else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) { //push away
const DRAIN = 0.0004 const DRAIN = 0.00025
if (mech.fieldMeter > DRAIN) { if (mech.fieldMeter > DRAIN) {
mech.grabPowerUp(); mech.grabPowerUp();
mech.lookForPickUp(170); mech.lookForPickUp(150);
mech.pushMobs360(200); mech.pushMobs360(150);
//look for nearby objects to make zero-g //look for nearby objects to make zero-g
function zeroG(who, mag = 1.06) { function zeroG(who, mag = 1.06) {
for (let i = 0, len = who.length; i < len; ++i) { for (let i = 0, len = who.length; i < len; ++i) {
@@ -1339,22 +1345,17 @@ const mech = {
// zeroG(bullet); //works fine, but not that noticeable and maybe not worth the possible performance hit // zeroG(bullet); //works fine, but not that noticeable and maybe not worth the possible performance hit
// zeroG(mob); //mobs are too irregular to make this work? // zeroG(mob); //mobs are too irregular to make this work?
Matter.Body.setVelocity(player, {
x: player.velocity.x,
y: player.velocity.y * 0.97
});
if (keys[83] || keys[40]) { //down if (keys[83] || keys[40]) { //down
player.force.y -= 0.8 * player.mass * mech.gravity; player.force.y -= 0.5 * player.mass * mech.gravity;
mech.grabRange = mech.grabRange * 0.97 + 400 * 0.03; mech.grabRange = mech.grabRange * 0.97 + 400 * 0.03;
zeroG(powerUp, 0.85); zeroG(powerUp, 0.7);
zeroG(body, 0.85); zeroG(body, 0.7);
} else if (keys[87] || keys[38]) { //up } else if (keys[87] || keys[38]) { //up
mech.fieldMeter -= 5 * DRAIN; mech.fieldMeter -= 5 * DRAIN;
mech.grabRange = mech.grabRange * 0.97 + 750 * 0.03; mech.grabRange = mech.grabRange * 0.97 + 850 * 0.03;
player.force.y -= 1.2 * player.mass * mech.gravity; player.force.y -= 1.45 * player.mass * mech.gravity;
zeroG(powerUp, 1.13); zeroG(powerUp, 1.38);
zeroG(body, 1.13); zeroG(body, 1.38);
} else { } else {
mech.fieldMeter -= DRAIN; mech.fieldMeter -= DRAIN;
mech.grabRange = mech.grabRange * 0.97 + 650 * 0.03; mech.grabRange = mech.grabRange * 0.97 + 650 * 0.03;
@@ -1366,8 +1367,13 @@ const mech = {
//add extra friction for horizontal motion //add extra friction for horizontal motion
if (keys[65] || keys[68] || keys[37] || keys[39]) { if (keys[65] || keys[68] || keys[37] || keys[39]) {
Matter.Body.setVelocity(player, { Matter.Body.setVelocity(player, {
x: player.velocity.x * 0.85, x: player.velocity.x * 0.95,
y: player.velocity.y y: player.velocity.y * 0.97
});
} else { //slow rise and fall
Matter.Body.setVelocity(player, {
x: player.velocity.x,
y: player.velocity.y * 0.97
}); });
} }
@@ -1443,7 +1449,7 @@ const mech = {
mech.hold = function () { mech.hold = function () {
if (mech.fieldMeter > mech.fieldEnergyMax - 0.02 && mech.fieldCDcycle < mech.cycle) { if (mech.fieldMeter > mech.fieldEnergyMax - 0.02 && mech.fieldCDcycle < mech.cycle) {
mech.fieldCDcycle = mech.cycle + 17; // set cool down to prevent +energy from making huge numbers of drones mech.fieldCDcycle = mech.cycle + 17; // set cool down to prevent +energy from making huge numbers of drones
mech.fieldMeter -= 0.32; mech.fieldMeter -= 0.35;
b.drone(1) b.drone(1)
} }
if (mech.isHolding) { if (mech.isHolding) {

View File

@@ -22,6 +22,14 @@ const powerUps = {
game.isChoosing = false; //stops p from un pausing on key down game.isChoosing = false; //stops p from un pausing on key down
requestAnimationFrame(cycle); requestAnimationFrame(cycle);
}, },
cancel() {
document.body.style.cursor = "none";
document.getElementById("choose-grid").style.display = "none"
document.getElementById("choose-background").style.display = "none"
game.paused = false;
game.isChoosing = false; //stops p from un pausing on key down
requestAnimationFrame(cycle);
},
showDraft() { showDraft() {
document.getElementById("choose-grid").style.display = "grid" document.getElementById("choose-grid").style.display = "grid"
document.getElementById("choose-background").style.display = "inline" document.getElementById("choose-background").style.display = "inline"
@@ -36,11 +44,10 @@ const powerUps = {
return 40 * Math.sqrt(0.1 + Math.random() * 0.5); return 40 * Math.sqrt(0.1 + Math.random() * 0.5);
}, },
effect() { effect() {
let heal = ((this.size / 40) ** 2) let heal = 0
heal = Math.min(mech.maxHealth - mech.health, heal) for (let i = 0; i < b.modRecursiveHealing; i++) heal += ((this.size / 40) ** 2)
if (b.isModRecursiveHealing) heal *= 2 if (heal > 0) game.makeTextLog("<div class='circle heal'></div> &nbsp; <span style='font-size:115%;'> <strong style = 'letter-spacing: 2px;'>heal</strong> " + (Math.min(mech.maxHealth - mech.health, heal) * game.healScale * 100).toFixed(0) + "%</span>", 300)
mech.addHealth(heal); mech.addHealth(heal);
if (heal > 0) game.makeTextLog("<div class='circle heal'></div> &nbsp; <span style='font-size:115%;'> <strong style = 'letter-spacing: 2px;'>heal</strong> " + (heal * game.healScale * 100).toFixed(0) + "%</span>", 300)
} }
}, },
ammo: { ammo: {
@@ -72,8 +79,7 @@ const powerUps = {
mech.fieldMeter = mech.fieldEnergyMax; mech.fieldMeter = mech.fieldEnergyMax;
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300); if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300);
} else { } else {
//ammo given scales as mobs take more hits to kill let ammo = Math.ceil((target.ammoPack * (1 + 0.05 * Math.random())));
let ammo = Math.ceil((target.ammoPack * (0.4 + 0.05 * Math.random())));
if (level.isBuildRun) ammo = Math.floor(ammo * 1.1) //extra ammo on build run because no ammo from getting a new gun if (level.isBuildRun) ammo = Math.floor(ammo * 1.1) //extra ammo on build run because no ammo from getting a new gun
target.ammo += ammo; target.ammo += ammo;
game.updateGunHUD(); game.updateGunHUD();
@@ -100,7 +106,7 @@ const powerUps = {
let choice2 = doNotHave(mech.fieldUpgrades, choice1) let choice2 = doNotHave(mech.fieldUpgrades, choice1)
let choice3 = -1 let choice3 = -1
if (choice1 > -1) { if (choice1 > -1) {
let text = `<h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a field</h3>` let text = `<div class='cancel' onclick='powerUps.cancel()'>✕</div><h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a field</h3>`
text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice1})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice1].name}</div> ${mech.fieldUpgrades[choice1].description}</div>` text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice1})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice1].name}</div> ${mech.fieldUpgrades[choice1].description}</div>`
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice2})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice2].name}</div> ${mech.fieldUpgrades[choice2].description}</div>` if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice2})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice2].name}</div> ${mech.fieldUpgrades[choice2].description}</div>`
if (!b.isModBayesian) { if (!b.isModBayesian) {
@@ -138,7 +144,7 @@ const powerUps = {
let choice2 = doNotHave(b.mods, choice1) let choice2 = doNotHave(b.mods, choice1)
let choice3 = -1 let choice3 = -1
if (choice1 > -1) { if (choice1 > -1) {
let text = "<h3 style = 'color:#fff; text-align:center; margin: 0px;'>choose a mod</h3>" let text = "<div class='cancel' onclick='powerUps.cancel()'>✕</div><h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a mod</h3>"
text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice1})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[choice1].name}</div> ${b.mods[choice1].description}</div>` text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice1})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[choice1].name}</div> ${b.mods[choice1].description}</div>`
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice2})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[choice2].name}</div> ${b.mods[choice2].description}</div>` if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice2})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[choice2].name}</div> ${b.mods[choice2].description}</div>`
if (!b.isModBayesian) { if (!b.isModBayesian) {
@@ -175,7 +181,7 @@ const powerUps = {
let choice2 = doNotHave(b.guns, choice1) let choice2 = doNotHave(b.guns, choice1)
let choice3 = -1 let choice3 = -1
if (choice1 > -1) { if (choice1 > -1) {
let text = "<h3 style = 'color:#fff; text-align:center; margin: 0px;'>choose a gun</h3>" let text = "<div class='cancel' onclick='powerUps.cancel()'>✕</div><h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a gun</h3>"
text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice1})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice1].name}</div> ${b.guns[choice1].description}</div>` text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice1})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice1].name}</div> ${b.guns[choice1].description}</div>`
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice2})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice2].name}</div> ${b.guns[choice2].description}</div>` if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice2})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice2].name}</div> ${b.guns[choice2].description}</div>`
if (!b.isModBayesian) { if (!b.isModBayesian) {
@@ -195,7 +201,7 @@ const powerUps = {
}, },
giveRandomAmmo() { giveRandomAmmo() {
const ammoTarget = Math.floor(Math.random() * (b.guns.length)); const ammoTarget = Math.floor(Math.random() * (b.guns.length));
const ammo = Math.ceil(b.guns[ammoTarget].ammoPack * 2); const ammo = Math.ceil(b.guns[ammoTarget].ammoPack * 6);
b.guns[ammoTarget].ammo += ammo; b.guns[ammoTarget].ammo += ammo;
game.updateGunHUD(); game.updateGunHUD();
game.makeTextLog("<span style='font-size:110%;'>+" + ammo + " ammo for " + b.guns[ammoTarget].name + "</span>", 300); game.makeTextLog("<span style='font-size:110%;'>+" + ammo + " ammo for " + b.guns[ammoTarget].name + "</span>", 300);
@@ -206,17 +212,17 @@ const powerUps = {
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "heal"); if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "heal");
return; return;
} }
if (Math.random() < 0.2 && b.inventory.length > 0) { if (Math.random() < 0.15 && b.inventory.length > 0) {
powerUps.spawn(x, y, "ammo"); powerUps.spawn(x, y, "ammo");
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "ammo"); if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "ammo");
return; return;
} }
if (Math.random() < 0.004 * (4 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun up to 4 if (Math.random() < 0.0035 * (3 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun up to 4
powerUps.spawn(x, y, "gun"); powerUps.spawn(x, y, "gun");
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "gun"); if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "gun");
return; return;
} }
if (Math.random() < 0.0035 * (9 - b.modCount)) { //a new mod has a low chance for each not acquired mod up to 7 if (Math.random() < 0.0031 * (10 - b.modCount)) { //a new mod has a low chance for each not acquired mod up to 7
powerUps.spawn(x, y, "mod"); powerUps.spawn(x, y, "mod");
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod"); if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod");
return; return;
@@ -231,28 +237,28 @@ const powerUps = {
if (mech.fieldMode === 0) { if (mech.fieldMode === 0) {
powerUps.spawn(x, y, "field") powerUps.spawn(x, y, "field")
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field") if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field")
} else if (Math.random() < 0.55) { } else if (Math.random() < 0.6) {
powerUps.spawn(x, y, "mod") powerUps.spawn(x, y, "mod")
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod") if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod")
} else if (Math.random() < 0.2) { } else if (Math.random() < 0.1) {
powerUps.spawn(x, y, "gun") powerUps.spawn(x, y, "gun")
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "gun") if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "gun")
} else if (Math.random() < 0.1) { } else if (Math.random() < 0.1) {
powerUps.spawn(x, y, "field"); powerUps.spawn(x, y, "field");
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field"); if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field");
} else if (mech.health < 0.65) { } else if (mech.health < 0.65) {
powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
if (Math.random() < b.isModBayesian) { if (Math.random() < b.isModBayesian) {
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal");
} }
} else { } else {
powerUps.spawn(x, y, "ammo");
powerUps.spawn(x, y, "ammo"); powerUps.spawn(x, y, "ammo");
powerUps.spawn(x, y, "ammo"); powerUps.spawn(x, y, "ammo");
if (Math.random() < b.isModBayesian) { if (Math.random() < b.isModBayesian) {
powerUps.spawn(x, y, "ammo"); powerUps.spawn(x, y, "ammo");
powerUps.spawn(x, y, "ammo");
} }
} }
}, },

View File

@@ -233,7 +233,7 @@ const spawn = {
me.accelMag = 0.001 * game.accelScale;; me.accelMag = 0.001 * game.accelScale;;
me.g = me.accelMag * 0.6; //required if using 'gravity' me.g = me.accelMag * 0.6; //required if using 'gravity'
me.memory = 50; me.memory = 50;
if (Math.random() < Math.min((game.difficulty - 1) * 0.07, 0.5)) spawn.shield(me, x, y); if (Math.random() < Math.min((game.difficulty - 1) * 0.05, 0.3)) spawn.shield(me, x, y);
me.do = function () { me.do = function () {
this.gravity(); this.gravity();
this.seePlayerCheck(); this.seePlayerCheck();
@@ -293,7 +293,7 @@ const spawn = {
me.onDeath = function () { me.onDeath = function () {
this.removeCons(); this.removeCons();
}; };
if (Math.random() < Math.min((game.difficulty - 1) * 0.07, 0.5)) spawn.shield(me, x, y); if (Math.random() < Math.min((game.difficulty - 1) * 0.05, 0.3)) spawn.shield(me, x, y);
me.do = function () { me.do = function () {
this.gravity(); this.gravity();
this.searchSpring(); this.searchSpring();
@@ -600,7 +600,7 @@ const spawn = {
me.accelMag = 0.0005 * game.accelScale; me.accelMag = 0.0005 * game.accelScale;
me.frictionStatic = 0; me.frictionStatic = 0;
me.friction = 0; me.friction = 0;
if (Math.random() < Math.min(0.2 + (game.difficulty - 1) * 0.07, 0.5)) spawn.shield(me, x, y); if (Math.random() < Math.min(0.2 + (game.difficulty - 1) * 0.05, 0.3)) spawn.shield(me, x, y);
me.do = function () { me.do = function () {
this.seePlayerByLookingAt(); this.seePlayerByLookingAt();
this.attraction(); this.attraction();
@@ -900,7 +900,7 @@ const spawn = {
x: 0, x: 0,
y: 0 y: 0
}; };
if (Math.random() < Math.min(0.15 + (game.difficulty - 1) * 0.07, 0.5)) spawn.shield(me, x, y); if (Math.random() < Math.min(0.15 + (game.difficulty - 1) * 0.05, 0.3)) spawn.shield(me, x, y);
me.do = function () { me.do = function () {
this.seePlayerByLookingAt(); this.seePlayerByLookingAt();
this.fire(); this.fire();
@@ -970,7 +970,7 @@ const spawn = {
}); });
} }
}; };
if (Math.random() < Math.min((game.difficulty - 1) * 0.05, 0.4)) spawn.shield(me, x, y); if (Math.random() < Math.min((game.difficulty - 1) * 0.04, 0.2)) spawn.shield(me, x, y);
me.do = function () { me.do = function () {
this.gravity(); this.gravity();
this.seePlayerCheck(); this.seePlayerCheck();
@@ -1019,7 +1019,7 @@ const spawn = {
me.laserRange = 500; me.laserRange = 500;
Matter.Body.setDensity(me, 0.001 + 0.0005 * Math.sqrt(game.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger Matter.Body.setDensity(me, 0.001 + 0.0005 * Math.sqrt(game.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger
spawn.shield(me, x, y); spawn.shield(me, x, y);
if (Math.random() < Math.min((game.difficulty - 1) * 0.07, 0.5)) spawn.shield(me, x, y); if (Math.random() < Math.min((game.difficulty - 1) * 0.05, 0.3)) spawn.shield(me, x, y);
me.onDeath = function () { me.onDeath = function () {
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)
}; };
@@ -1060,7 +1060,7 @@ const spawn = {
me.memory = 20; me.memory = 20;
Matter.Body.setDensity(me, 0.001 + 0.0005 * Math.sqrt(game.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger Matter.Body.setDensity(me, 0.001 + 0.0005 * Math.sqrt(game.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger
spawn.shield(me, x, y); spawn.shield(me, x, y);
if (Math.random() < Math.min((game.difficulty - 1) * 0.07, 0.5)) spawn.shield(me, x, y); if (Math.random() < Math.min((game.difficulty - 1) * 0.05, 0.3)) spawn.shield(me, x, y);
me.onDeath = function () { me.onDeath = function () {
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)

View File

@@ -100,6 +100,18 @@ summary {
background-color: #efeff5; background-color: #efeff5;
} }
.cancel {
/* text-align: right; */
position: absolute;
top: 15px;
right: 15px;
color: #fff;
}
.cancel:hover {
color: #aaa;
}
#build-grid { #build-grid {
padding: 16px; padding: 16px;
margin: 0px; margin: 0px;