custom run difficulty scaling
This commit is contained in:
@@ -72,20 +72,20 @@ const b = {
|
|||||||
},
|
},
|
||||||
mods: [{
|
mods: [{
|
||||||
name: "depleted uranium rounds", //0
|
name: "depleted uranium rounds", //0
|
||||||
description: `your <strong>bullets</strong> are +11% larger<br>increased mass and physical <strong class='color-d'>damage</strong>`,
|
description: `your <strong>bullets</strong> are +13% larger<br>increased mass and physical <strong class='color-d'>damage</strong>`,
|
||||||
count: 0,
|
count: 0,
|
||||||
maxCount: 4,
|
maxCount: 33,
|
||||||
effect() {
|
effect() {
|
||||||
b.modBulletSize += 0.11
|
b.modBulletSize += 0.13
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "fluoroantimonic acid", //1
|
name: "fluoroantimonic acid", //1
|
||||||
description: "each <strong>bullet</strong> does extra chemical <strong class='color-d'>damage</strong><br>instant damage, unaffected by momentum",
|
description: "each <strong>bullet</strong> does extra chemical <strong class='color-d'>damage</strong><br>instant damage, unaffected by momentum",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.modExtraDmg += 0.25
|
b.modExtraDmg += 0.3
|
||||||
game.playerDmgColor = "rgba(0,80,80,0.9)"
|
game.playerDmgColor = "rgba(0,80,80,0.9)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -105,22 +105,6 @@ const b = {
|
|||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.isModFarAwayDmg = true; //used in mob.damage()
|
b.isModFarAwayDmg = true; //used in mob.damage()
|
||||||
// game.drawList.push({ //draw range
|
|
||||||
// //add dmg to draw queue
|
|
||||||
// x: player.position.x,
|
|
||||||
// y: player.position.y,
|
|
||||||
// radius: 3000,
|
|
||||||
// color: "rgba(255,0,0,0.05)",
|
|
||||||
// time: 120
|
|
||||||
// });
|
|
||||||
// game.drawList.push({ //draw range
|
|
||||||
// //add dmg to draw queue
|
|
||||||
// x: player.position.x,
|
|
||||||
// y: player.position.y,
|
|
||||||
// radius: 500,
|
|
||||||
// color: "rgba(0,0,0,0.2)",
|
|
||||||
// time: 120
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -135,7 +119,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "high explosives", //15
|
name: "high explosives", //15
|
||||||
description: "the radius of <strong class='color-e'>explosions</strong> are +20% <strong>larger</strong><br>immune to <strong>harm</strong> from <strong class='color-e'>explosions</strong>",
|
description: "the radius of <strong class='color-e'>explosions</strong> are +20% <strong>larger</strong><br>immune to <strong>harm</strong> from <strong class='color-e'>explosions</strong>",
|
||||||
maxCount: 4,
|
maxCount: 1,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect: () => {
|
effect: () => {
|
||||||
b.modExplosionRadius += 0.2;
|
b.modExplosionRadius += 0.2;
|
||||||
@@ -145,7 +129,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "auto-loading heuristics", //5
|
name: "auto-loading heuristics", //5
|
||||||
description: "your <strong>delay</strong> after firing is +12% <strong>shorter</strong>",
|
description: "your <strong>delay</strong> after firing is +12% <strong>shorter</strong>",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.modFireRate *= 0.88
|
b.modFireRate *= 0.88
|
||||||
@@ -163,7 +147,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "Lorentzian topology", //7
|
name: "Lorentzian topology", //7
|
||||||
description: "your <strong>bullets</strong> last +33% <strong>longer</strong>",
|
description: "your <strong>bullets</strong> last +33% <strong>longer</strong>",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.isModBulletsLastLonger += 0.33
|
b.isModBulletsLastLonger += 0.33
|
||||||
@@ -172,7 +156,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "zoospore vector", //8
|
name: "zoospore vector", //8
|
||||||
description: "enemies discharge <strong style='letter-spacing: 2px;'>spores</strong> on <strong>death</strong><br>+11% chance",
|
description: "enemies discharge <strong style='letter-spacing: 2px;'>spores</strong> on <strong>death</strong><br>+11% chance",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.modSpores += 0.11;
|
b.modSpores += 0.11;
|
||||||
@@ -184,7 +168,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "laser-bot", //10
|
name: "laser-bot", //10
|
||||||
description: "a bot <strong>defends</strong> the space around you<br>uses a <strong>short range</strong> laser that drains <strong class='color-f'>energy</strong>",
|
description: "a bot <strong>defends</strong> the space around you<br>uses a <strong>short range</strong> laser that drains <strong class='color-f'>energy</strong>",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.modLaserBotCount++;
|
b.modLaserBotCount++;
|
||||||
@@ -194,7 +178,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "nail-bot", //11
|
name: "nail-bot", //11
|
||||||
description: "a bot fires <strong>nails</strong> at targets in line of sight",
|
description: "a bot fires <strong>nails</strong> at targets in line of sight",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.modNailBotCount++;
|
b.modNailBotCount++;
|
||||||
@@ -216,7 +200,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "bremsstrahlung radiation", //13
|
name: "bremsstrahlung radiation", //13
|
||||||
description: "when your <strong>field blocks</strong> it also does <strong class='color-d'>damage</strong>",
|
description: "when your <strong>field blocks</strong> it also does <strong class='color-d'>damage</strong>",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.modBlockDmg += 0.7 //if you change this value also update the for loop in the electricity graphics in mech.pushMass
|
b.modBlockDmg += 0.7 //if you change this value also update the for loop in the electricity graphics in mech.pushMass
|
||||||
@@ -244,11 +228,11 @@ const b = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Pauli exclusion", //12
|
name: "Pauli exclusion", //12
|
||||||
description: "unable to <strong>collide</strong> with enemies for +2 seconds<br>activates after being <strong>harmed</strong> from a collision",
|
description: "unable to <strong>collide</strong> with enemies for +1 second<br>activates after being <strong>harmed</strong> from a collision",
|
||||||
maxCount: 1,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.modCollisionImmuneCycles += 120;
|
b.modCollisionImmuneCycles += 60;
|
||||||
mech.collisionImmune = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles
|
mech.collisionImmune = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -274,7 +258,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "energy conservation", //18
|
name: "energy conservation", //18
|
||||||
description: "gain <strong class='color-f'>energy</strong> proportional to <strong class='color-d'>damage</strong> done",
|
description: "gain <strong class='color-f'>energy</strong> proportional to <strong class='color-d'>damage</strong> done",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.modEnergySiphon += 0.15;
|
b.modEnergySiphon += 0.15;
|
||||||
@@ -284,7 +268,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "entropy exchange", //19
|
name: "entropy exchange", //19
|
||||||
description: "<strong class='color-h'>heal</strong> proportional to <strong class='color-d'>damage</strong> done",
|
description: "<strong class='color-h'>heal</strong> proportional to <strong class='color-d'>damage</strong> done",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.modHealthDrain += 0.015;
|
b.modHealthDrain += 0.015;
|
||||||
@@ -293,7 +277,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "overcharge", //20
|
name: "overcharge", //20
|
||||||
description: "charge <strong class='color-f'>energy</strong> <strong>+33%</strong> beyond your <strong>maximum</strong>",
|
description: "charge <strong class='color-f'>energy</strong> <strong>+33%</strong> beyond your <strong>maximum</strong>",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
mech.fieldEnergyMax += 0.33
|
mech.fieldEnergyMax += 0.33
|
||||||
@@ -303,7 +287,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "supersaturation", //21
|
name: "supersaturation", //21
|
||||||
description: "<strong class='color-h'>heal</strong> <strong>+33%</strong> beyond your <strong>max health</strong>",
|
description: "<strong class='color-h'>heal</strong> <strong>+33%</strong> beyond your <strong>max health</strong>",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
mech.maxHealth += 0.33
|
mech.maxHealth += 0.33
|
||||||
@@ -313,7 +297,7 @@ const b = {
|
|||||||
{
|
{
|
||||||
name: "recursive healing", //22
|
name: "recursive healing", //22
|
||||||
description: "<strong class='color-h'>healing</strong> power ups trigger an extra time.",
|
description: "<strong class='color-h'>healing</strong> power ups trigger an extra time.",
|
||||||
maxCount: 4,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect() {
|
effect() {
|
||||||
b.modRecursiveHealing += 1
|
b.modRecursiveHealing += 1
|
||||||
@@ -321,7 +305,7 @@ const b = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mass-energy equivalence", //23
|
name: "mass-energy equivalence", //23
|
||||||
description: "convert the mass of <strong>power ups</strong> into <strong class='color-f'>energy</strong><br>power ups fill your <strong class='color-f'>energy</strong> and <strong class='color-h'>heal</strong> for +5%",
|
description: "power ups fill your <strong class='color-f'>energy</strong> and <strong class='color-h'>heal</strong> for +5%",
|
||||||
maxCount: 1,
|
maxCount: 1,
|
||||||
count: 0,
|
count: 0,
|
||||||
effect: () => {
|
effect: () => {
|
||||||
@@ -338,15 +322,6 @@ const b = {
|
|||||||
b.isModImmortal = true;
|
b.isModImmortal = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "+1 cardinality", //24
|
|
||||||
description: "one extra <strong>choice</strong> when selecting <strong>power ups</strong>",
|
|
||||||
maxCount: 1,
|
|
||||||
count: 0,
|
|
||||||
effect: () => {
|
|
||||||
b.isModFourOptions = true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "Bayesian inference", //25
|
name: "Bayesian inference", //25
|
||||||
description: "<strong>20%</strong> chance for double <strong>power ups</strong> to drop<br>one fewer <strong>choice</strong> when selecting <strong>power ups</strong>",
|
description: "<strong>20%</strong> chance for double <strong>power ups</strong> to drop<br>one fewer <strong>choice</strong> when selecting <strong>power ups</strong>",
|
||||||
@@ -356,6 +331,15 @@ const b = {
|
|||||||
b.isModBayesian = 0.20;
|
b.isModBayesian = 0.20;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "+1 cardinality", //24
|
||||||
|
description: "one extra <strong>choice</strong> when selecting <strong>power ups</strong>",
|
||||||
|
maxCount: 1,
|
||||||
|
count: 0,
|
||||||
|
effect: () => {
|
||||||
|
b.isModFourOptions = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Born rule", //26
|
name: "Born rule", //26
|
||||||
description: "<strong>remove</strong> all current <strong class='color-m'>mods</strong><br>spawn new <strong class='color-m'>mods</strong> to replace them",
|
description: "<strong>remove</strong> all current <strong class='color-m'>mods</strong><br>spawn new <strong class='color-m'>mods</strong> to replace them",
|
||||||
@@ -1059,7 +1043,7 @@ const b = {
|
|||||||
Matter.Query.ray(body, this.position, mob[i].position).length === 0) {
|
Matter.Query.ray(body, this.position, mob[i].position).length === 0) {
|
||||||
target = Vector.add(mob[i].position, Vector.mult(mob[i].velocity, Math.sqrt(dist) / 60))
|
target = Vector.add(mob[i].position, Vector.mult(mob[i].velocity, Math.sqrt(dist) / 60))
|
||||||
const SPEED = 50
|
const SPEED = 50
|
||||||
b.nail(this.position, Vector.mult(Vector.normalise(Vector.sub(target, this.position)), SPEED), 0.3)
|
b.nail(this.position, Vector.mult(Vector.normalise(Vector.sub(target, this.position)), SPEED), 0.4)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1294,10 +1278,10 @@ const b = {
|
|||||||
have: false,
|
have: false,
|
||||||
isStarterGun: true,
|
isStarterGun: true,
|
||||||
fire() {
|
fire() {
|
||||||
mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 35 : 20) * b.modFireRate); // cool down
|
mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 30 : 20) * b.modFireRate); // cool down
|
||||||
b.muzzleFlash(20);
|
b.muzzleFlash(20);
|
||||||
// mobs.alert(450);
|
// mobs.alert(450);
|
||||||
const SPEED = mech.crouch ? 55 : 35
|
const SPEED = mech.crouch ? 45 : 35
|
||||||
const SPREAD = mech.crouch ? 0.04 : 0.15
|
const SPREAD = mech.crouch ? 0.04 : 0.15
|
||||||
let dir = mech.angle - SPREAD * 2;
|
let dir = mech.angle - SPREAD * 2;
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
@@ -1368,7 +1352,7 @@ const b = {
|
|||||||
fire() {
|
fire() {
|
||||||
const me = bullet.length;
|
const me = bullet.length;
|
||||||
const dir = mech.angle
|
const dir = mech.angle
|
||||||
const SCALE = (mech.crouch ? 0.963 : 0.95)
|
const SCALE = (mech.crouch ? 0.963 : 0.95) + 0.03 * Math.min(1, 0.5 * (b.isModBulletsLastLonger - 1))
|
||||||
const wiggleMag = ((mech.crouch) ? 0.004 : 0.005) * ((mech.flipLegs === 1) ? 1 : -1)
|
const wiggleMag = ((mech.crouch) ? 0.004 : 0.005) * ((mech.flipLegs === 1) ? 1 : -1)
|
||||||
bullet[me] = Bodies.polygon(mech.pos.x + 25 * Math.cos(dir), mech.pos.y + 25 * Math.sin(dir), 10, 10 * b.modBulletSize, {
|
bullet[me] = Bodies.polygon(mech.pos.x + 25 * Math.cos(dir), mech.pos.y + 25 * Math.sin(dir), 10, 10 * b.modBulletSize, {
|
||||||
angle: dir,
|
angle: dir,
|
||||||
@@ -1623,10 +1607,10 @@ const b = {
|
|||||||
fireCycle: 0,
|
fireCycle: 0,
|
||||||
ammoLoaded: 0,
|
ammoLoaded: 0,
|
||||||
fire() {
|
fire() {
|
||||||
const thrust = 0.0005;
|
|
||||||
let dir = mech.angle + (0.5 - Math.random()) * (mech.crouch ? 0 : 0.2);
|
let dir = mech.angle + (0.5 - Math.random()) * (mech.crouch ? 0 : 0.2);
|
||||||
const me = bullet.length;
|
const me = bullet.length;
|
||||||
bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(mech.angle), mech.pos.y + 40 * Math.sin(mech.angle) - 3, 30 * b.modBulletSize, 4 * b.modBulletSize, b.fireAttributes(dir));
|
bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(mech.angle), mech.pos.y + 40 * Math.sin(mech.angle) - 3, 30 * b.modBulletSize, 4 * b.modBulletSize, b.fireAttributes(dir));
|
||||||
|
const thrust = 0.00417 * bullet[me].mass;
|
||||||
b.fireProps(mech.crouch ? 55 : 30, -3 * (0.5 - Math.random()) + (mech.crouch ? 25 : -8), dir, me); //cd , speed
|
b.fireProps(mech.crouch ? 55 : 30, -3 * (0.5 - Math.random()) + (mech.crouch ? 25 : -8), dir, me); //cd , speed
|
||||||
// bullet[me].collisionFilter.mask = cat.map | cat.body | cat.mobBullet
|
// bullet[me].collisionFilter.mask = cat.map | cat.body | cat.mobBullet
|
||||||
// Matter.Body.setDensity(bullet[me], 0.01) //doesn't help with reducing explosion knock backs
|
// Matter.Body.setDensity(bullet[me], 0.01) //doesn't help with reducing explosion knock backs
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ function collisionChecks(event) {
|
|||||||
function collidePlayer(obj, speedThreshold = 12, massThreshold = 2) {
|
function collidePlayer(obj, speedThreshold = 12, massThreshold = 2) {
|
||||||
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.collisionImmune < mech.cycle) {
|
||||||
|
mech.collisionImmune = mech.cycle + b.modCollisionImmuneCycles; //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);
|
||||||
@@ -131,8 +132,7 @@ function collisionChecks(event) {
|
|||||||
|
|
||||||
function collideMob(obj) {
|
function collideMob(obj) {
|
||||||
//player + mob collision
|
//player + mob collision
|
||||||
if (mech.collisionImmune < mech.cycle) {
|
if (mech.collisionImmune < mech.cycle && (obj === playerBody || obj === playerHead)) {
|
||||||
if (obj === playerBody || obj === playerHead) {
|
|
||||||
mech.collisionImmune = mech.cycle + b.modCollisionImmuneCycles; //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
|
||||||
@@ -172,7 +172,6 @@ function collisionChecks(event) {
|
|||||||
});
|
});
|
||||||
return;
|
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)));
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ const game = {
|
|||||||
if (game.difficultyMode === 0) {
|
if (game.difficultyMode === 0) {
|
||||||
game.isEasyMode = true;
|
game.isEasyMode = true;
|
||||||
game.difficultyMode = 1
|
game.difficultyMode = 1
|
||||||
level.difficultyDecrease(6);
|
level.difficultyDecrease(6); //if this stops being -6 change in build.calculateCustomDifficulty()
|
||||||
}
|
}
|
||||||
|
|
||||||
game.clearNow = true;
|
game.clearNow = true;
|
||||||
|
|||||||
159
js/index.js
159
js/index.js
@@ -117,34 +117,6 @@ game mechanics
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// local storage
|
|
||||||
let localSettings = JSON.parse(localStorage.getItem("localSettings"));
|
|
||||||
// console.log(localSettings)
|
|
||||||
if (localSettings) {
|
|
||||||
game.isBodyDamage = localSettings.isBodyDamage
|
|
||||||
document.getElementById("body-damage").checked = localSettings.isBodyDamage
|
|
||||||
|
|
||||||
game.difficultyMode = localSettings.difficultyMode
|
|
||||||
document.getElementById("difficulty-select").value = localSettings.difficultyMode
|
|
||||||
|
|
||||||
if (localSettings.fpsCapDefault === 'max') {
|
|
||||||
game.fpsCapDefault = 999999999;
|
|
||||||
} else {
|
|
||||||
game.fpsCapDefault = Number(localSettings.fpsCapDefault)
|
|
||||||
}
|
|
||||||
document.getElementById("fps-select").value = localSettings.fpsCapDefault
|
|
||||||
} else {
|
|
||||||
localSettings = {
|
|
||||||
isBodyDamage: true,
|
|
||||||
difficultyMode: '1',
|
|
||||||
fpsCapDefault: '72',
|
|
||||||
};
|
|
||||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
|
||||||
document.getElementById("body-damage").checked = localSettings.isBodyDamage
|
|
||||||
document.getElementById("difficulty-select").value = localSettings.difficultyMode
|
|
||||||
document.getElementById("fps-select").value = localSettings.fpsCapDefault
|
|
||||||
}
|
|
||||||
|
|
||||||
//collision groups
|
//collision groups
|
||||||
// cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet | cat.mobShield
|
// cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet | cat.mobShield
|
||||||
const cat = {
|
const cat = {
|
||||||
@@ -222,19 +194,77 @@ const build = {
|
|||||||
who.innerHTML = `<div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[index].name}</div> ${b.mods[index].description}`
|
who.innerHTML = `<div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[index].name}</div> ${b.mods[index].description}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.title = `effective starting level: ${build.list.length * game.difficultyMode}`
|
// document.title = `effective starting level: ${build.list.length * game.difficultyMode}`
|
||||||
// document.getElementById("starting-level").innerHTML = `effective starting level: ${build.list.length * game.difficultyMode}`
|
build.calculateCustomDifficulty()
|
||||||
},
|
},
|
||||||
removeMod(index) {
|
makeGrid() {
|
||||||
for (let i = build.list.length - 1; i > -1; i--) {
|
let text =
|
||||||
if (build.list[i].type === "mod" && build.list[i].index === index) build.list.splice(i, 1);
|
`<div style="display: flex; justify-content: space-around; align-items: center;">
|
||||||
|
<svg class="SVG-button" onclick="build.startBuildRun()" width="105" height="55">
|
||||||
|
<g stroke='none' fill='#333' stroke-width="2" font-size="40px" font-family="Ariel, sans-serif">
|
||||||
|
<text x="13" y="40">start</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
<svg class="SVG-button" onclick="build.reset()" width="70" height="35">
|
||||||
|
<g stroke='none' fill='#333' stroke-width="2" font-size="22px" font-family="Ariel, sans-serif">
|
||||||
|
<text x="10" y="24">reset</text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="build-grid-module" style="text-align:center; font-size: 1.00em; line-height: 175%;background-color:#c4ccd8;">
|
||||||
|
<div id="starting-level"></div>
|
||||||
|
<label for="difficulty-select" title="effects: number of mobs, damage done by mobs, damage done to mobs, mob speed, heal effects">difficulty:</label>
|
||||||
|
<select name="difficulty-select" id="difficulty-select-custom">
|
||||||
|
<option value="0">easy</option>
|
||||||
|
<option value="1" selected>normal</option>
|
||||||
|
<option value="2">hard</option>
|
||||||
|
<option value="6">why...</option>
|
||||||
|
</select>
|
||||||
|
</div>`
|
||||||
|
for (let i = 1, len = mech.fieldUpgrades.length; i < len; i++) {
|
||||||
|
text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'field')"><div class="grid-title"><div class="circle-grid field"></div> ${mech.fieldUpgrades[i].name}</div> ${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(this,${i},'gun')"><div class="grid-title"><div class="circle-grid gun"></div> ${b.guns[i].name}</div> ${b.guns[i].description}</div>`
|
||||||
|
}
|
||||||
|
for (let i = 0, len = b.mods.length; i < len; i++) {
|
||||||
|
if (b.mods[i].name === "Born rule" || b.mods[i].name === "+1 cardinality") {
|
||||||
|
text += `<div class="build-grid-module" style="opacity:0.3;"><div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[i].name}</div> ${b.mods[i].description}</div>`
|
||||||
|
} else {
|
||||||
|
text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'mod')"><div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[i].name}</div> ${b.mods[i].description}</div>`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const el = document.getElementById("build-grid")
|
||||||
|
el.innerHTML = text
|
||||||
|
el.style.display = "none"
|
||||||
|
|
||||||
|
document.getElementById("difficulty-select-custom").addEventListener("input", () => {
|
||||||
|
document.getElementById("difficulty-select").value = document.getElementById("difficulty-select-custom").value
|
||||||
|
game.difficultyMode = Number(document.getElementById("difficulty-select-custom").value)
|
||||||
|
localSettings.difficultyMode = game.difficultyMode
|
||||||
|
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
|
build.calculateCustomDifficulty()
|
||||||
|
});
|
||||||
|
},
|
||||||
|
reset() {
|
||||||
|
build.list = []
|
||||||
|
build.makeGrid();
|
||||||
|
document.getElementById("build-grid").style.display = "grid"
|
||||||
|
build.calculateCustomDifficulty()
|
||||||
|
document.getElementById("difficulty-select-custom").value = localSettings.difficultyMode
|
||||||
|
},
|
||||||
|
calculateCustomDifficulty() {
|
||||||
|
let difficulty = build.list.length * game.difficultyMode
|
||||||
|
if (game.difficultyMode === 0) difficulty = build.list.length * 1 - 6
|
||||||
|
document.getElementById("starting-level").innerHTML = `starting level: <strong style="font-size:1.1em;">${difficulty}</strong>`
|
||||||
},
|
},
|
||||||
startBuildRun() {
|
startBuildRun() {
|
||||||
spawn.setSpawnList();
|
spawn.setSpawnList();
|
||||||
spawn.setSpawnList(); //gives random mobs, not starter
|
spawn.setSpawnList(); //gives random mobs, not starter
|
||||||
game.startGame();
|
game.startGame();
|
||||||
level.difficultyIncrease(build.list.length * game.difficultyMode)
|
let difficulty = build.list.length * game.difficultyMode - 1
|
||||||
|
if (game.difficultyMode === 0) difficulty = build.list.length * 1 - 6 - 1
|
||||||
|
level.difficultyIncrease(difficulty)
|
||||||
|
|
||||||
level.isBuildRun = true;
|
level.isBuildRun = true;
|
||||||
for (let i = 0; i < build.list.length; i++) {
|
for (let i = 0; i < build.list.length; i++) {
|
||||||
@@ -249,6 +279,8 @@ const build = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
build.makeGrid();
|
||||||
|
|
||||||
document.getElementById("build-button").addEventListener("click", () => {
|
document.getElementById("build-button").addEventListener("click", () => {
|
||||||
document.getElementById("build-button").style.display = "none";
|
document.getElementById("build-button").style.display = "none";
|
||||||
const el = document.getElementById("build-grid")
|
const el = document.getElementById("build-grid")
|
||||||
@@ -260,40 +292,45 @@ document.getElementById("build-button").addEventListener("click", () => {
|
|||||||
} else {
|
} else {
|
||||||
build.list = []
|
build.list = []
|
||||||
// let text = '<p>The difficulty increases by one level for each power up you choose.<br> <button type="button" id="build-begin-button" onclick="build.startBuildRun()">Begin Run</button></p>'
|
// let text = '<p>The difficulty increases by one level for each power up you choose.<br> <button type="button" id="build-begin-button" onclick="build.startBuildRun()">Begin Run</button></p>'
|
||||||
let text =
|
|
||||||
`<div style="display: flex; justify-content: center; align-items: center;">
|
|
||||||
<svg class="SVG-button" onclick="build.startBuildRun()" width="90" height="45">
|
|
||||||
<g stroke='none' fill='#333' stroke-width="2" font-size="30px" font-family="Ariel, sans-serif">
|
|
||||||
<text x="15" y="32">start</text>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div id ="starting-level" class="build-grid-module" style="font-size: 1.00em; line-height: 175%;">
|
|
||||||
each power up you select will increase the starting level by one
|
|
||||||
</div>`
|
|
||||||
for (let i = 1, len = mech.fieldUpgrades.length; i < len; i++) {
|
|
||||||
text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'field')"><div class="grid-title"><div class="circle-grid field"></div> ${mech.fieldUpgrades[i].name}</div> ${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(this,${i},'gun')"><div class="grid-title"><div class="circle-grid gun"></div> ${b.guns[i].name}</div> ${b.guns[i].description}</div>`
|
|
||||||
}
|
|
||||||
for (let i = 0, len = b.mods.length; i < len; i++) {
|
|
||||||
if (b.mods[i].name === "Born rule" || b.mods[i].name === "Bayesian inference" || b.mods[i].name === "+1 cardinality") {
|
|
||||||
text += `<div class="build-grid-module" style="opacity:0.3;"><div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[i].name}</div> ${b.mods[i].description}</div>`
|
|
||||||
} else {
|
|
||||||
text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'mod')"><div class="grid-title"><div class="circle-grid mod"></div> ${b.mods[i].name}</div> ${b.mods[i].description}</div>`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
el.innerHTML = text
|
|
||||||
el.style.display = "grid"
|
|
||||||
build.isShowingBuilds = true
|
build.isShowingBuilds = true
|
||||||
|
el.style.display = "grid"
|
||||||
document.body.style.overflowY = "scroll";
|
document.body.style.overflowY = "scroll";
|
||||||
document.body.style.overflowX = "hidden";
|
document.body.style.overflowX = "hidden";
|
||||||
document.getElementById("info").style.display = 'none'
|
document.getElementById("info").style.display = 'none'
|
||||||
}
|
}
|
||||||
|
build.calculateCustomDifficulty()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// local storage
|
||||||
|
let localSettings = JSON.parse(localStorage.getItem("localSettings"));
|
||||||
|
// console.log(localSettings)
|
||||||
|
if (localSettings) {
|
||||||
|
game.isBodyDamage = localSettings.isBodyDamage
|
||||||
|
document.getElementById("body-damage").checked = localSettings.isBodyDamage
|
||||||
|
|
||||||
|
game.difficultyMode = localSettings.difficultyMode
|
||||||
|
document.getElementById("difficulty-select").value = localSettings.difficultyMode
|
||||||
|
document.getElementById("difficulty-select-custom").value = localSettings.difficultyMode
|
||||||
|
|
||||||
|
if (localSettings.fpsCapDefault === 'max') {
|
||||||
|
game.fpsCapDefault = 999999999;
|
||||||
|
} else {
|
||||||
|
game.fpsCapDefault = Number(localSettings.fpsCapDefault)
|
||||||
|
}
|
||||||
|
document.getElementById("fps-select").value = localSettings.fpsCapDefault
|
||||||
|
} else {
|
||||||
|
localSettings = {
|
||||||
|
isBodyDamage: true,
|
||||||
|
difficultyMode: '1',
|
||||||
|
fpsCapDefault: '72',
|
||||||
|
};
|
||||||
|
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
|
document.getElementById("body-damage").checked = localSettings.isBodyDamage
|
||||||
|
document.getElementById("difficulty-select").value = localSettings.difficultyMode
|
||||||
|
document.getElementById("fps-select").value = localSettings.fpsCapDefault
|
||||||
|
}
|
||||||
|
|
||||||
//set up canvas
|
//set up canvas
|
||||||
var canvas = document.getElementById("canvas");
|
var canvas = document.getElementById("canvas");
|
||||||
//using "const" causes problems in safari when an ID shares the same name.
|
//using "const" causes problems in safari when an ID shares the same name.
|
||||||
@@ -385,7 +422,9 @@ document.getElementById("body-damage").addEventListener("input", () => {
|
|||||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// difficulty-select-custom event listener is set in build.makeGrid
|
||||||
document.getElementById("difficulty-select").addEventListener("input", () => {
|
document.getElementById("difficulty-select").addEventListener("input", () => {
|
||||||
|
document.getElementById("difficulty-select-custom").value = document.getElementById("difficulty-select").value
|
||||||
game.difficultyMode = Number(document.getElementById("difficulty-select").value)
|
game.difficultyMode = Number(document.getElementById("difficulty-select").value)
|
||||||
localSettings.difficultyMode = game.difficultyMode
|
localSettings.difficultyMode = game.difficultyMode
|
||||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
|
|||||||
@@ -1477,7 +1477,7 @@ const level = {
|
|||||||
level.onLevel++; //cycles map to next level
|
level.onLevel++; //cycles map to next level
|
||||||
if (level.onLevel > level.levels.length - 1) level.onLevel = 0;
|
if (level.onLevel > level.levels.length - 1) level.onLevel = 0;
|
||||||
|
|
||||||
level.difficultyIncrease(game.difficultyMode + level.isBuildRun) //increase difficulty based on modes
|
level.difficultyIncrease(game.difficultyMode) //increase difficulty based on modes
|
||||||
if (game.isEasyMode && level.levelsCleared % 2) level.difficultyDecrease(1);
|
if (game.isEasyMode && level.levelsCleared % 2) level.difficultyDecrease(1);
|
||||||
game.clearNow = true; //triggers in game.clearMap to remove all physics bodies and setup for new map
|
game.clearNow = true; //triggers in game.clearMap to remove all physics bodies and setup for new map
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -895,7 +895,7 @@ const mech = {
|
|||||||
pushMass(who) {
|
pushMass(who) {
|
||||||
const speed = Vector.magnitude(Vector.sub(who.velocity, player.velocity))
|
const speed = Vector.magnitude(Vector.sub(who.velocity, player.velocity))
|
||||||
const fieldBlockCost = 0.03 + Math.sqrt(who.mass) * speed * 0.003 //0.012
|
const fieldBlockCost = 0.03 + Math.sqrt(who.mass) * speed * 0.003 //0.012
|
||||||
if (mech.fieldMeter > fieldBlockCost * 0.6) { //shield needs at least some of the cost to block
|
if (mech.fieldMeter > fieldBlockCost * 0.2) { //shield needs at least some of the cost to block
|
||||||
mech.fieldMeter -= fieldBlockCost * mech.fieldShieldingScale;
|
mech.fieldMeter -= fieldBlockCost * mech.fieldShieldingScale;
|
||||||
if (mech.fieldMeter < 0) mech.fieldMeter = 0;
|
if (mech.fieldMeter < 0) mech.fieldMeter = 0;
|
||||||
mech.drawHold(who);
|
mech.drawHold(who);
|
||||||
|
|||||||
@@ -75,8 +75,9 @@ const powerUps = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//if you don't have any guns just add ammo to a random gun you don't have yet
|
// target = b.guns[Math.floor(Math.random() * b.guns.length)]; //if you don't have any guns just add ammo to a random gun you don't have yet
|
||||||
target = b.guns[Math.floor(Math.random() * b.guns.length)];
|
mech.fieldMeter = mech.fieldEnergyMax;
|
||||||
|
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300);
|
||||||
}
|
}
|
||||||
if (target.ammo === Infinity) {
|
if (target.ammo === Infinity) {
|
||||||
mech.fieldMeter = mech.fieldEnergyMax;
|
mech.fieldMeter = mech.fieldEnergyMax;
|
||||||
@@ -253,16 +254,12 @@ const powerUps = {
|
|||||||
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");
|
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");
|
|
||||||
}
|
|
||||||
} 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");
|
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
chooseRandomPowerUp(x, y) { //100% chance to drop a random power up //used in spawn.debris
|
chooseRandomPowerUp(x, y) { //100% chance to drop a random power up //used in spawn.debris
|
||||||
|
|||||||
Reference in New Issue
Block a user