foam wall collisions, Bayesian one choice

This commit is contained in:
landgreen
2020-04-25 13:04:39 -07:00
parent 42338ea49e
commit d24ea799cb
10 changed files with 136 additions and 90 deletions

View File

@@ -29,7 +29,7 @@ const b = {
isModFarAwayDmg: null,
isModEntanglement: null,
isModMassEnergy: null,
isModFourOptions: null,
isModExtraChoice: null,
modLaserBotCount: null,
modNailBotCount: null,
modCollisionImmuneCycles: null,
@@ -48,7 +48,7 @@ const b = {
isModEnergyRecovery: null,
isModHealthRecovery: null,
isModEnergyLoss: null,
isModFoamShieldHit: null,
isModFoamShieldSKip: null,
isModDeathAvoid: null,
isModDeathAvoidOnCD: null,
modWaveSpeedMap: null,
@@ -577,11 +577,13 @@ const b = {
b.modOnHealthChange();
mech.displayHealth();
document.getElementById("health-bg").style.display = "none"
document.getElementById("dmg").style.backgroundColor = "#0cf";
b.isModEnergyHealth = true;
},
remove() {
b.isModEnergyHealth = false;
document.getElementById("health-bg").style.display = "inline"
document.getElementById("dmg").style.backgroundColor = "#f67";
mech.health = mech.energy;
}
},
@@ -596,7 +598,7 @@ const b = {
requires: "not mass-energy equivalence",
effect() {
b.isModPiezo = true;
mech.energy = mech.fieldEnergyMax;
mech.energy = mech.maxEnergy;
},
remove() {
b.isModPiezo = false;
@@ -631,7 +633,7 @@ const b = {
requires: "",
effect() {
b.modEnergySiphon += 0.15;
mech.energy = mech.fieldEnergyMax
mech.energy = mech.maxEnergy
},
remove() {
b.modEnergySiphon = 0;
@@ -663,11 +665,11 @@ const b = {
},
requires: "",
effect() {
mech.fieldEnergyMax += 0.5
mech.maxEnergy += 0.5
mech.energy += 0.5
},
remove() {
mech.fieldEnergyMax = 1;
mech.maxEnergy = 1;
}
},
{
@@ -716,7 +718,7 @@ const b = {
requires: "",
effect: () => {
b.isModMassEnergy = true // used in mech.grabPowerUp
mech.energy = mech.fieldEnergyMax * 2
mech.energy = mech.maxEnergy * 2
},
remove() {
b.isModMassEnergy = false;
@@ -724,7 +726,7 @@ const b = {
},
{
name: "Bayesian inference",
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>33%</strong> chance for double <strong>power ups</strong> to drop<br>only <strong>one choice</strong> when selecting <strong>power ups</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -732,7 +734,7 @@ const b = {
},
requires: "",
effect: () => {
b.isModBayesian = 0.20;
b.isModBayesian = 0.33;
},
remove() {
b.isModBayesian = 0;
@@ -748,10 +750,10 @@ const b = {
},
requires: "",
effect: () => {
b.isModFourOptions = true;
b.isModExtraChoice = true;
},
remove() {
b.isModFourOptions = false;
b.isModExtraChoice = false;
}
},
{
@@ -1288,8 +1290,8 @@ const b = {
}
},
{
name: "quantum foam",
description: "<strong>foam</strong> can stick to <strong>shields</strong>",
name: "quantum tunneling",
description: "<strong>foam</strong> bypasses <strong>shields</strong> to stick to mobs",
maxCount: 1,
count: 0,
allowed() {
@@ -1297,10 +1299,10 @@ const b = {
},
requires: "foam",
effect() {
b.isModFoamShieldHit = true;
b.isModFoamShieldSKip = true;
},
remove() {
b.isModFoamShieldHit = false;
b.isModFoamShieldSKip = false;
}
},
{
@@ -1374,7 +1376,7 @@ const b = {
{
name: "timelike world line",
description: "<strong>time dilation</strong> increases your time <strong>rate</strong> by <strong>2x</strong><br>while <strong class='color-f'>energy</strong> <strong>drain</strong> is decreased by <strong>2x</strong>",
maxCount: 9,
maxCount: 1,
count: 0,
allowed() {
return mech.fieldUpgrades[mech.fieldMode].name === "time dilation field"
@@ -2092,7 +2094,7 @@ const b = {
}
}
}
for (let i = 0; i < 16; i++) {
for (let i = 0; i < 14; i++) {
const speed = 53 + 10 * Math.random()
if (targets.length > 0) { // aim near a random target in array
const index = Math.floor(Math.random() * targets.length)
@@ -3092,7 +3094,7 @@ const b = {
};
if (b.isModRPG) {
b.fireProps(25, mech.crouch ? 60 : -15, dir, me); //cd , speed
b.fireProps(35, mech.crouch ? 60 : -15, dir, me); //cd , speed
bullet[me].endCycle = game.cycle + 70;
bullet[me].frictionAir = 0.07;
const MAG = 0.015
@@ -3350,11 +3352,11 @@ const b = {
isStarterGun: true,
isEasyToAim: false,
fire() {
mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 12 : 5) * b.modFireRate); // cool down
mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 13 : 6) * b.modFireRate); // cool down
const me = bullet.length;
const dir = mech.angle + 0.2 * (Math.random() - 0.5)
const RADIUS = (8 + 16 * Math.random())
bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 25, RADIUS, {
bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 20, RADIUS, {
angle: dir,
density: 0.00005, // 0.001 is normal density
inertia: Infinity,
@@ -3365,7 +3367,7 @@ const b = {
classType: "bullet",
collisionFilter: {
category: cat.bullet,
mask: cat.map | cat.body | cat.mob | cat.mobShield
mask: cat.mob | cat.mobShield //cat.map | cat.body | cat.mob | cat.mobShield
},
minDmgSpeed: 0,
endCycle: Infinity,
@@ -3374,7 +3376,7 @@ const b = {
target: null,
targetVertex: null,
onDmg(who) {
if (!this.target && who.alive && (who.dropPowerUp || b.isModFoamShieldHit) && (!who.isShielded || b.isModFoamShieldHit)) {
if (!this.target && who.alive && who.dropPowerUp && (!who.isShielded || b.isModFoamShieldSKip)) {
this.target = who;
this.collisionFilter.category = cat.body;
this.collisionFilter.mask = null;
@@ -3399,7 +3401,23 @@ const b = {
// ctx.fill()
if (!mech.isBodiesAsleep) { //if time dilation isn't active
//check for touching map
if (Matter.Query.collides(this, map).length > 0) {
const slow = 0.94
Matter.Body.setVelocity(this, {
x: this.velocity.x * slow,
y: this.velocity.y * slow
});
} else if (Matter.Query.collides(this, body).length > 0) {
const slow = 0.97
Matter.Body.setVelocity(this, {
x: this.velocity.x * slow,
y: this.velocity.y * slow
});
} else {
this.force.y += this.mass * 0.00006; //gravity
}
if (this.count < 17) {
this.count++
@@ -3409,7 +3427,7 @@ const b = {
this.radius *= SCALE;
} else {
//shrink
const SCALE = 1 - 0.0035 / b.isModBulletsLastLonger
const SCALE = 1 - 0.0033 / b.isModBulletsLastLonger
Matter.Body.scale(this, SCALE, SCALE);
this.radius *= SCALE;
if (this.radius < 14) this.endCycle = 0;
@@ -3419,12 +3437,11 @@ const b = {
Matter.Body.setPosition(this, this.target.vertices[this.targetVertex])
Matter.Body.setVelocity(this.target, Vector.mult(this.target.velocity, 0.9))
Matter.Body.setAngularVelocity(this.target, this.target.angularVelocity * 0.9)
if (this.target.isShielded) {
this.target.damage(b.dmgScale * 0.001);
if (b.isModFoamShieldSKip) {
this.target.damage(b.dmgScale * 0.0025, true); //shield damage bypass
} else {
this.target.damage(b.dmgScale * 0.005);
}
} else if (this.target !== null) { //look for a new target
this.target = null
this.collisionFilter.category = cat.bullet;
@@ -3434,7 +3451,8 @@ const b = {
}
});
World.add(engine.world, bullet[me]); //add bullet to world
const SPEED = mech.crouch ? 22 : 12 - RADIUS * 0.25;
if (b.isModFoamShieldSKip) bullet[me].collisionFilter.mask = cat.mob // | cat.mobShield
const SPEED = (mech.crouch ? 17 : 12) - RADIUS * 0.25;
Matter.Body.setVelocity(bullet[me], {
x: SPEED * Math.cos(dir),
y: SPEED * Math.sin(dir)

View File

@@ -162,7 +162,7 @@ function collisionChecks(event) {
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
if (b.isModPiezo) {
mech.energy = mech.fieldEnergyMax;
mech.energy = mech.maxEnergy;
dmg *= 0.85
}
mech.damage(dmg);

View File

@@ -358,7 +358,7 @@ const game = {
b.giveGuns("all", 1000)
} else if (keys[72]) { // heal with H
mech.addHealth(Infinity)
mech.energy = mech.fieldEnergyMax;
mech.energy = mech.maxEnergy;
} else if (keys[89]) { //add mods with y
b.giveMod()
} else if (keys[82]) { // teleport to mouse with R
@@ -471,7 +471,7 @@ const game = {
b.setupAllMods(); //sets mods to default values
game.updateModHUD();
mech.maxHealth = 1
mech.fieldEnergyMax = 1
mech.maxEnergy = 1
game.paused = false;
engine.timing.timeScale = 1;
game.fpsCap = game.fpsCapDefault;
@@ -724,8 +724,8 @@ const game = {
if (mech.lastKillCycle + 300 > mech.cycle) { //effects active for 5 seconds after killing a mob
if (b.isModEnergyRecovery) {
mech.energy += mech.fieldEnergyMax * 0.07
if (mech.energy > mech.fieldEnergyMax) mech.energy = mech.fieldEnergyMax;
mech.energy += mech.maxEnergy * 0.07
if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy;
}
if (b.isModHealthRecovery) mech.addHealth(0.01)
}

View File

@@ -15,10 +15,10 @@ const level = {
if (build.isURLBuild && level.levelsCleared === 0) build.onLoadPowerUps();
if (level.levelsCleared === 0) { //this code only runs on the first level
// level.difficultyIncrease(9)
// b.giveGuns("missiles")
b.giveGuns("foam")
// mech.setField("time dilation field")
// b.giveMod("renormalization");
// b.giveMod("pocket universe");
// b.giveMod("quantum tunneling");
// b.giveGuns("grenades")
// b.giveMod("rocket-propelled grenade");
// mech.setField("pilot wave")
@@ -100,7 +100,7 @@ const level = {
//******************************************************************************************************************
testing() {
level.difficultyIncrease(9);
level.difficultyIncrease(19);
spawn.setSpawnList();
spawn.setSpawnList();
level.defaultZoom = 1500
@@ -153,12 +153,16 @@ const level = {
spawn.mapRect(level.exit.x, level.exit.y + 20, 100, 100); //exit bump
// spawn.bomberBoss(2900, -500)
spawn.stabber(1200, -500)
// spawn.chaser(1200, -500)
spawn.suckerBoss(1200, -500)
// spawn.hopper(1200, -500)
// spawn.shield(mob[mob.length - 1], 1200, -500, 1);
// spawn.nodeBoss(1200, -500, "spiker")
// spawn.hopper(1200, -500)
// spawn.timeSkipBoss(2900, -500)
// spawn.randomMob(1600, -500)
spawn.boost()
spawn.boost(1500, 0, 1400);
},
bosses() {
@@ -254,28 +258,35 @@ const level = {
level.addZone(level.exit.x, level.exit.y, 100, 30, "nextLevel");
spawn.mapRect(level.exit.x, level.exit.y + 25, 100, 100); //exit bump
document.body.style.backgroundColor = "#eee";
document.body.style.backgroundColor = "#ddd";
// game.draw.mapFill = "#444"
// game.draw.bodyFill = "rgba(140,140,140,0.85)"
// game.draw.bodyStroke = "#222"
level.fill.push({
x: 2600,
y: -600,
width: 400,
height: 500,
color: "rgba(0,255,255,0.05)"
});
level.fillBG.push({
x: 2600,
y: -600,
width: 400,
height: 500,
color: "#dee"
color: "#fff"
});
level.fill.push({
x: -150,
y: -1000,
width: 2750,
height: 1000,
color: "rgba(0,10,30,0.04)"
});
// level.fill.push({
// x: -150,
// y: -1000,
// width: 2750,
// height: 1000,
// color: "rgba(0,10,30,0.04)"
// });
const lineColor = "#ddd"
const lineColor = "#ccc"
level.fillBG.push({
x: 1600,
y: -500,
@@ -428,8 +439,7 @@ const level = {
spawn.bodyRect(2000, 50, 60, 60);
// spawn.bodyRect(1650, 50, 300, 200);
spawn.bodyRect(3175, -155, 325, 325);
spawn.mapRect(1800, 175, 800, 100); //stops above body from moving to right
spawn.mapRect(1800, Math.floor(Math.random() * 200), 850, 300); //stops above body from moving to right
//exit building
// spawn.mapRect(-100, -410, 100, 30);
spawn.mapRect(-300, -800, 500, 50);
@@ -509,7 +519,7 @@ const level = {
});
//far right structure
spawn.mapRect(5200, -775, 100, 920);
spawn.mapRect(5200, -725, 100, 870);
spawn.mapRect(5300, -1075, 350, 1220);
spawn.boost(5825, 235, 1400);
level.fill.push({
@@ -528,8 +538,8 @@ const level = {
height: 1500,
color: "rgba(0,20,40,0.13)"
});
spawn.mapRect(4000, -400, 325, 50);
spawn.mapRect(4725, -400, 325, 50);
spawn.mapRect(3950, -350, 375, 50);
spawn.mapRect(4725, -350, 375, 50);
spawn.mapRect(4000, -1300, 1050, 100);
//steep stairs

View File

@@ -953,8 +953,14 @@ const mobs = {
if (b.isModFarAwayDmg) dmg *= 1 + Math.sqrt(Math.max(500, Math.min(3000, this.distanceToPlayer())) - 500) * 0.0067 //up to 50% dmg at max range of 3500
//energy and heal drain should be calculated after damage boosts
if (b.modEnergySiphon && dmg !== Infinity) mech.energy += Math.min(this.health, dmg) * b.modEnergySiphon
if (b.modHealthDrain && dmg !== Infinity) mech.addHealth(Math.min(this.health, dmg) * b.modHealthDrain)
if (b.modEnergySiphon && dmg !== Infinity) {
mech.energy += Math.min(this.health, dmg) * b.modEnergySiphon
if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy
}
if (b.modHealthDrain && dmg !== Infinity) {
mech.addHealth(Math.min(this.health, dmg) * b.modHealthDrain)
if (mech.health > mech.maxHealth) mech.health = mech.maxHealth
}
this.health -= dmg
//this.fill = this.color + this.health + ')';
this.onDamage(dmg); //custom damage effects

View File

@@ -759,7 +759,7 @@ const mech = {
fireCDcycle: 0,
fieldCDcycle: 0,
fieldMode: 0, //basic field mode before upgrades
fieldEnergyMax: 1, //can be increased by a mod
maxEnergy: 1, //can be increased by a mod
holdingTarget: null,
fieldShieldingScale: 1,
timeSkipLastCycle: 0,
@@ -777,7 +777,7 @@ const mech = {
mech.fieldThreshold = Math.cos(mech.fieldArc * Math.PI)
},
setHoldDefaults() {
if (mech.energy < mech.fieldEnergyMax) mech.energy = mech.fieldEnergyMax;
if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy;
mech.fieldRegen = b.modEnergyRegen; //0.001
mech.fieldMeterColor = "#0cf"
mech.fieldShieldingScale = 1;
@@ -796,17 +796,18 @@ const mech = {
},
fieldMeterColor: "#0cf",
drawFieldMeter(bgColor = "rgba(0, 0, 0, 0.4)", range = 60) {
if (mech.energy < mech.fieldEnergyMax) {
if (mech.energy < mech.maxEnergy) {
mech.energy += mech.fieldRegen;
ctx.fillStyle = bgColor;
const xOff = mech.pos.x - mech.radius * mech.fieldEnergyMax
const xOff = mech.pos.x - mech.radius * mech.maxEnergy
const yOff = mech.pos.y - 50
ctx.fillRect(xOff, yOff, range * mech.fieldEnergyMax, 10);
ctx.fillRect(xOff, yOff, range * mech.maxEnergy, 10);
ctx.fillStyle = mech.fieldMeterColor;
ctx.fillRect(xOff, yOff, range * mech.energy, 10);
}
if (mech.energy < 0) mech.energy = 0
// else {
// mech.energy = mech.fieldEnergyMax
// mech.energy = mech.maxEnergy
// }
},
lookingAt(who) {
@@ -1019,7 +1020,7 @@ const mech = {
y: powerUp[i].velocity.y * 0.11
});
if (dist2 < 5000 && !game.isChoosing) { //use power up if it is close enough
if (b.isModMassEnergy) mech.energy = mech.fieldEnergyMax * 2;
if (b.isModMassEnergy) mech.energy = mech.maxEnergy * 2;
Matter.Body.setVelocity(player, { //player knock back, after grabbing power up
x: player.velocity.x + ((powerUp[i].velocity.x * powerUp[i].mass) / player.mass) * 0.3,
y: player.velocity.y + ((powerUp[i].velocity.y * powerUp[i].mass) / player.mass) * 0.3
@@ -1038,7 +1039,7 @@ const mech = {
if (mech.energy > fieldBlockCost * 0.2) { //shield needs at least some of the cost to block
mech.energy -= fieldBlockCost
if (mech.energy < 0) mech.energy = 0;
if (mech.energy > mech.fieldEnergyMax) mech.energy = mech.fieldEnergyMax;
if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy;
const unit = Vector.normalise(Vector.sub(player.position, who.position))
if (b.modBlockDmg) {
@@ -1378,7 +1379,7 @@ const mech = {
effect: () => {
// mech.fieldRegen *= 2;
mech.hold = function () {
if (mech.energy > mech.fieldEnergyMax - 0.02 && mech.fieldCDcycle < mech.cycle) {
if (mech.energy > mech.maxEnergy - 0.02 && mech.fieldCDcycle < mech.cycle) {
if (b.isModSporeField) {
// mech.fieldCDcycle = mech.cycle + 10; // set cool down to prevent +energy from making huge numbers of drones
const len = Math.floor(6 + 4 * Math.random())
@@ -1926,20 +1927,21 @@ const mech = {
mech.holdingTarget = null; //clears holding target (this is so you only pick up right after the field button is released and a hold target exists)
}
if (mech.energy < mech.fieldEnergyMax) {
if (mech.energy < mech.maxEnergy) {
mech.energy += mech.fieldRegen;
const xOff = mech.pos.x - mech.radius * mech.fieldEnergyMax
const xOff = mech.pos.x - mech.radius * mech.maxEnergy
const yOff = mech.pos.y - 50
ctx.fillStyle = "rgba(0, 0, 0, 0.3)";
ctx.fillRect(xOff, yOff, 60 * mech.fieldEnergyMax, 10);
ctx.fillRect(xOff, yOff, 60 * mech.maxEnergy, 10);
ctx.fillStyle = mech.fieldMeterColor;
ctx.fillRect(xOff, yOff, 60 * mech.energy, 10);
ctx.beginPath()
ctx.rect(xOff, yOff, 60 * mech.fieldEnergyMax, 10);
ctx.rect(xOff, yOff, 60 * mech.maxEnergy, 10);
ctx.strokeStyle = "rgb(0, 0, 0)";
ctx.lineWidth = 1;
ctx.stroke();
}
if (mech.energy < 0) mech.energy = 0
}
}
},
@@ -2000,6 +2002,7 @@ const mech = {
}
}
//grab power ups into the field
for (let i = 0, len = powerUp.length; i < len; ++i) {
const dxP = mech.fieldPosition.x - powerUp[i].position.x;
const dyP = mech.fieldPosition.y - powerUp[i].position.y;
@@ -2014,11 +2017,11 @@ const mech = {
y: powerUp[i].velocity.y * 0.11
});
if (dist2 < 5000 && !game.isChoosing) { //use power up if it is close enough
if (b.isModMassEnergy) mech.energy = mech.fieldEnergyMax * 2;
if (b.isModMassEnergy) mech.energy = mech.maxEnergy * 2;
powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1);
mech.fieldRadius += 50
// mech.fieldRadius += 50
break; //because the array order is messed up after splice
}
}

View File

@@ -78,7 +78,7 @@ const powerUps = {
}
}
if (target.ammo === Infinity) {
mech.energy = mech.fieldEnergyMax;
if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy;
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300);
} else {
let ammo = Math.ceil((target.ammoPack * (1 + 0.1 * Math.random())));
@@ -89,7 +89,7 @@ const powerUps = {
}
} else {
// 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
mech.energy = mech.fieldEnergyMax;
if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy;
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300);
}
}
@@ -110,17 +110,18 @@ const powerUps = {
}
let choice1 = pick(mech.fieldUpgrades)
let choice2 = pick(mech.fieldUpgrades, choice1)
let choice2 = -1
let choice3 = -1
if (choice1 > -1) {
let text = `<div class='cancel' onclick='powerUps.cancel("field")'>✕</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>`
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) {
choice2 = pick(mech.fieldUpgrades, choice1)
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>`
choice3 = pick(mech.fieldUpgrades, choice1, choice2)
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice3})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice3].name}</div> ${mech.fieldUpgrades[choice3].description}</div>`
}
if (b.isModFourOptions) {
if (b.isModExtraChoice) {
let choice4 = pick(mech.fieldUpgrades, choice1, choice2, choice3)
if (choice4 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice4})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice4].name}</div> ${mech.fieldUpgrades[choice4].description}</div>`
}
@@ -154,17 +155,18 @@ const powerUps = {
}
let choice1 = pick()
let choice2 = pick(choice1)
let choice2 = -1
let choice3 = -1
if (choice1 > -1) {
let text = `<div class='cancel' onclick='powerUps.cancel("mod")'>✕</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>`
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) {
choice2 = pick(choice1)
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>`
choice3 = pick(choice1, choice2)
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice3})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[choice3].name}</div> ${b.mods[choice3].description}</div>`
}
if (b.isModFourOptions) {
if (b.isModExtraChoice) {
let choice4 = pick(choice1, choice2, choice3)
if (choice4 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice4})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[choice4].name}</div> ${b.mods[choice4].description}</div>`
}
@@ -191,17 +193,18 @@ const powerUps = {
}
let choice1 = pick(b.guns)
let choice2 = pick(b.guns, choice1)
let choice2 = -1
let choice3 = -1
if (choice1 > -1) {
let text = `<div class='cancel' onclick='powerUps.cancel("gun")'>✕</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>`
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) {
choice2 = pick(b.guns, choice1)
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>`
choice3 = pick(b.guns, choice1, choice2)
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice3})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice3].name}</div> ${b.guns[choice3].description}</div>`
}
if (b.isModFourOptions) {
if (b.isModExtraChoice) {
let choice4 = pick(b.guns, choice1, choice2, choice3)
if (choice4 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice4})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice4].name}</div> ${b.guns[choice4].description}</div>`
}

View File

@@ -517,10 +517,9 @@ const spawn = {
//when player is inside event horizon
if (Vector.magnitude(Vector.sub(this.position, player.position)) < eventHorizon) {
if (mech.energy > 0.1) {
mech.energy -= 0.005
} else {
mech.damage(0.0002 * game.dmgScale);
mech.energy -= 0.004
if (mech.energy < 0.1) {
mech.damage(0.00015 * game.dmgScale);
}
const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x);
player.force.x -= 0.00125 * player.mass * Math.cos(angle) * (mech.onGround ? 1.8 : 1);
@@ -616,10 +615,9 @@ const spawn = {
ctx.fill();
//when player is inside event horizon
if (Vector.magnitude(Vector.sub(this.position, player.position)) < eventHorizon) {
if (mech.energy > 0.1) {
mech.energy -= 0.0075
} else {
mech.damage(0.0003 * game.dmgScale);
mech.energy -= 0.006
if (mech.energy < 0.1) {
mech.damage(0.0002 * game.dmgScale);
}
const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x);
player.force.x -= 0.0013 * Math.cos(angle) * player.mass * (mech.onGround ? 1.7 : 1);
@@ -936,7 +934,8 @@ const spawn = {
ctx.lineTo(best.x, best.y);
}
},
stabber(x, y, radius = 25 + Math.ceil(Math.random() * 15)) {
stabber(x, y, radius = 25 + Math.ceil(Math.random() * 12)) {
if (radius > 80) radius = 65;
mobs.spawn(x, y, 6, radius, "rgb(220,50,205)"); //can't have sides above 6 or collision events don't work (probably because of a convex problem)
let me = mob[mob.length - 1];
me.accelMag = 0.0006 * game.accelScale;

View File

@@ -268,6 +268,7 @@ summary {
width: 100%;
height: 100%;
display: none;
/* background-color also set in mass-energy mod */
background-color: #f67;
opacity: 0;
transition: opacity 1s;

View File

@@ -2,6 +2,12 @@
************** TODO - n-gon **************
mod - annihilation might be unbalanced?
boss mob - let it die multiple times and come back to life
on death event spawns a new version of self, but with a decrementing counter
foam - check for touching map / blocks and slow foam down rather then bounce off walls
quantum foam should just skip the shield