Composite replaces World

Matter.World has been replaced with Matter.Composite
  matter.js deprecated World
  could cause problems merging your old code
    (replace World with Composite in your code)

tech: many worlds - now costs 1 research at the start of each level to activate
  a nerf, but also a buff because if you like a build you can freeze it by not getting research

mine gun has 25% less ammo and 33% more damage

railgun now gets 50% more ammo, but it fires slower
fixed rail gun ammo drain on misfire bug

fixed experiment gun display bug
This commit is contained in:
landgreen
2021-08-06 09:20:37 -07:00
parent d8e891a681
commit aea9276cb2
13 changed files with 464 additions and 309 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -111,6 +111,18 @@ const b = {
// m.setMaxHealth(); // m.setMaxHealth();
// } // }
}, },
refundAmmo() { //triggers after firing when you removed ammo for a gun, but didn't need to (like a rail gun misfire)
if (tech.isCrouchAmmo && m.crouch) {
tech.isCrouchAmmo--
if ((tech.isCrouchAmmo) % 2) {
b.guns[b.activeGun].ammo++;
simulation.updateGunHUD();
}
} else {
b.guns[b.activeGun].ammo++;
simulation.updateGunHUD();
}
},
giveGuns(gun = "random", ammoPacks = 10) { giveGuns(gun = "random", ammoPacks = 10) {
if (tech.isOneGun) b.removeAllGuns(); if (tech.isOneGun) b.removeAllGuns();
if (gun === "random") { if (gun === "random") {
@@ -192,7 +204,7 @@ const b = {
if (bullet[i].endCycle < simulation.cycle) { if (bullet[i].endCycle < simulation.cycle) {
bullet[i].onEnd(i); //some bullets do stuff on end bullet[i].onEnd(i); //some bullets do stuff on end
if (bullet[i]) { if (bullet[i]) {
Matter.World.remove(engine.world, bullet[i]); Matter.Composite.remove(engine.world, bullet[i]);
bullet.splice(i, 1); bullet.splice(i, 1);
} else { } else {
break; //if bullet[i] doesn't exist don't complete the for loop, because the game probably reset break; //if bullet[i] doesn't exist don't complete the for loop, because the game probably reset
@@ -210,7 +222,7 @@ const b = {
} }
ctx.lineTo(vertices[0].x, vertices[0].y); ctx.lineTo(vertices[0].x, vertices[0].y);
} }
ctx.fillStyle = "#000"; ctx.fillStyle = color.bullet;
ctx.fill(); ctx.fill();
}, },
bulletDo() { bulletDo() {
@@ -224,7 +236,7 @@ const b = {
x: m.Vx / 2 + speed * Math.cos(dir), x: m.Vx / 2 + speed * Math.cos(dir),
y: m.Vy / 2 + speed * Math.sin(dir) y: m.Vy / 2 + speed * Math.sin(dir)
}); });
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
}, },
fireCDscale: 1, fireCDscale: 1,
setFireCD() { setFireCD() {
@@ -408,7 +420,7 @@ const b = {
const size = 20 + 350 * Math.pow(body[i].mass, 0.25) const size = 20 + 350 * Math.pow(body[i].mass, 0.25)
const where = body[i].position const where = body[i].position
const onLevel = level.onLevel //prevent explosions in the next level const onLevel = level.onLevel //prevent explosions in the next level
Matter.World.remove(engine.world, body[i]); Matter.Composite.remove(engine.world, body[i]);
body.splice(i, 1); body.splice(i, 1);
setTimeout(() => { setTimeout(() => {
if (onLevel === level.onLevel) b.explosion(where, size); //makes bullet do explosive damage at end if (onLevel === level.onLevel) b.explosion(where, size); //makes bullet do explosive damage at end
@@ -733,7 +745,7 @@ const b = {
bullet[me].do = function() { bullet[me].do = function() {
this.force.y += this.mass * 0.0025; //extra gravity for harder arcs this.force.y += this.mass * 0.0025; //extra gravity for harder arcs
}; };
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
} }
grenadeRPG = function(where = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }, angle = m.angle) { grenadeRPG = function(where = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }, angle = m.angle) {
const me = bullet.length; const me = bullet.length;
@@ -753,7 +765,7 @@ const b = {
x: m.Vx / 2 + speed * Math.cos(angle), x: m.Vx / 2 + speed * Math.cos(angle),
y: m.Vy / 2 + speed * Math.sin(angle) y: m.Vy / 2 + speed * Math.sin(angle)
}); });
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
bullet[me].endCycle = simulation.cycle + 70; bullet[me].endCycle = simulation.cycle + 70;
bullet[me].frictionAir = 0.07; bullet[me].frictionAir = 0.07;
@@ -788,7 +800,7 @@ const b = {
x: m.Vx / 2 + speed * Math.cos(angle), x: m.Vx / 2 + speed * Math.cos(angle),
y: m.Vy / 2 + speed * Math.sin(angle) y: m.Vy / 2 + speed * Math.sin(angle)
}); });
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
bullet[me].endCycle = simulation.cycle + 70; bullet[me].endCycle = simulation.cycle + 70;
bullet[me].frictionAir = 0.07; bullet[me].frictionAir = 0.07;
@@ -914,7 +926,7 @@ const b = {
x: m.Vx / 2 + speed * Math.cos(angle), x: m.Vx / 2 + speed * Math.cos(angle),
y: m.Vy / 2 + speed * Math.sin(angle) y: m.Vy / 2 + speed * Math.sin(angle)
}); });
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
} }
grenadeNeutron = function(where = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }, angle = m.angle) { grenadeNeutron = function(where = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }, angle = m.angle) {
@@ -1206,7 +1218,7 @@ const b = {
x: m.Vx / 2 + speed * Math.cos(angle), x: m.Vx / 2 + speed * Math.cos(angle),
y: m.Vy / 2 + speed * Math.sin(angle) y: m.Vy / 2 + speed * Math.sin(angle)
}); });
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
}, },
lastAngle: 0, lastAngle: 0,
wasExtruderOn: false, wasExtruderOn: false,
@@ -1280,7 +1292,7 @@ const b = {
} }
} }
}); });
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: SPEED * Math.cos(m.angle), x: SPEED * Math.cos(m.angle),
y: SPEED * Math.sin(m.angle) y: SPEED * Math.sin(m.angle)
@@ -1600,7 +1612,7 @@ const b = {
dmg: 0, // 0.14 //damage done in addition to the damage from momentum dmg: 0, // 0.14 //damage done in addition to the damage from momentum
minDmgSpeed: 2, minDmgSpeed: 2,
lookFrequency: 67 + Math.floor(7 * Math.random()), lookFrequency: 67 + Math.floor(7 * Math.random()),
drain: 0.6 * tech.isLaserDiode * tech.laserFieldDrain, drain: 0.45 * tech.isLaserDiode * tech.laserFieldDrain,
isArmed: false, isArmed: false,
torqueMagnitude: 0.000003 * (Math.round(Math.random()) ? 1 : -1), torqueMagnitude: 0.000003 * (Math.round(Math.random()) ? 1 : -1),
range: 1500, range: 1500,
@@ -1662,7 +1674,7 @@ const b = {
} }
}) })
Matter.Body.setVelocity(bullet[me], velocity); Matter.Body.setVelocity(bullet[me], velocity);
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
}, },
mine(where, velocity, angle = 0, isAmmoBack = false) { mine(where, velocity, angle = 0, isAmmoBack = false) {
const bIndex = bullet.length; const bIndex = bullet.length;
@@ -1758,7 +1770,7 @@ const b = {
this.force.y += this.mass * 0.002; //extra gravity this.force.y += this.mass * 0.002; //extra gravity
if (!(simulation.cycle % this.lookFrequency) && !m.isBodiesAsleep) { //find mob targets if (!(simulation.cycle % this.lookFrequency) && !m.isBodiesAsleep) { //find mob targets
this.endCycle -= 8 this.endCycle -= 8
b.targetedNail(this.position, 1, 45 + 5 * Math.random(), 1100, false) b.targetedNail(this.position, 1, 45 + 5 * Math.random(), 1100, false, 2) //targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, isRandomAim = true, damage = 1.4) {
if (!(simulation.cycle % (this.lookFrequency * 6))) { if (!(simulation.cycle % (this.lookFrequency * 6))) {
simulation.drawList.push({ simulation.drawList.push({
x: this.position.x, x: this.position.x,
@@ -1807,7 +1819,8 @@ const b = {
}, },
onEnd() { onEnd() {
if (this.isArmed) { if (this.isArmed) {
b.targetedNail(this.position, 22) b.targetedNail(this.position, 22, 40 + 10 * Math.random(), 1200, true, 1.9) //targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, isRandomAim = true, damage = 1.4) {
} }
if (tech.isMineAmmoBack && (!this.isArmed || Math.random() < 0.2)) { //get ammo back from tech.isMineAmmoBack if (tech.isMineAmmoBack && (!this.isArmed || Math.random() < 0.2)) { //get ammo back from tech.isMineAmmoBack
for (i = 0, len = b.guns.length; i < len; i++) { //find which gun for (i = 0, len = b.guns.length; i < len; i++) { //find which gun
@@ -1831,7 +1844,7 @@ const b = {
}); });
bullet[bIndex].torque += bullet[bIndex].inertia * 0.0002 * (0.5 - Math.random()) bullet[bIndex].torque += bullet[bIndex].inertia * 0.0002 * (0.5 - Math.random())
Matter.Body.setVelocity(bullet[bIndex], velocity); Matter.Body.setVelocity(bullet[bIndex], velocity);
World.add(engine.world, bullet[bIndex]); //add bullet to world Composite.add(engine.world, bullet[bIndex]); //add bullet to world
}, },
worm(where, isFreeze = tech.isSporeFreeze) { //used with the tech upgrade in mob.death() worm(where, isFreeze = tech.isSporeFreeze) { //used with the tech upgrade in mob.death()
const bIndex = bullet.length; const bIndex = bullet.length;
@@ -1924,7 +1937,7 @@ const b = {
x: SPEED * Math.cos(ANGLE), x: SPEED * Math.cos(ANGLE),
y: SPEED * Math.sin(ANGLE) y: SPEED * Math.sin(ANGLE)
}); });
World.add(engine.world, bullet[bIndex]); //add bullet to world Composite.add(engine.world, bullet[bIndex]); //add bullet to world
if (tech.isMutualism && m.health > 0.02) { if (tech.isMutualism && m.health > 0.02) {
m.health -= 0.005 - 0.005 * tech.isSporeWorm m.health -= 0.005 - 0.005 * tech.isSporeWorm
m.displayHealth(); m.displayHealth();
@@ -2044,7 +2057,7 @@ const b = {
x: SPEED * Math.cos(ANGLE), x: SPEED * Math.cos(ANGLE),
y: SPEED * Math.sin(ANGLE) y: SPEED * Math.sin(ANGLE)
}); });
World.add(engine.world, bullet[bIndex]); //add bullet to world Composite.add(engine.world, bullet[bIndex]); //add bullet to world
if (tech.isMutualism && m.health > 0.02) { if (tech.isMutualism && m.health > 0.02) {
m.health -= 0.005 - 0.005 * tech.isSporeWorm m.health -= 0.005 - 0.005 * tech.isSporeWorm
@@ -2114,7 +2127,7 @@ const b = {
} }
}) })
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
// Matter.Body.setAngularVelocity(bullet[me], 2 * (0.5 - Math.random())) //doesn't work due to high friction // Matter.Body.setAngularVelocity(bullet[me], 2 * (0.5 - Math.random())) //doesn't work due to high friction
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: speed * Math.cos(dir), x: speed * Math.cos(dir),
@@ -2242,7 +2255,7 @@ const b = {
//pick up nearby power ups //pick up nearby power ups
powerUps.onPickUp(powerUp[i]); powerUps.onPickUp(powerUp[i]);
powerUp[i].effect(); powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]); Matter.Composite.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1); powerUp.splice(i, 1);
if (tech.isDroneGrab) { if (tech.isDroneGrab) {
this.isImproved = true; this.isImproved = true;
@@ -2274,7 +2287,7 @@ const b = {
//pick up nearby power ups //pick up nearby power ups
powerUps.onPickUp(powerUp[i]); powerUps.onPickUp(powerUp[i]);
powerUp[i].effect(); powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]); Matter.Composite.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1); powerUp.splice(i, 1);
if (tech.isDroneGrab) { if (tech.isDroneGrab) {
this.isImproved = true; this.isImproved = true;
@@ -2318,7 +2331,7 @@ const b = {
} }
} }
}) })
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: speed * Math.cos(dir), x: speed * Math.cos(dir),
y: speed * Math.sin(dir) y: speed * Math.sin(dir)
@@ -2458,7 +2471,7 @@ const b = {
//pick up nearby power ups //pick up nearby power ups
powerUps.onPickUp(powerUp[i]); powerUps.onPickUp(powerUp[i]);
powerUp[i].effect(); powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]); Matter.Composite.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1); powerUp.splice(i, 1);
if (tech.isDroneGrab) { if (tech.isDroneGrab) {
this.isImproved = true; this.isImproved = true;
@@ -2491,7 +2504,7 @@ const b = {
//pick up nearby power ups //pick up nearby power ups
powerUps.onPickUp(powerUp[i]); powerUps.onPickUp(powerUp[i]);
powerUp[i].effect(); powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]); Matter.Composite.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1); powerUp.splice(i, 1);
if (tech.isDroneGrab) { if (tech.isDroneGrab) {
this.isImproved = true; this.isImproved = true;
@@ -2535,7 +2548,7 @@ const b = {
} }
} }
}) })
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: speed * Math.cos(dir), x: speed * Math.cos(dir),
y: speed * Math.sin(dir) y: speed * Math.sin(dir)
@@ -2631,14 +2644,14 @@ const b = {
this.target = null this.target = null
this.collisionFilter.category = cat.bullet; this.collisionFilter.category = cat.bullet;
this.collisionFilter.mask = cat.mob //| cat.mobShield //cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield this.collisionFilter.mask = cat.mob //| cat.mobShield //cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
if (tech.isFoamGrowOnDeath && bullet.length < 200) { if (tech.isFoamGrowOnDeath && bullet.length < 180) {
let targets = [] let targets = []
for (let i = 0, len = mob.length; i < len; i++) { for (let i = 0, len = mob.length; i < len; i++) {
const dist = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position)); const dist = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position));
if (dist < 1000000) targets.push(mob[i]) if (dist < 1000000) targets.push(mob[i])
} }
const radius = Math.min(this.radius * 0.5, 10) const radius = Math.min(this.radius * 0.5, 9)
const len = bullet.length < 100 ? 2 : 1 const len = bullet.length < 80 ? 2 : 1
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
if (targets.length - i > 0) { if (targets.length - i > 0) {
const index = Math.floor(Math.random() * targets.length) const index = Math.floor(Math.random() * targets.length)
@@ -2697,7 +2710,7 @@ const b = {
} }
}); });
if (tech.isFoamTeleport) bullet[me].nextPortCycle = simulation.cycle + bullet[me].portFrequency if (tech.isFoamTeleport) bullet[me].nextPortCycle = simulation.cycle + bullet[me].portFrequency
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
Matter.Body.setVelocity(bullet[me], velocity); Matter.Body.setVelocity(bullet[me], velocity);
}, },
targetedBlock(who, isSpin = false, speed = 50 - Math.min(20, who.mass * 2), range = 1600) { targetedBlock(who, isSpin = false, speed = 50 - Math.min(20, who.mass * 2), range = 1600) {
@@ -2718,7 +2731,7 @@ const b = {
Matter.Body.setVelocity(who, velocity); Matter.Body.setVelocity(who, velocity);
} }
}, },
targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, isRandomAim = true) { targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, isRandomAim = true, damage = 1.4) {
const targets = [] //target nearby mobs const targets = [] //target nearby mobs
for (let i = 0, len = mob.length; i < len; i++) { for (let i = 0, len = mob.length; i < len; i++) {
const dist = Vector.magnitude(Vector.sub(position, mob[i].position)); const dist = Vector.magnitude(Vector.sub(position, mob[i].position));
@@ -2734,13 +2747,13 @@ const b = {
x: targets[index].x + SPREAD * (Math.random() - 0.5), x: targets[index].x + SPREAD * (Math.random() - 0.5),
y: targets[index].y + SPREAD * (Math.random() - 0.5) y: targets[index].y + SPREAD * (Math.random() - 0.5)
} }
b.nail(position, Vector.mult(Vector.normalise(Vector.sub(WHERE, position)), speed), 1.4) b.nail(position, Vector.mult(Vector.normalise(Vector.sub(WHERE, position)), speed), damage)
} else if (isRandomAim) { // aim in random direction } else if (isRandomAim) { // aim in random direction
const ANGLE = 2 * Math.PI * Math.random() const ANGLE = 2 * Math.PI * Math.random()
b.nail(position, { b.nail(position, {
x: speed * Math.cos(ANGLE), x: speed * Math.cos(ANGLE),
y: speed * Math.sin(ANGLE) y: speed * Math.sin(ANGLE)
}, 1.4) }, damage)
} }
} }
}, },
@@ -2748,7 +2761,7 @@ const b = {
const me = bullet.length; const me = bullet.length;
bullet[me] = Bodies.rectangle(pos.x, pos.y, 25, 2, b.fireAttributes(Math.atan2(velocity.y, velocity.x))); bullet[me] = Bodies.rectangle(pos.x, pos.y, 25, 2, b.fireAttributes(Math.atan2(velocity.y, velocity.x)));
Matter.Body.setVelocity(bullet[me], velocity); Matter.Body.setVelocity(bullet[me], velocity);
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
bullet[me].endCycle = simulation.cycle + 60 + 18 * Math.random(); bullet[me].endCycle = simulation.cycle + 60 + 18 * Math.random();
bullet[me].dmg = tech.isNailRadiation ? 0 : dmg bullet[me].dmg = tech.isNailRadiation ? 0 : dmg
bullet[me].beforeDmg = function(who) { //beforeDmg is rewritten with ice crystal tech bullet[me].beforeDmg = function(who) { //beforeDmg is rewritten with ice crystal tech
@@ -2822,7 +2835,7 @@ const b = {
y: m.Vy / 2 + SPEED * Math.sin(angle) y: m.Vy / 2 + SPEED * Math.sin(angle)
}); });
// Matter.Body.setDensity(bullet[me], 0.00001); // Matter.Body.setDensity(bullet[me], 0.00001);
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
}, },
// ************************************************************************************************** // **************************************************************************************************
// ************************************************************************************************** // **************************************************************************************************
@@ -3024,7 +3037,7 @@ const b = {
} }
} }
}) })
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
b.setDynamoBotDelay() b.setDynamoBotDelay()
}, },
nailBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { nailBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) {
@@ -3079,7 +3092,7 @@ const b = {
} }
} }
}) })
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
}, },
missileBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { missileBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) {
if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.missileBot()`); if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.missileBot()`);
@@ -3130,7 +3143,7 @@ const b = {
} }
} }
}) })
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
}, },
foamBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { foamBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) {
if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.foamBot()`); if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.foamBot()`);
@@ -3185,7 +3198,7 @@ const b = {
} }
} }
}) })
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
}, },
laserBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { laserBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) {
if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.laserBot()`); if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.laserBot()`);
@@ -3273,7 +3286,7 @@ const b = {
} }
} }
}) })
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
}, },
boomBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { boomBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) {
if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.boomBot()`); if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.boomBot()`);
@@ -3358,7 +3371,7 @@ const b = {
} }
} }
}) })
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
}, },
plasmaBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { plasmaBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) {
if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.plasmaBot()`); if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.plasmaBot()`);
@@ -3544,7 +3557,7 @@ const b = {
} }
} }
}) })
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
}, },
orbitBot(position = player.position, isConsole = true) { orbitBot(position = player.position, isConsole = true) {
if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.orbitBot()`); if (isConsole) simulation.makeTextLog(`<span class='color-var'>b</span>.orbitBot()`);
@@ -3629,7 +3642,7 @@ const b = {
// bullet[me].orbitalSpeed = Math.sqrt(0.7 / bullet[me].range) // bullet[me].orbitalSpeed = Math.sqrt(0.7 / bullet[me].range)
bullet[me].orbitalSpeed = Math.sqrt(0.25 / bullet[me].range) //also set in bot upgrade too! bullet[me].orbitalSpeed = Math.sqrt(0.25 / bullet[me].range) //also set in bot upgrade too!
// bullet[me].phase = (index / tech.orbitBotCount) * 2 * Math.PI // bullet[me].phase = (index / tech.orbitBotCount) * 2 * Math.PI
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
//reorder orbital bot positions around a circle //reorder orbital bot positions around a circle
let totalOrbitalBots = 0 let totalOrbitalBots = 0
@@ -3721,7 +3734,7 @@ const b = {
bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle), m.pos.y + 35 * Math.sin(m.angle), 5 * size, size, b.fireAttributes(m.angle)); bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle), m.pos.y + 35 * Math.sin(m.angle), 5 * size, size, b.fireAttributes(m.angle));
bullet[me].dmg = tech.isNailRadiation ? 0 : 2.75 bullet[me].dmg = tech.isNailRadiation ? 0 : 2.75
Matter.Body.setDensity(bullet[me], 0.002); Matter.Body.setDensity(bullet[me], 0.002);
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
const SPEED = m.crouch ? 55 : 44 const SPEED = m.crouch ? 55 : 44
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: SPEED * Math.cos(m.angle), x: SPEED * Math.cos(m.angle),
@@ -3834,7 +3847,7 @@ const b = {
bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle), m.pos.y + 35 * Math.sin(m.angle), 60, 27, b.fireAttributes(dir)); bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle), m.pos.y + 35 * Math.sin(m.angle), 60, 27, b.fireAttributes(dir));
Matter.Body.setDensity(bullet[me], 0.007 * (tech.isShotgunReversed ? 1.6 : 1)); Matter.Body.setDensity(bullet[me], 0.007 * (tech.isShotgunReversed ? 1.6 : 1));
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
const SPEED = (m.crouch ? 45 : 35) + Math.random() * 6 const SPEED = (m.crouch ? 45 : 35) + Math.random() * 6
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: SPEED * Math.cos(dir), x: SPEED * Math.cos(dir),
@@ -3904,7 +3917,7 @@ const b = {
this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
}; };
bullet[me].do = function() {} bullet[me].do = function() {}
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
} }
} else if (tech.isNailShot) { } else if (tech.isNailShot) {
spread *= 0.65 spread *= 0.65
@@ -3985,7 +3998,7 @@ const b = {
const me = bullet.length; const me = bullet.length;
const dir = m.angle + (Math.random() - 0.5) * spread const dir = m.angle + (Math.random() - 0.5) * spread
bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle) + 15 * (Math.random() - 0.5), m.pos.y + 35 * Math.sin(m.angle) + 15 * (Math.random() - 0.5), side, side, b.fireAttributes(dir)); bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle) + 15 * (Math.random() - 0.5), m.pos.y + 35 * Math.sin(m.angle) + 15 * (Math.random() - 0.5), side, side, b.fireAttributes(dir));
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
const SPEED = 52 + Math.random() * 8 const SPEED = 52 + Math.random() * 8
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: SPEED * Math.cos(dir), x: SPEED * Math.cos(dir),
@@ -4019,7 +4032,7 @@ const b = {
let dir = m.angle let dir = m.angle
const me = bullet.length; const me = bullet.length;
bullet[me] = Bodies.polygon(m.pos.x + 30 * Math.cos(m.angle), m.pos.y + 30 * Math.sin(m.angle), 12, 21 * tech.bulletSize, b.fireAttributes(dir, false)); bullet[me] = Bodies.polygon(m.pos.x + 30 * Math.cos(m.angle), m.pos.y + 30 * Math.sin(m.angle), 12, 21 * tech.bulletSize, b.fireAttributes(dir, false));
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: SPEED * Math.cos(dir), x: SPEED * Math.cos(dir),
y: SPEED * Math.sin(dir) y: SPEED * Math.sin(dir)
@@ -4048,7 +4061,7 @@ const b = {
for (let i = 0; i < tech.superBallNumber; i++) { for (let i = 0; i < tech.superBallNumber; i++) {
const me = bullet.length; const me = bullet.length;
bullet[me] = Bodies.polygon(m.pos.x + 30 * Math.cos(m.angle), m.pos.y + 30 * Math.sin(m.angle), 12, 11 * tech.bulletSize, b.fireAttributes(dir, false)); bullet[me] = Bodies.polygon(m.pos.x + 30 * Math.cos(m.angle), m.pos.y + 30 * Math.sin(m.angle), 12, 11 * tech.bulletSize, b.fireAttributes(dir, false));
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: SPEED * Math.cos(dir), x: SPEED * Math.cos(dir),
y: SPEED * Math.sin(dir) y: SPEED * Math.sin(dir)
@@ -4081,7 +4094,7 @@ const b = {
const fireBall = () => { const fireBall = () => {
const me = bullet.length; const me = bullet.length;
bullet[me] = Bodies.polygon(x, y, 12, 11 * tech.bulletSize, b.fireAttributes(dir, false)); bullet[me] = Bodies.polygon(x, y, 12, 11 * tech.bulletSize, b.fireAttributes(dir, false));
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: SPEED * Math.cos(dir), x: SPEED * Math.cos(dir),
y: SPEED * Math.sin(dir) y: SPEED * Math.sin(dir)
@@ -4412,7 +4425,7 @@ const b = {
} }
} }
} }
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: tech.waveBeamSpeed * Math.cos(m.angle), x: tech.waveBeamSpeed * Math.cos(m.angle),
y: tech.waveBeamSpeed * Math.sin(m.angle) y: tech.waveBeamSpeed * Math.sin(m.angle)
@@ -4559,7 +4572,7 @@ const b = {
name: "mine", name: "mine",
description: "toss a <strong>proximity</strong> mine that <strong>sticks</strong> to walls<br>fires <strong>nails</strong> at mobs within range", description: "toss a <strong>proximity</strong> mine that <strong>sticks</strong> to walls<br>fires <strong>nails</strong> at mobs within range",
ammo: 0, ammo: 0,
ammoPack: 2, ammoPack: 1.5,
have: false, have: false,
do() {}, do() {},
fire() { fire() {
@@ -4833,7 +4846,7 @@ const b = {
name: "rail gun", name: "rail gun",
description: "use <strong class='color-f'>energy</strong> to launch a high-speed <strong>dense</strong> rod<br><strong>hold</strong> left mouse to charge, <strong>release</strong> to fire", description: "use <strong class='color-f'>energy</strong> to launch a high-speed <strong>dense</strong> rod<br><strong>hold</strong> left mouse to charge, <strong>release</strong> to fire",
ammo: 0, ammo: 0,
ammoPack: 3, ammoPack: 5,
have: false, have: false,
do() {}, do() {},
fire() { fire() {
@@ -4886,7 +4899,7 @@ const b = {
if (tech.isCapacitor) { if (tech.isCapacitor) {
if ((m.energy > 0.16 || tech.isRailEnergyGain)) { //&& m.immuneCycle < m.cycle if ((m.energy > 0.16 || tech.isRailEnergyGain)) { //&& m.immuneCycle < m.cycle
m.energy += 0.16 * (tech.isRailEnergyGain ? 4.5 : -1) m.energy += 0.16 * (tech.isRailEnergyGain ? 4.5 : -1)
m.fireCDcycle = m.cycle + Math.floor(30 * b.fireCDscale); m.fireCDcycle = m.cycle + Math.floor(40 * b.fireCDscale);
const me = bullet.length; const me = bullet.length;
bullet[me] = Bodies.rectangle(m.pos.x + 50 * Math.cos(m.angle), m.pos.y + 50 * Math.sin(m.angle), 60, 14, { bullet[me] = Bodies.rectangle(m.pos.x + 50 * Math.cos(m.angle), m.pos.y + 50 * Math.sin(m.angle), 60, 14, {
density: 0.005, //0.001 is normal density: 0.005, //0.001 is normal
@@ -4956,7 +4969,7 @@ const b = {
} }
} }
}); });
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
const speed = 67 const speed = 67
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
@@ -4968,9 +4981,9 @@ const b = {
const KNOCK = (m.crouch ? 0.08 : 0.34) * (tech.isShotgunReversed ? -2 : 1) const KNOCK = (m.crouch ? 0.08 : 0.34) * (tech.isShotgunReversed ? -2 : 1)
player.force.x -= KNOCK * Math.cos(m.angle) player.force.x -= KNOCK * Math.cos(m.angle)
player.force.y -= KNOCK * Math.sin(m.angle) * 0.35 //reduce knock back in vertical direction to stop super jumps player.force.y -= KNOCK * Math.sin(m.angle) * 0.35 //reduce knock back in vertical direction to stop super jumps
pushAway(800) pushAway(800)
} else { } else {
b.refundAmmo()
m.fireCDcycle = m.cycle + Math.floor(120); m.fireCDcycle = m.cycle + Math.floor(120);
} }
} else { } else {
@@ -5007,7 +5020,7 @@ const b = {
onEnd() {} onEnd() {}
}); });
m.fireCDcycle = Infinity; // cool down m.fireCDcycle = Infinity; // cool down
World.add(engine.world, bullet[me]); //add bullet to world Composite.add(engine.world, bullet[me]); //add bullet to world
bullet[me].endCycle = Infinity bullet[me].endCycle = Infinity
bullet[me].charge = 0; bullet[me].charge = 0;
bullet[me].do = function() { bullet[me].do = function() {
@@ -5015,6 +5028,7 @@ const b = {
m.energy += 0.05 + this.charge * 0.2 m.energy += 0.05 + this.charge * 0.2
m.fireCDcycle = m.cycle + 120; // cool down if out of energy m.fireCDcycle = m.cycle + 120; // cool down if out of energy
this.endCycle = 0; this.endCycle = 0;
b.refundAmmo()
return return
} }
@@ -5045,7 +5059,6 @@ const b = {
player.force.y -= KNOCK * Math.sin(m.angle) * 0.35 //reduce knock back in vertical direction to stop super jumps player.force.y -= KNOCK * Math.sin(m.angle) * 0.35 //reduce knock back in vertical direction to stop super jumps
pushAway(1200 * this.charge) pushAway(1200 * this.charge)
} else { // charging on mouse down } else { // charging on mouse down
if (tech.isFireMoveLock) { if (tech.isFireMoveLock) {
Matter.Body.setVelocity(player, { Matter.Body.setVelocity(player, {
x: 0, x: 0,
@@ -5055,10 +5068,9 @@ const b = {
player.force.y = 0 player.force.y = 0
} }
m.fireCDcycle = Infinity //can't fire until mouse is released m.fireCDcycle = Infinity //can't fire until mouse is released
const previousCharge = this.charge const previousCharge = this.charge
let smoothRate = 0.98 * (m.crouch ? 0.99 : 1) * (0.98 + 0.02 * b.fireCDscale) //small b.fireCDscale = faster shots, b.fireCDscale=1 = normal shot, big b.fireCDscale = slower chot let smoothRate = (m.crouch ? 0.98 : 0.99) * (0.98 + 0.02 * b.fireCDscale) //small b.fireCDscale = faster shots, b.fireCDscale=1 = normal shot, big b.fireCDscale = slower chot
this.charge = this.charge * smoothRate + 1 * (1 - smoothRate) this.charge = this.charge * smoothRate + 1 * (1 - smoothRate)
if (tech.isRailEnergyGain) { if (tech.isRailEnergyGain) {
m.energy += (this.charge - previousCharge) * 1.5 //energy drain is proportional to charge gained, but doesn't stop normal m.fieldRegen m.energy += (this.charge - previousCharge) * 1.5 //energy drain is proportional to charge gained, but doesn't stop normal m.fieldRegen

View File

@@ -1,7 +1,6 @@
//matter.js *********************************************************** //matter.js ***********************************************************
// module aliases // module aliases
const Engine = Matter.Engine, const Engine = Matter.Engine,
World = Matter.World,
Events = Matter.Events, Events = Matter.Events,
Composites = Matter.Composites, Composites = Matter.Composites,
Composite = Matter.Composite, Composite = Matter.Composite,

View File

@@ -13,6 +13,28 @@ const cat = {
phased: 0x100000000, phased: 0x100000000,
} }
const color = { //light
background: "#ddd",
block: "rgba(140,140,140,0.85)",
blockS: "#222",
map: "#444",
}
// const color = { //dark
// background: "#333",
// block: "#444",
// blockS: "#aab",
// map: "#556",
// bullet: "#fff"
// }
// const color = { //dark
// background: "#999",
// block: "#888",
// blockS: "#111",
// map: "#444",
// }
function shuffle(array) { function shuffle(array) {
var currentIndex = array.length, var currentIndex = array.length,
temporaryValue, temporaryValue,
@@ -170,7 +192,7 @@ const build = {
// level.onLevel++ // level.onLevel++
// } // }
// } // }
// for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]); // for (let i = 0; i < bullet.length; ++i) Matter.Composite.remove(engine.world, bullet[i]);
// bullet = []; //remove any bullets that might have spawned from tech // bullet = []; //remove any bullets that might have spawned from tech
// if (b.inventory.length > 0) { // if (b.inventory.length > 0) {
// b.activeGun = b.inventory[0] //set first gun to active gun // b.activeGun = b.inventory[0] //set first gun to active gun
@@ -342,6 +364,7 @@ const build = {
const techID = document.getElementById("tech-" + i) const techID = document.getElementById("tech-" + i)
if (!tech.tech[i].isExperimentHide && (!tech.tech[i].isNonRefundable || tech.tech[i].isExperimentalMode)) { if (!tech.tech[i].isExperimentHide && (!tech.tech[i].isNonRefundable || tech.tech[i].isExperimentalMode)) {
if (tech.tech[i].allowed() || isAllowed || tech.tech[i].count > 0) { if (tech.tech[i].allowed() || isAllowed || tech.tech[i].count > 0) {
// console.log(tech.tech[i].name, isAllowed, tech.tech[i].count, tech.haveGunCheck("nail gun"))
const isCount = tech.tech[i].count > 1 ? `(${tech.tech[i].count}x)` : ""; const isCount = tech.tech[i].count > 1 ? `(${tech.tech[i].count}x)` : "";
if (tech.tech[i].isFieldTech) { if (tech.tech[i].isFieldTech) {
@@ -537,7 +560,7 @@ const build = {
b.activeGun = b.inventory[0] //set first gun to active gun b.activeGun = b.inventory[0] //set first gun to active gun
simulation.makeGunHUD(); simulation.makeGunHUD();
} }
for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]); for (let i = 0; i < bullet.length; ++i) Matter.Composite.remove(engine.world, bullet[i]);
bullet = []; //remove any bullets that might have spawned from tech bullet = []; //remove any bullets that might have spawned from tech
const levelsCleared = Math.abs(Number(document.getElementById("starting-level").value) - 1) const levelsCleared = Math.abs(Number(document.getElementById("starting-level").value) - 1)
level.difficultyIncrease(Math.min(99, levelsCleared * simulation.difficultyMode)) //increase difficulty based on modes level.difficultyIncrease(Math.min(99, levelsCleared * simulation.difficultyMode)) //increase difficulty based on modes
@@ -547,7 +570,7 @@ const build = {
function removeOne() { //recursive remove one at a time to avoid array problems function removeOne() { //recursive remove one at a time to avoid array problems
for (let i = 0; i < powerUp.length; i++) { for (let i = 0; i < powerUp.length; i++) {
if (powerUp[i].name === "tech" || powerUp[i].name === "gun" || powerUp[i].name === "field") { if (powerUp[i].name === "tech" || powerUp[i].name === "gun" || powerUp[i].name === "field") {
Matter.World.remove(engine.world, powerUp[i]); Matter.Composite.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1); powerUp.splice(i, 1);
removeOne(); removeOne();
break break
@@ -928,7 +951,7 @@ window.addEventListener("keydown", function(event) {
body[index].collisionFilter.category = cat.body; body[index].collisionFilter.category = cat.body;
body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
body[index].classType = "body"; body[index].classType = "body";
World.add(engine.world, body[index]); //add to world Composite.add(engine.world, body[index]); //add to world
break break
case "7": case "7":
const pick = spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)]; const pick = spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)];

View File

@@ -13,12 +13,12 @@ const level = {
if (level.levelsCleared === 0) { //this code only runs on the first level if (level.levelsCleared === 0) { //this code only runs on the first level
// localSettings.levelsClearedLastGame = 10 // localSettings.levelsClearedLastGame = 10
// simulation.enableConstructMode() //used to build maps in testing mode // simulation.enableConstructMode() //used to build maps in testing mode
// level.difficultyIncrease(30) //30 is near max on hard //60 is near max on why // level.difficultyIncrease(10) //30 is near max on hard //60 is near max on why
// simulation.isHorizontalFlipped = true // simulation.isHorizontalFlipped = true
// tech.isFieldFree = true // tech.isFieldFree = true
// m.setField("time dilation") // m.setField("time dilation")
// b.giveGuns("nail gun") // b.giveGuns("rail gun")
// tech.giveTech("needle gun") // tech.giveTech("half-wave rectifier")
// b.giveGuns("wave beam") // b.giveGuns("wave beam")
// tech.giveTech("Lenz's law") // tech.giveTech("Lenz's law")
// for (let i = 0; i < 3; i++) tech.giveTech("packet length") // for (let i = 0; i < 3; i++) tech.giveTech("packet length")
@@ -86,7 +86,8 @@ const level = {
if (b.inventoryGun > b.inventory.length - 1) b.inventoryGun = 0; if (b.inventoryGun > b.inventory.length - 1) b.inventoryGun = 0;
simulation.switchGun(); simulation.switchGun();
} }
if (tech.isSwitchReality) { if (tech.isSwitchReality && powerUps.research.count > 0) {
powerUps.research.changeRerolls(-1);
simulation.makeTextLog(`simulation.amplitude <span class='color-symbol'>=</span> ${Math.random()}`); simulation.makeTextLog(`simulation.amplitude <span class='color-symbol'>=</span> ${Math.random()}`);
m.switchWorlds() m.switchWorlds()
simulation.trails() simulation.trails()
@@ -266,13 +267,13 @@ const level = {
body[i].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet body[i].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
} }
body[i].classType = "body"; body[i].classType = "body";
World.add(engine.world, body[i]); //add to world Composite.add(engine.world, body[i]); //add to world
} }
for (let i = 0; i < map.length; i++) { for (let i = 0; i < map.length; i++) {
map[i].collisionFilter.category = cat.map; map[i].collisionFilter.category = cat.map;
map[i].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; map[i].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet;
Matter.Body.setStatic(map[i], true); //make static Matter.Body.setStatic(map[i], true); //make static
World.add(engine.world, map[i]); //add to world Composite.add(engine.world, map[i]); //add to world
} }
}, },
spinner(x, y, width, height, density = 0.001, angle = 0, frictionAir = 0.001, angularVelocity = 0) { spinner(x, y, width, height, density = 0.001, angle = 0, frictionAir = 0.001, angularVelocity = 0) {
@@ -303,7 +304,7 @@ const level = {
stiffness: 1, stiffness: 1,
damping: 1 damping: 1
}); });
World.add(engine.world, constraint); Composite.add(engine.world, constraint);
return constraint return constraint
}, },
boost(x, y, height = 1000) { //height is how high the player will be flung above y boost(x, y, height = 1000) { //height is how high the player will be flung above y
@@ -445,10 +446,10 @@ const level = {
stiffness: 0.01, stiffness: 0.01,
damping: 0.3 damping: 0.3
}); });
World.add(engine.world, this.constraint); Composite.add(engine.world, this.constraint);
}, },
removeConstraint() { removeConstraint() {
World.remove(engine.world, this.constraint, true) Composite.remove(engine.world, this.constraint, true)
}, },
drawTrack() { drawTrack() {
ctx.fillStyle = "#ccc" ctx.fillStyle = "#ccc"
@@ -483,7 +484,7 @@ const level = {
stiffness: 0.1, stiffness: 0.1,
damping: 0.3 damping: 0.3
}); });
World.add(engine.world, constraint); Composite.add(engine.world, constraint);
constraint.plat = { constraint.plat = {
position: who.position, position: who.position,
speed: speed, speed: speed,
@@ -516,7 +517,7 @@ const level = {
x: x, x: x,
y: y y: y
}); });
World.add(engine.world, [rotor]); Composite.add(engine.world, [rotor]);
body[body.length] = rotor1 body[body.length] = rotor1
body[body.length] = rotor2 body[body.length] = rotor2
@@ -532,7 +533,7 @@ const level = {
}, },
bodyB: rotor bodyB: rotor
}); });
World.add(engine.world, constraint); Composite.add(engine.world, constraint);
if (rotate) { if (rotate) {
rotor.rotate = function() { rotor.rotate = function() {
@@ -580,7 +581,7 @@ const level = {
stiffness: 1, stiffness: 1,
length: 0 length: 0
}); });
World.add(engine.world, [cons[cons.length - 1]]); Composite.add(engine.world, [cons[cons.length - 1]]);
return { return {
flip: flip, flip: flip,
@@ -609,7 +610,7 @@ const level = {
ctx.fillStyle = "#3df" ctx.fillStyle = "#3df"
ctx.fill(); ctx.fill();
ctx.lineWidth = 1; ctx.lineWidth = 1;
ctx.strokeStyle = simulation.draw.bodyStroke; ctx.strokeStyle = color.blockS;
ctx.stroke(); ctx.stroke();
} }
}, },
@@ -795,7 +796,7 @@ const level = {
if (body[i].isInPortal === this) body[i].isInPortal = null if (body[i].isInPortal === this) body[i].isInPortal = null
} else if (body[i].isInPortal !== this) { //touching this portal, but for the first time } else if (body[i].isInPortal !== this) { //touching this portal, but for the first time
if (isRemoveBlocks) { if (isRemoveBlocks) {
Matter.World.remove(engine.world, body[i]); Matter.Composite.remove(engine.world, body[i]);
body.splice(i, 1); body.splice(i, 1);
break break
} }
@@ -829,7 +830,7 @@ const level = {
// if (body[j] === touching[i].bodyB) { // if (body[j] === touching[i].bodyB) {
// body.splice(j, 1); // body.splice(j, 1);
// len-- // len--
// Matter.World.remove(engine.world, touching[i].bodyB); // Matter.Composite.remove(engine.world, touching[i].bodyB);
// break; // break;
// } // }
// } // }
@@ -846,7 +847,7 @@ const level = {
// } // }
// } // }
// } // }
// Matter.World.remove(engine.world, touching[0].bodyB); // Matter.Composite.remove(engine.world, touching[0].bodyB);
// } // }
} }
@@ -869,13 +870,13 @@ const level = {
}, },
unit: unitA, unit: unitA,
angle: angleA, angle: angleA,
color: simulation.draw.mapFill, color: color.map,
draw: draw, draw: draw,
query: query, query: query,
lastPortalCycle: 0 lastPortalCycle: 0
}); });
Matter.Body.setStatic(mapA, true); //make static Matter.Body.setStatic(mapA, true); //make static
World.add(engine.world, mapA); //add to world Composite.add(engine.world, mapA); //add to world
const mapB = composite[composite.length] = Bodies.rectangle(centerB.x - 0.5 * unitB.x * mapWidth, centerB.y - 0.5 * unitB.y * mapWidth, mapWidth, height + 10, { const mapB = composite[composite.length] = Bodies.rectangle(centerB.x - 0.5 * unitB.x * mapWidth, centerB.y - 0.5 * unitB.y * mapWidth, mapWidth, height + 10, {
collisionFilter: { collisionFilter: {
@@ -884,13 +885,13 @@ const level = {
}, },
unit: unitB, unit: unitB,
angle: angleB, angle: angleB,
color: simulation.draw.mapFill, color: color.map,
draw: draw, draw: draw,
query: query, query: query,
lastPortalCycle: 0, lastPortalCycle: 0,
}); });
Matter.Body.setStatic(mapB, true); //make static Matter.Body.setStatic(mapB, true); //make static
World.add(engine.world, mapB); //add to world Composite.add(engine.world, mapB); //add to world
mapA.portal = portalA mapA.portal = portalA
mapB.portal = portalB mapB.portal = portalB
@@ -1041,7 +1042,7 @@ const level = {
stiffness: stiffness, stiffness: stiffness,
damping: damping damping: damping
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
} }
cons[cons.length] = Constraint.create({ //pin first block to a point in space cons[cons.length] = Constraint.create({ //pin first block to a point in space
pointA: { pointA: {
@@ -1052,7 +1053,7 @@ const level = {
stiffness: 1, stiffness: 1,
damping: damping damping: damping
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
if (isAttached) { if (isAttached) {
cons[cons.length] = Constraint.create({ //pin last block to a point in space cons[cons.length] = Constraint.create({ //pin last block to a point in space
pointA: { pointA: {
@@ -1063,7 +1064,7 @@ const level = {
stiffness: 1, stiffness: 1,
damping: damping damping: damping
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
} }
}, },
//****************************************************************************************************************** //******************************************************************************************************************
@@ -1074,7 +1075,7 @@ const level = {
level.isProcedural = true //used in generating text itn he level builder level.isProcedural = true //used in generating text itn he level builder
level.defaultZoom = 1700 level.defaultZoom = 1700
simulation.zoomTransition(level.defaultZoom) simulation.zoomTransition(level.defaultZoom)
document.body.style.backgroundColor = "#dcdcdf"; document.body.style.backgroundColor = "#d9d9de" //"#d3d3db" //"#dcdcdf";
let isDoorLeft, isDoorRight, x, y let isDoorLeft, isDoorRight, x, y
doCustom = [] doCustom = []
doCustomTopLayer = [] doCustomTopLayer = []
@@ -1361,11 +1362,11 @@ const level = {
body[index].collisionFilter.category = cat.body; body[index].collisionFilter.category = cat.body;
body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
body[index].classType = "body"; body[index].classType = "body";
World.add(engine.world, body[index]); //add to world Composite.add(engine.world, body[index]); //add to world
setTimeout(() => { //remove block setTimeout(() => { //remove block
for (let i = 0; i < body.length; i++) { for (let i = 0; i < body.length; i++) {
if (body[i] === bodyBullet) { if (body[i] === bodyBullet) {
Matter.World.remove(engine.world, body[i]); Matter.Composite.remove(engine.world, body[i]);
body.splice(i, 1); body.splice(i, 1);
} }
} }
@@ -1418,11 +1419,11 @@ const level = {
body[index].collisionFilter.category = cat.body; body[index].collisionFilter.category = cat.body;
body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
body[index].classType = "body"; body[index].classType = "body";
World.add(engine.world, body[index]); //add to world Composite.add(engine.world, body[index]); //add to world
setTimeout(() => { //remove block setTimeout(() => { //remove block
for (let i = 0; i < body.length; i++) { for (let i = 0; i < body.length; i++) {
if (body[i] === bodyBullet) { if (body[i] === bodyBullet) {
Matter.World.remove(engine.world, body[i]); Matter.Composite.remove(engine.world, body[i]);
body.splice(i, 1); body.splice(i, 1);
} }
} }
@@ -1787,7 +1788,7 @@ const level = {
// who.collisionFilter.category = cat.map; // who.collisionFilter.category = cat.map;
// who.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; // who.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet;
// Matter.Body.setStatic(who, true); //make static // Matter.Body.setStatic(who, true); //make static
// World.add(engine.world, who); //add to world // Composite.add(engine.world, who); //add to world
// } // }
// const numberOfMapElementsAdded = 0 // const numberOfMapElementsAdded = 0
// for (let i = 0; i < numberOfMapElementsAdded; i++) addMapToLevelInProgress(map[map.length - 1 - i]) // for (let i = 0; i < numberOfMapElementsAdded; i++) addMapToLevelInProgress(map[map.length - 1 - i])
@@ -1821,7 +1822,7 @@ const level = {
who.collisionFilter.category = cat.map; who.collisionFilter.category = cat.map;
who.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; who.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet;
Matter.Body.setStatic(who, true); //make static Matter.Body.setStatic(who, true); //make static
World.add(engine.world, who); //add to world Composite.add(engine.world, who); //add to world
} }
let r = 150 let r = 150
let hexagon = `${r} 0 ${r*Math.cos(5.236)} ${r*Math.sin(5.236)} ${r*Math.cos(4.189)} ${r*Math.sin(4.189)} ${-r} 0 ${r*Math.cos(2.0944)} ${r*Math.sin(2.0944)} ${r*Math.cos(1.0472)} ${r*Math.sin(1.0472)} ` let hexagon = `${r} 0 ${r*Math.cos(5.236)} ${r*Math.sin(5.236)} ${r*Math.cos(4.189)} ${r*Math.sin(4.189)} ${-r} 0 ${r*Math.cos(2.0944)} ${r*Math.sin(2.0944)} ${r*Math.cos(1.0472)} ${r*Math.sin(1.0472)} `
@@ -1908,7 +1909,7 @@ const level = {
who.collisionFilter.category = cat.map; who.collisionFilter.category = cat.map;
who.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; who.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet;
Matter.Body.setStatic(who, true); //make static Matter.Body.setStatic(who, true); //make static
World.add(engine.world, who); //add to world Composite.add(engine.world, who); //add to world
} }
//right side hexagons //right side hexagons
let r = 300 let r = 300
@@ -2040,7 +2041,7 @@ const level = {
} }
} }
let rows = [ let columns = [
() => { () => {
offset.y = 0 offset.y = 0
outlineUpDown() outlineUpDown()
@@ -2065,7 +2066,7 @@ const level = {
rooms[3]() rooms[3]()
}, },
] ]
rows = shuffle(rows) //********************************* RUN THIS LINE IN THE FINAL VERSION *************************************** columns = shuffle(columns) //********************************* RUN THIS LINE IN THE FINAL VERSION ***************************************
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
if (i === 0) { if (i === 0) {
isDoorLeft = false isDoorLeft = false
@@ -2078,7 +2079,7 @@ const level = {
isDoorRight = false isDoorRight = false
} }
offset.x = i * 2100 offset.x = i * 2100
rows[i]() columns[i]()
} }
level.custom = () => { level.custom = () => {
for (let i = 0, len = doCustom.length; i < len; i++) doCustom[i]() //runs all the active code from each room for (let i = 0, len = doCustom.length; i < len; i++) doCustom[i]() //runs all the active code from each room
@@ -2187,7 +2188,7 @@ const level = {
level.setPosToSpawn(0, -50); //normal spawn level.setPosToSpawn(0, -50); //normal spawn
spawn.mapRect(level.enter.x, level.enter.y + 25, 100, 10); spawn.mapRect(level.enter.x, level.enter.y + 25, 100, 10);
level.exit.x = 0; level.exit.x = 0;
level.exit.y = 400; level.exit.y = 40000;
level.defaultZoom = 1000 level.defaultZoom = 1000
simulation.zoomTransition(level.defaultZoom) simulation.zoomTransition(level.defaultZoom)
// document.body.style.backgroundColor = "#aaa"; // document.body.style.backgroundColor = "#aaa";
@@ -2230,7 +2231,7 @@ const level = {
spawn.setSpawnList(); spawn.setSpawnList();
level.defaultZoom = 1500 level.defaultZoom = 1500
simulation.zoomTransition(level.defaultZoom) simulation.zoomTransition(level.defaultZoom)
document.body.style.backgroundColor = "#ddd"; document.body.style.backgroundColor = color.background //"#ddd";
// simulation.draw.mapFill = "#444" // simulation.draw.mapFill = "#444"
// simulation.draw.bodyFill = "rgba(140,140,140,0.85)" // simulation.draw.bodyFill = "rgba(140,140,140,0.85)"
// simulation.draw.bodyStroke = "#222" // simulation.draw.bodyStroke = "#222"
@@ -2241,7 +2242,7 @@ const level = {
spawn.mapRect(-950, -1800, 8200, 800); //roof spawn.mapRect(-950, -1800, 8200, 800); //roof
spawn.mapRect(-250, -400, 1000, 600); // shelf spawn.mapRect(-250, -400, 1000, 600); // shelf
spawn.mapRect(-250, -1200, 1000, 550); // shelf roof spawn.mapRect(-250, -1200, 1000, 550); // shelf roof
// powerUps.spawnStartingPowerUps(600, -800); powerUps.spawnStartingPowerUps(600, -800);
// for (let i = 0; i < 50; ++i) powerUps.spawn(550, -800, "research", false); // for (let i = 0; i < 50; ++i) powerUps.spawn(550, -800, "research", false);
// powerUps.spawn(350, -800, "gun", false); // powerUps.spawn(350, -800, "gun", false);
@@ -2270,11 +2271,11 @@ const level = {
spawn.mapRect(5300, -275, 50, 175); spawn.mapRect(5300, -275, 50, 175);
spawn.mapRect(5050, -100, 50, 150); spawn.mapRect(5050, -100, 50, 150);
spawn.mapRect(4850, -275, 50, 175); spawn.mapRect(4850, -275, 50, 175);
spawn.starter(1900, -500, 200) //big boy // spawn.starter(1900, -500, 200) //big boy
// spawn.growBossCulture(1900, -500) // spawn.growBossCulture(1900, -500)
// spawn.blinkBoss(1900, -500) // spawn.blinkBoss(1900, -500)
// spawn.snakeBoss(1900, -500) // spawn.snakeBoss(1900, -500)
// spawn.grenadierBoss(1900, -500) // spawn.growBossCulture(1900, -500)
// spawn.sneaker(1900, -500) // spawn.sneaker(1900, -500)
// spawn.historyBoss(1200, -500) // spawn.historyBoss(1200, -500)
// spawn.laserTargetingBoss(1600, -400) // spawn.laserTargetingBoss(1600, -400)
@@ -2285,7 +2286,7 @@ const level = {
// spawn.streamBoss(1600, -500) // spawn.streamBoss(1600, -500)
// spawn.powerUpBoss(1600, -500) // spawn.powerUpBoss(1600, -500)
// spawn.cellBossCulture(1600, -500) // spawn.cellBossCulture(1600, -500)
// spawn.shieldingBoss(1600, -500) spawn.shieldingBoss(1600, -500)
// spawn.grenadier(1200, -500) // spawn.grenadier(1200, -500)
// spawn.shield(mob[mob.length - 1], 1800, -120, 1); // spawn.shield(mob[mob.length - 1], 1800, -120, 1);
@@ -2718,7 +2719,7 @@ const level = {
if (!(m.cycle % 60)) { //so much work to catch blocks caught at the bottom of the vertical portals if (!(m.cycle % 60)) { //so much work to catch blocks caught at the bottom of the vertical portals
let touching = Matter.Query.collides(map[removeIndex1], body) let touching = Matter.Query.collides(map[removeIndex1], body)
if (touching.length) { if (touching.length) {
Matter.World.remove(engine.world, touching[0].bodyB); Matter.Composite.remove(engine.world, touching[0].bodyB);
for (let i = 0, len = body.length; i < len; i++) { for (let i = 0, len = body.length; i < len; i++) {
if (body[i].id === touching[0].bodyB.id) { if (body[i].id === touching[0].bodyB.id) {
body.splice(i, 1); body.splice(i, 1);
@@ -2728,7 +2729,7 @@ const level = {
} }
touching = Matter.Query.collides(map[removeIndex2], body) touching = Matter.Query.collides(map[removeIndex2], body)
if (touching.length) { if (touching.length) {
Matter.World.remove(engine.world, touching[0].bodyB); Matter.Composite.remove(engine.world, touching[0].bodyB);
for (let i = 0, len = body.length; i < len; i++) { for (let i = 0, len = body.length; i < len; i++) {
if (body[i].id === touching[0].bodyB.id) { if (body[i].id === touching[0].bodyB.id) {
body.splice(i, 1); body.splice(i, 1);
@@ -3981,7 +3982,7 @@ const level = {
powerUps.spawn(-4200, -700, "ammo"); powerUps.spawn(-4200, -700, "ammo");
powerUps.spawn(-4000, -700, "ammo"); powerUps.spawn(-4000, -700, "ammo");
spawn.mapRect(-4450, -1000, 100, 500); spawn.mapRect(-4450, -1000, 100, 500);
spawn.bodyRect(-3500, -750, 150, 150); spawn.bodyRect(-3300, -750, 150, 150);
//building 1 //building 1
spawn.bodyRect(-1000, -675, 25, 25); spawn.bodyRect(-1000, -675, 25, 25);
@@ -4317,7 +4318,7 @@ const level = {
stiffness: 0.0001815, stiffness: 0.0001815,
length: 1 length: 1
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
spawn.bodyRect(600, 525, 125, 125, 1, spawn.propsSlide); //weight spawn.bodyRect(600, 525, 125, 125, 1, spawn.propsSlide); //weight
spawn.bodyRect(800, 600, 300, 100, 1, spawn.propsHoist); //hoist spawn.bodyRect(800, 600, 300, 100, 1, spawn.propsHoist); //hoist
@@ -4330,7 +4331,7 @@ const level = {
stiffness: 0.0001815, stiffness: 0.0001815,
length: 1 length: 1
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
spawn.bodyRect(-2700, 1150, 100, 160, 1, spawn.propsSlide); //weight spawn.bodyRect(-2700, 1150, 100, 160, 1, spawn.propsSlide); //weight
spawn.bodyRect(-2550, 1150, 200, 100, 1, spawn.propsSlide); //weight spawn.bodyRect(-2550, 1150, 200, 100, 1, spawn.propsSlide); //weight
@@ -4344,7 +4345,7 @@ const level = {
stiffness: 0.0005, stiffness: 0.0005,
length: 566 length: 566
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
} }
//blocks //blocks
spawn.bodyRect(-165, -150, 30, 35, 1); spawn.bodyRect(-165, -150, 30, 35, 1);
@@ -4569,7 +4570,7 @@ const level = {
bodyB: map[map.length - 1], bodyB: map[map.length - 1],
stiffness: 1 stiffness: 1
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
spawn.mapRect(-600 + 300, -2000 * 0.75, 1900, 50); //3rd floor spawn.mapRect(-600 + 300, -2000 * 0.75, 1900, 50); //3rd floor
spawn.mapRect(-600 + 2000 * 0.7, -2000 * 0.74, 50, 375); //center wall spawn.mapRect(-600 + 2000 * 0.7, -2000 * 0.74, 50, 375); //center wall
spawn.bodyRect(-600 + 2000 * 0.7, -2000 * 0.5 - 106, 50, 106); //center block under wall spawn.bodyRect(-600 + 2000 * 0.7, -2000 * 0.5 - 106, 50, 106); //center block under wall
@@ -4757,7 +4758,7 @@ const level = {
stiffness: 0.0002, //1217, stiffness: 0.0002, //1217,
length: 200 length: 200
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
spawn.bodyRect(2799, -870, 310, 290); //Gros bloc angle toit spawn.bodyRect(2799, -870, 310, 290); //Gros bloc angle toit
spawn.mapRect(4000, -1750, 50, 400); //Right Wall Cuve spawn.mapRect(4000, -1750, 50, 400); //Right Wall Cuve
@@ -4806,7 +4807,7 @@ const level = {
bodyB: map[map.length - 1], bodyB: map[map.length - 1],
stiffness: 1 stiffness: 1
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
spawn.bodyRect(650, 50, 70, 50); spawn.bodyRect(650, 50, 70, 50);
spawn.bodyRect(300, 0, 100, 60); spawn.bodyRect(300, 0, 100, 60);
spawn.bodyRect(400, 0, 100, 150); spawn.bodyRect(400, 0, 100, 150);
@@ -4996,7 +4997,7 @@ const level = {
stiffness: 0.00014, stiffness: 0.00014,
length: 120 length: 120
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
spawn.bodyRect(0, -1250, 240, 190) //Fat cube ascenseur spawn.bodyRect(0, -1250, 240, 190) //Fat cube ascenseur
} else { /// Reversed spawn } else { /// Reversed spawn
spawn.bodyRect(0, -650, 225, 175); spawn.bodyRect(0, -650, 225, 175);
@@ -5199,7 +5200,7 @@ const level = {
map[len].collisionFilter.category = cat.map; map[len].collisionFilter.category = cat.map;
map[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; map[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet;
Matter.Body.setStatic(map[len], true); //make static Matter.Body.setStatic(map[len], true); //make static
World.add(engine.world, map[len]); //add to world Composite.add(engine.world, map[len]); //add to world
simulation.draw.setPaths() //update map graphics simulation.draw.setPaths() //update map graphics
} }
@@ -5208,7 +5209,7 @@ const level = {
len = body.length - 1 len = body.length - 1
body[len].collisionFilter.category = cat.body; body[len].collisionFilter.category = cat.body;
body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
World.add(engine.world, body[len]); //add to world Composite.add(engine.world, body[len]); //add to world
body[len].classType = "body" body[len].classType = "body"
} }
@@ -5656,8 +5657,8 @@ const level = {
chair2 = Body.create({ chair2 = Body.create({
parts: [part4, part5, part6], parts: [part4, part5, part6],
}); });
World.add(engine.world, [chair]); Composite.add(engine.world, [chair]);
World.add(engine.world, [chair2]); Composite.add(engine.world, [chair2]);
composite[composite.length] = chair; composite[composite.length] = chair;
composite[composite.length] = chair2; composite[composite.length] = chair2;
body[body.length] = part1; body[body.length] = part1;
@@ -5712,7 +5713,7 @@ const level = {
rightLowerLeg, leftUpperLeg, rightUpperLeg rightLowerLeg, leftUpperLeg, rightUpperLeg
], ],
}); });
World.add(engine.world, [person]); Composite.add(engine.world, [person]);
composite[composite.length] = person composite[composite.length] = person
body[body.length] = chest body[body.length] = chest
body[body.length] = head body[body.length] = head
@@ -5773,7 +5774,7 @@ const level = {
bodyB: map[map.length - 1], bodyB: map[map.length - 1],
stiffness: 1 stiffness: 1
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
//table + chaises //table + chaises
spawn.mapRect(4025, -850, 50, 175); spawn.mapRect(4025, -850, 50, 175);
@@ -6371,23 +6372,23 @@ const level = {
//Boss Spawning //Boss Spawning
if (simulation.difficulty > 10) { if (simulation.difficulty > 10) {
spawn.pulsarBoss(-400, -200); spawn.pulsarBoss(3600, -400);
powerUps.chooseRandomPowerUp(4006, 400); powerUps.chooseRandomPowerUp(4006, 400);
powerUps.chooseRandomPowerUp(4407, 400); powerUps.chooseRandomPowerUp(4407, 400);
powerUps.spawnStartingPowerUps(4400, 400); powerUps.spawnStartingPowerUps(4400, 400);
if (simulation.difficulty > 30) { if (simulation.difficulty > 30) {
powerUps.chooseRandomPowerUp(4002, 400); powerUps.chooseRandomPowerUp(4002, 400);
powerUps.chooseRandomPowerUp(4004, 400); powerUps.chooseRandomPowerUp(4004, 400);
spawn.pulsarBoss(3600, -400); spawn.pulsarBoss(4200, 1000);
if (simulation.difficulty > 60) { if (simulation.difficulty > 60) {
powerUps.chooseRandomPowerUp(4409, 400); powerUps.chooseRandomPowerUp(4409, 400);
spawn.pulsarBoss(4200, 1000); spawn.pulsarBoss(5800, -1200);
if (simulation.difficulty > 80) { if (simulation.difficulty > 80) {
spawn.pulsarBoss(5800, -1200); spawn.pulsarBoss(-400, -200);
if (simulation.difficulty > 100) { if (simulation.difficulty > 100) {
spawn.pulsarBoss(-400, -200); spawn.pulsarBoss(3600, -400);
if (simulation.difficulty > 120) { if (simulation.difficulty > 120) {
spawn.pulsarBoss(3600, -400); spawn.pulsarBoss(-400, -200);
} }
} }
} }
@@ -6541,7 +6542,7 @@ const level = {
stiffness: 0.005, stiffness: 0.005,
length: 700 length: 700
}); });
World.add(engine.world, [cons[cons.length - 2], cons[cons.length - 1]]); Composite.add(engine.world, [cons[cons.length - 2], cons[cons.length - 1]]);
spawn.bodyRect(5225, -2525, 300, 75); spawn.bodyRect(5225, -2525, 300, 75);
spawn.bodyRect(4700, -2525, 100, 75, 0.5); spawn.bodyRect(4700, -2525, 100, 75, 0.5);
@@ -6649,7 +6650,7 @@ const level = {
stiffness: 0.002, stiffness: 0.002,
length: 1000 length: 1000
}); });
World.add(engine.world, [cons[cons.length - 1], cons[cons.length - 2]]) Composite.add(engine.world, [cons[cons.length - 1], cons[cons.length - 2]])
} }
const boost1 = level.boost(4400, -1385, 1200) const boost1 = level.boost(4400, -1385, 1200)
@@ -6663,7 +6664,7 @@ const level = {
if (!buttonGreen.isUp) { if (!buttonGreen.isUp) {
if (!g) { if (!g) {
Matter.World.remove(engine.world, cons[1]) Matter.Composite.remove(engine.world, cons[1])
cons.splice(1, 2) cons.splice(1, 2)
} }
g = true; g = true;
@@ -6715,7 +6716,7 @@ const level = {
body[len] = Matter.Bodies.polygon(Math.floor(Math.random() * 1700) + 1050, 100, Math.floor(Math.random() * 11) + 10, Math.floor(Math.random() * 20) + 15) body[len] = Matter.Bodies.polygon(Math.floor(Math.random() * 1700) + 1050, 100, Math.floor(Math.random() * 11) + 10, Math.floor(Math.random() * 20) + 15)
body[len].collisionFilter.category = cat.body; body[len].collisionFilter.category = cat.body;
body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet; body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet;
World.add(engine.world, body[len]) Composite.add(engine.world, body[len])
nextBlockSpawn = simulation.cycle + Math.floor(Math.random() * 60 + 30) nextBlockSpawn = simulation.cycle + Math.floor(Math.random() * 60 + 30)
} }
@@ -6738,7 +6739,7 @@ const level = {
y: slowY * body[i].velocity.y y: slowY * body[i].velocity.y
}); });
if (body[i].mass < 0.05) { if (body[i].mass < 0.05) {
Matter.World.remove(engine.world, body[i]) Matter.Composite.remove(engine.world, body[i])
body.splice(i, 1) body.splice(i, 1)
break break
} }
@@ -7169,7 +7170,7 @@ const level = {
const compoundParts = Body.create({ const compoundParts = Body.create({
parts: [part1, part2, part3], parts: [part1, part2, part3],
}); });
World.add(engine.world, [compoundParts]); Composite.add(engine.world, [compoundParts]);
needGravity[needGravity.length] = compoundParts; needGravity[needGravity.length] = compoundParts;
composite[composite.length] = compoundParts; composite[composite.length] = compoundParts;
body[body.length] = part1; body[body.length] = part1;
@@ -7198,7 +7199,7 @@ const level = {
}, },
stiffness: stiff stiffness: stiff
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
} }
//I SINCERELY APOLOGIZE FOR THE ILLEGIBLE BLOCKS OF STRING CONCATENATION //I SINCERELY APOLOGIZE FOR THE ILLEGIBLE BLOCKS OF STRING CONCATENATION

View File

@@ -305,7 +305,7 @@ const lore = {
lore.talkingColor = "#dff" lore.talkingColor = "#dff"
level.isHazardRise = true level.isHazardRise = true
//remove all bullets, so they can't get endless energy //remove all bullets, so they can't get endless energy
for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]); for (let i = 0; i < bullet.length; ++i) Matter.Composite.remove(engine.world, bullet[i]);
bullet = []; bullet = [];
setTimeout(() => { lore.anand.text("I'm actually surprised you haven't been attacked by the adversarial network this time.") }, 500); setTimeout(() => { lore.anand.text("I'm actually surprised you haven't been attacked by the adversarial network this time.") }, 500);
}, },
@@ -401,7 +401,7 @@ const lore = {
}, },
() => { () => {
lore.talkingColor = "#dff"; lore.talkingColor = "#dff";
setTimeout(() => { lore.anand.text("hurry back!") }, 1000); setTimeout(() => { lore.anand.text("Hurry back!") }, 1000);
}, },
() => { lore.talkingColor = "#dff" }, () => { lore.talkingColor = "#dff" },
], ],

View File

@@ -222,7 +222,6 @@ const mobs = {
alive: true, alive: true,
index: i, index: i,
health: tech.mobSpawnWithHealth, health: tech.mobSpawnWithHealth,
damageReduction: 1,
showHealthBar: true, showHealthBar: true,
accelMag: 0.001 * simulation.accelScale, accelMag: 0.001 * simulation.accelScale,
cd: 0, //game cycle when cooldown will be over cd: 0, //game cycle when cooldown will be over
@@ -1042,8 +1041,10 @@ const mobs = {
if (tech.isFarAwayDmg) dmg *= 1 + Math.sqrt(Math.max(500, Math.min(3000, this.distanceToPlayer())) - 500) * 0.0067 //up to 50% dmg at max range of 3500 if (tech.isFarAwayDmg) dmg *= 1 + Math.sqrt(Math.max(500, Math.min(3000, this.distanceToPlayer())) - 500) * 0.0067 //up to 50% dmg at max range of 3500
// if (this.shield) dmg *= 0.075 // if (this.shield) dmg *= 0.075
// if (this.isBoss) dmg *= 0.25 // if (this.isBoss) dmg *= 0.25
dmg *= this.damageReduction if (this.damageReduction < 1) { //only used for bosses with this.armor() or shields
this.damageReductionGoal += dmg * this.damageReductionScale //reduce damageReductionGoal
dmg *= this.damageReduction
}
//energy and heal drain should be calculated after damage boosts //energy and heal drain should be calculated after damage boosts
if (tech.energySiphon && dmg !== Infinity && this.isDropPowerUp && m.immuneCycle < m.cycle) m.energy += Math.min(this.health, dmg) * tech.energySiphon if (tech.energySiphon && dmg !== Infinity && this.isDropPowerUp && m.immuneCycle < m.cycle) m.energy += Math.min(this.health, dmg) * tech.energySiphon
if (tech.healthDrain && dmg !== Infinity && this.isDropPowerUp) { if (tech.healthDrain && dmg !== Infinity && this.isDropPowerUp) {
@@ -1067,6 +1068,20 @@ const mobs = {
// a placeholder for custom effects on mob death // a placeholder for custom effects on mob death
// to use declare custom method in mob spawn // to use declare custom method in mob spawn
}, },
damageReduction: 1,
damageReductionGoal: 0.001, //must add this to boss set up: me.damageReduction = me.damageReductionGoal
damageReductionScale: 0.004, //for bosses in this.onDamage determines the impact of dmg on damageReductionGoal
armor() { //slowly reduce damage reduction, for bosses
if (this.seePlayer.recall) {
if (this.damageReductionGoal > 0.24) {
this.damageReductionGoal = 0.25
} else {
this.damageReductionGoal = this.damageReductionGoal * 0.999 + 0.001 * 0.25 //smooth the goal towards 0.25 damage reduction
}
this.damageReduction = this.damageReduction * 0.995 + 0.005 * this.damageReductionGoal //smooth damage reduction towards the goal
// console.log(`damageReduction = ${this.damageReduction.toFixed(4)}`, `damageReductionGoal = ${this.damageReductionGoal.toFixed(4)}`)
}
},
leaveBody: true, leaveBody: true,
isDropPowerUp: true, isDropPowerUp: true,
death() { death() {
@@ -1217,7 +1232,7 @@ const mobs = {
// body[len].collisionFilter.mask = cat.player | cat.bullet | cat.mob | cat.mobBullet; // body[len].collisionFilter.mask = cat.player | cat.bullet | cat.mob | cat.mobBullet;
// } // }
body[len].classType = "body"; body[len].classType = "body";
World.add(engine.world, body[len]); //add to world Composite.add(engine.world, body[len]); //add to world
//large mobs shrink so they don't block paths //large mobs shrink so they don't block paths
if (body[len].mass > 9) { if (body[len].mass > 9) {
@@ -1230,7 +1245,7 @@ const mobs = {
}; };
shrink(body[len], 7 + 4 * Math.random()) shrink(body[len], 7 + 4 * Math.random())
} }
Matter.World.remove(engine.world, this); Matter.Composite.remove(engine.world, this);
mob.splice(i, 1); mob.splice(i, 1);
if (tech.isMobBlockFling) { if (tech.isMobBlockFling) {
const who = body[body.length - 1] const who = body[body.length - 1]
@@ -1238,12 +1253,12 @@ const mobs = {
Matter.Body.setAngularVelocity(who, (0.5 + 0.2 * Math.random()) * (Math.random() < 0.5 ? -1 : 1)); Matter.Body.setAngularVelocity(who, (0.5 + 0.2 * Math.random()) * (Math.random() < 0.5 ? -1 : 1));
} }
} else { } else {
Matter.World.remove(engine.world, this); Matter.Composite.remove(engine.world, this);
mob.splice(i, 1); mob.splice(i, 1);
} }
} }
}); });
mob[i].alertRange2 = Math.pow(mob[i].radius * 3 + 550, 2); mob[i].alertRange2 = Math.pow(mob[i].radius * 3 + 550, 2);
World.add(engine.world, mob[i]); //add to world Composite.add(engine.world, mob[i]); //add to world
} }
}; };

View File

@@ -39,7 +39,7 @@ const m = {
} }
}); });
Matter.Body.setMass(player, m.mass); Matter.Body.setMass(player, m.mass);
World.add(engine.world, [player]); Composite.add(engine.world, [player]);
}, },
cycle: 600, //starts at 600 cycles instead of 0 to prevent bugs with m.history cycle: 600, //starts at 600 cycles instead of 0 to prevent bugs with m.history
lastKillCycle: 0, lastKillCycle: 0,
@@ -331,7 +331,7 @@ const m = {
const randomBotCount = b.totalBots() const randomBotCount = b.totalBots()
b.zeroBotCount() b.zeroBotCount()
//remove all bullets, respawn bots //remove all bullets, respawn bots
for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]); for (let i = 0; i < bullet.length; ++i) Matter.Composite.remove(engine.world, bullet[i]);
bullet = []; bullet = [];
//randomize health //randomize health
@@ -437,7 +437,7 @@ const m = {
document.getElementById("fade-out").style.opacity = 1; //slowly fades out document.getElementById("fade-out").style.opacity = 1; //slowly fades out
// build.shareURL(false) // build.shareURL(false)
setTimeout(function() { setTimeout(function() {
World.clear(engine.world); Composite.clear(engine.world);
Engine.clear(engine); Engine.clear(engine);
simulation.splashReturn(); simulation.splashReturn();
}, 3000); }, 3000);
@@ -650,6 +650,7 @@ const m = {
ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillRect(0, 0, canvas.width, canvas.height);
} }
setTimeout(function() { setTimeout(function() {
tech.maxDuplicationEvent()
simulation.wipe = function() { //set wipe to normal simulation.wipe = function() { //set wipe to normal
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.clearRect(0, 0, canvas.width, canvas.height);
} }
@@ -679,6 +680,7 @@ const m = {
ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillRect(0, 0, canvas.width, canvas.height);
} }
setTimeout(function() { setTimeout(function() {
tech.maxDuplicationEvent()
simulation.wipe = function() { //set wipe to normal simulation.wipe = function() { //set wipe to normal
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.clearRect(0, 0, canvas.width, canvas.height);
} }
@@ -1130,7 +1132,7 @@ const m = {
//remove block before pulse, so it doesn't get in the way //remove block before pulse, so it doesn't get in the way
for (let i = 0; i < body.length; i++) { for (let i = 0; i < body.length; i++) {
if (body[i] === m.holdingTarget) { if (body[i] === m.holdingTarget) {
Matter.World.remove(engine.world, body[i]); Matter.Composite.remove(engine.world, body[i]);
body.splice(i, 1); body.splice(i, 1);
} }
} }
@@ -1264,7 +1266,7 @@ const m = {
y: player.velocity.y + powerUp[i].velocity.y / player.mass * 5 y: player.velocity.y + powerUp[i].velocity.y / player.mass * 5
}); });
powerUp[i].effect(); powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]); Matter.Composite.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1); powerUp.splice(i, 1);
return; //because the array order is messed up after splice return; //because the array order is messed up after splice
} }
@@ -2495,7 +2497,7 @@ const m = {
) { //use power up if it is close enough ) { //use power up if it is close enough
powerUps.onPickUp(powerUp[i]); powerUps.onPickUp(powerUp[i]);
powerUp[i].effect(); powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]); Matter.Composite.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1); powerUp.splice(i, 1);
// m.fieldRadius += 50 // m.fieldRadius += 50
break; //because the array order is messed up after splice break; //because the array order is messed up after splice
@@ -2605,9 +2607,9 @@ const m = {
}, },
{ {
name: "wormhole", name: "wormhole",
description: "use <strong class='color-f'>energy</strong> to <strong>tunnel</strong> through a <strong class='color-worm'>wormhole</strong><br><strong class='color-worm'>wormholes</strong> attract <strong class='color-block'>blocks</strong> and power ups<br><strong>11%</strong> chance to <strong class='color-dup'>duplicate</strong> spawned <strong>power ups</strong>", //<br>bullets may also traverse <strong class='color-worm'>wormholes</strong> description: "use <strong class='color-f'>energy</strong> to <strong>tunnel</strong> through a <strong class='color-worm'>wormhole</strong><br><strong class='color-worm'>wormholes</strong> attract <strong class='color-block'>blocks</strong> and power ups<br><strong>9%</strong> chance to <strong class='color-dup'>duplicate</strong> spawned <strong>power ups</strong>", //<br>bullets may also traverse <strong class='color-worm'>wormholes</strong>
effect: function() { effect: function() {
m.duplicateChance = 0.11 m.duplicateChance = 0.09
powerUps.setDo(); //needed after adjusting duplication chance powerUps.setDo(); //needed after adjusting duplication chance
m.hold = function() { m.hold = function() {
@@ -2667,7 +2669,7 @@ const m = {
m.fieldRange *= 0.8 m.fieldRange *= 0.8
powerUps.onPickUp(powerUp[i]); powerUps.onPickUp(powerUp[i]);
powerUp[i].effect(); powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]); Matter.Composite.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1); powerUp.splice(i, 1);
break; //because the array order is messed up after splice break; //because the array order is messed up after splice
} }
@@ -2691,7 +2693,7 @@ const m = {
if (Vector.magnitude(Vector.sub(m.hole.pos1, body[i].position)) < shrinkRange) { if (Vector.magnitude(Vector.sub(m.hole.pos1, body[i].position)) < shrinkRange) {
Matter.Body.scale(body[i], shrinkScale, shrinkScale); Matter.Body.scale(body[i], shrinkScale, shrinkScale);
if (body[i].mass < 0.05) { if (body[i].mass < 0.05) {
Matter.World.remove(engine.world, body[i]); Matter.Composite.remove(engine.world, body[i]);
body.splice(i, 1); body.splice(i, 1);
m.fieldRange *= 0.8 m.fieldRange *= 0.8
if (tech.isWormholeEnergy) m.energy += 0.63 if (tech.isWormholeEnergy) m.energy += 0.63
@@ -2724,7 +2726,7 @@ const m = {
if (Vector.magnitude(Vector.sub(m.hole.pos2, body[i].position)) < shrinkRange) { if (Vector.magnitude(Vector.sub(m.hole.pos2, body[i].position)) < shrinkRange) {
Matter.Body.scale(body[i], shrinkScale, shrinkScale); Matter.Body.scale(body[i], shrinkScale, shrinkScale);
if (body[i].mass < 0.05) { if (body[i].mass < 0.05) {
Matter.World.remove(engine.world, body[i]); Matter.Composite.remove(engine.world, body[i]);
body.splice(i, 1); body.splice(i, 1);
m.fieldRange *= 0.8 m.fieldRange *= 0.8
// if (tech.isWormholeEnergy && m.energy < m.maxEnergy * 2) m.energy = m.maxEnergy * 2 // if (tech.isWormholeEnergy && m.energy < m.maxEnergy * 2) m.energy = m.maxEnergy * 2
@@ -2911,7 +2913,7 @@ const m = {
// if (dxP * dxP + dyP * dyP < 50000 && !simulation.isChoosing && !(m.health === m.maxHealth && powerUp[i].name === "heal")) { // if (dxP * dxP + dyP * dyP < 50000 && !simulation.isChoosing && !(m.health === m.maxHealth && powerUp[i].name === "heal")) {
// powerUps.onPickUp(player.position); // powerUps.onPickUp(player.position);
// powerUp[i].effect(); // powerUp[i].effect();
// Matter.World.remove(engine.world, powerUp[i]); // Matter.Composite.remove(engine.world, powerUp[i]);
// powerUp.splice(i, 1); // powerUp.splice(i, 1);
// const shortPause = function() { // const shortPause = function() {
// if (m.defaultFPSCycle < m.cycle) { //back to default values // if (m.defaultFPSCycle < m.cycle) { //back to default values

View File

@@ -83,7 +83,7 @@ const powerUps = {
for (let i = 0, len = powerUp.length; i < len; ++i) { for (let i = 0, len = powerUp.length; i < len; ++i) {
if (powerUp[i].isDuplicated && Math.random() < 0.004) { // (1-0.004)^150 = chance to be removed after 3 seconds if (powerUp[i].isDuplicated && Math.random() < 0.004) { // (1-0.004)^150 = chance to be removed after 3 seconds
b.explosion(powerUp[i].position, 150 + (10 + 3 * Math.random()) * powerUp[i].size); b.explosion(powerUp[i].position, 150 + (10 + 3 * Math.random()) * powerUp[i].size);
Matter.World.remove(engine.world, powerUp[i]); Matter.Composite.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1); powerUp.splice(i, 1);
break break
} }
@@ -209,7 +209,7 @@ const powerUps = {
// document.body.style.overflow = "hidden" // document.body.style.overflow = "hidden"
simulation.paused = false; simulation.paused = false;
simulation.isChoosing = false; //stops p from un pausing on key down simulation.isChoosing = false; //stops p from un pausing on key down
if (m.immuneCycle < m.cycle + tech.collisionImmuneCycles) m.immuneCycle = m.cycle + tech.collisionImmuneCycles; //player is immune to damage for 30 cycles if (m.immuneCycle < m.cycle + 15) m.immuneCycle = m.cycle + 15; //player is immune to damage for 30 cycles
build.unPauseGrid() build.unPauseGrid()
requestAnimationFrame(cycle); requestAnimationFrame(cycle);
if (m.holdingTarget) m.drop(); if (m.holdingTarget) m.drop();
@@ -234,7 +234,7 @@ const powerUps = {
} }
} }
if (tech.isRerollBots) { if (tech.isRerollBots) {
for (const cost = 3; powerUps.research.count > cost - 1; powerUps.research.count -= cost) { for (const cost = 4; powerUps.research.count > cost - 1; powerUps.research.count -= cost) {
b.randomBot() b.randomBot()
if (tech.renormalization) { if (tech.renormalization) {
for (let i = 0; i < cost; i++) { for (let i = 0; i < cost; i++) {
@@ -373,7 +373,7 @@ const powerUps = {
if (tech.isAmmoForGun && b.inventory.length > 0 && b.activeGun) { if (tech.isAmmoForGun && b.inventory.length > 0 && b.activeGun) {
const target = b.guns[b.activeGun] const target = b.guns[b.activeGun]
if (target.ammo !== Infinity) { if (target.ammo !== Infinity) {
const ammoAdded = Math.ceil((0.82 * Math.random() + 0.8 * Math.random()) * target.ammoPack) const ammoAdded = Math.ceil((0.7 * Math.random() + 0.7 * Math.random()) * target.ammoPack)
target.ammo += ammoAdded target.ammo += ammoAdded
simulation.makeTextLog(`${target.name}.<span class='color-gun'>ammo</span> <span class='color-symbol'>+=</span> ${ammoAdded}`) simulation.makeTextLog(`${target.name}.<span class='color-gun'>ammo</span> <span class='color-symbol'>+=</span> ${ammoAdded}`)
} }
@@ -884,7 +884,7 @@ const powerUps = {
y: Math.random() * -9 - 3 y: Math.random() * -9 - 3
}); });
} }
World.add(engine.world, powerUp[index]); //add to world Composite.add(engine.world, powerUp[index]); //add to world
}, },
spawn(x, y, target, moving = true, mode = null, size = powerUps[target].size()) { spawn(x, y, target, moving = true, mode = null, size = powerUps[target].size()) {
if ( if (

View File

@@ -526,7 +526,7 @@ const simulation = {
m.spawn(); //spawns the player m.spawn(); //spawns the player
m.look = m.lookDefault m.look = m.lookDefault
} else { } else {
World.add(engine.world, [player]) Composite.add(engine.world, [player])
} }
simulation.isHorizontalFlipped = (Math.random() < 0.5) ? true : false //if true, some maps are flipped horizontally simulation.isHorizontalFlipped = (Math.random() < 0.5) ? true : false //if true, some maps are flipped horizontally
@@ -735,7 +735,8 @@ const simulation = {
simulation.drawList = []; simulation.drawList = [];
function removeAll(array) { function removeAll(array) {
for (let i = 0; i < array.length; ++i) Matter.World.remove(engine.world, array[i]); // for (let i = 0; i < array.length; ++i) Matter.Composite.remove(engine.world, array[i]);
for (let i = 0; i < array.length; ++i) Matter.Composite.remove(engine.world, array[i]);
} }
removeAll(map); removeAll(map);
map = []; map = [];
@@ -882,7 +883,7 @@ const simulation = {
y: level.exit.y + 30 * (Math.random() - 0.5) y: level.exit.y + 30 * (Math.random() - 0.5)
}); });
} else { } else {
Matter.World.remove(engine.world, who[i]); Matter.Composite.remove(engine.world, who[i]);
who.splice(i, 1); who.splice(i, 1);
} }
} }
@@ -998,11 +999,8 @@ const simulation = {
simulation.draw.mapPath.lineTo(vertices[0].x, vertices[0].y); simulation.draw.mapPath.lineTo(vertices[0].x, vertices[0].y);
} }
}, },
mapFill: "#444",
bodyFill: "rgba(140,140,140,0.85)", //"#999",
bodyStroke: "#222",
drawMapPath() { drawMapPath() {
ctx.fillStyle = simulation.draw.mapFill; ctx.fillStyle = color.map;
ctx.fill(simulation.draw.mapPath); ctx.fill(simulation.draw.mapPath);
}, },
body() { body() {
@@ -1016,9 +1014,9 @@ const simulation = {
ctx.lineTo(vertices[0].x, vertices[0].y); ctx.lineTo(vertices[0].x, vertices[0].y);
} }
ctx.lineWidth = 2; ctx.lineWidth = 2;
ctx.fillStyle = simulation.draw.bodyFill; ctx.fillStyle = color.block;
ctx.fill(); ctx.fill();
ctx.strokeStyle = simulation.draw.bodyStroke; ctx.strokeStyle = color.blockS;
ctx.stroke(); ctx.stroke();
}, },
cons() { cons() {
@@ -1194,7 +1192,7 @@ const simulation = {
map[len].collisionFilter.category = cat.map; map[len].collisionFilter.category = cat.map;
map[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; map[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet;
Matter.Body.setStatic(map[len], true); //make static Matter.Body.setStatic(map[len], true); //make static
World.add(engine.world, map[len]); //add to world Composite.add(engine.world, map[len]); //add to world
simulation.draw.setPaths() //update map graphics simulation.draw.setPaths() //update map graphics
} else if (e.which === 3) { //add body } else if (e.which === 3) { //add body
@@ -1209,7 +1207,7 @@ const simulation = {
len = body.length - 1 len = body.length - 1
body[len].collisionFilter.category = cat.body; body[len].collisionFilter.category = cat.body;
body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
World.add(engine.world, body[len]); //add to world Composite.add(engine.world, body[len]); //add to world
body[len].classType = "body" body[len].classType = "body"
} }
} }
@@ -1230,12 +1228,12 @@ const simulation = {
if (simulation.testing && e.keyCode === 90 && simulation.constructMapString.length) { if (simulation.testing && e.keyCode === 90 && simulation.constructMapString.length) {
if (simulation.constructMapString[simulation.constructMapString.length - 1][6] === 'm') { //remove map from current level if (simulation.constructMapString[simulation.constructMapString.length - 1][6] === 'm') { //remove map from current level
const index = map.length - 1 const index = map.length - 1
Matter.World.remove(engine.world, map[index]); Matter.Composite.remove(engine.world, map[index]);
map.splice(index, 1); map.splice(index, 1);
simulation.draw.setPaths() //update map graphics simulation.draw.setPaths() //update map graphics
} else if (simulation.constructMapString[simulation.constructMapString.length - 1][6] === 'b') { //remove body from current level } else if (simulation.constructMapString[simulation.constructMapString.length - 1][6] === 'b') { //remove body from current level
const index = body.length - 1 const index = body.length - 1
Matter.World.remove(engine.world, body[index]); Matter.Composite.remove(engine.world, body[index]);
body.splice(index, 1); body.splice(index, 1);
} }
simulation.constructMapString.pop(); simulation.constructMapString.pop();

View File

@@ -250,12 +250,12 @@ const spawn = {
stiffness: 1, stiffness: 1,
damping: 1 damping: 1
}); });
World.add(engine.world, me.constraint); Composite.add(engine.world, me.constraint);
}, 2000); //add in a delay in case the level gets flipped left right }, 2000); //add in a delay in case the level gets flipped left right
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.damageReduction = 0.25;
me.frictionAir = 0.01; me.frictionAir = 0.01;
me.memory = Infinity; me.memory = Infinity;
me.hasRunDeathScript = false me.hasRunDeathScript = false
@@ -276,7 +276,7 @@ const spawn = {
body[len].collisionFilter.category = cat.body; body[len].collisionFilter.category = cat.body;
body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet; body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet;
body[len].classType = "body"; body[len].classType = "body";
World.add(engine.world, body[len]); //add to world Composite.add(engine.world, body[len]); //add to world
const expand = function(that, massLimit) { const expand = function(that, massLimit) {
const scale = 1.05; const scale = 1.05;
Matter.Body.scale(that, scale, scale); Matter.Body.scale(that, scale, scale);
@@ -291,7 +291,7 @@ const spawn = {
level.exit.x = 5500; level.exit.x = 5500;
} }
level.exit.y = -330; level.exit.y = -330;
Matter.World.remove(engine.world, map[map.length - 1]); Matter.Composite.remove(engine.world, map[map.length - 1]);
map.splice(map.length - 1, 1); map.splice(map.length - 1, 1);
simulation.draw.setPaths(); //redraw map draw path simulation.draw.setPaths(); //redraw map draw path
} }
@@ -316,7 +316,7 @@ const spawn = {
} else if (count === 780) { } else if (count === 780) {
simulation.makeTextLog(`<span class="lore-text">undefined</span> <span class='color-symbol'>=</span> ${lore.techCount}/${lore.techGoal}`) simulation.makeTextLog(`<span class="lore-text">undefined</span> <span class='color-symbol'>=</span> ${lore.techCount}/${lore.techGoal}`)
} else if (count === 1020) { } else if (count === 1020) {
simulation.makeTextLog(`World.clear(engine.world) <em>//simulation successful</em>`); simulation.makeTextLog(`Composite.clear(engine.composite) <em>//simulation successful</em>`);
} else if (count === 1260) { } else if (count === 1260) {
// tech.isImmortal = false; // tech.isImmortal = false;
// m.death() // m.death()
@@ -331,7 +331,7 @@ const spawn = {
// build.shareURL(false) // build.shareURL(false)
setTimeout(function() { setTimeout(function() {
simulation.paused = true; simulation.paused = true;
World.clear(engine.world); Composite.clear(engine.composite);
Engine.clear(engine); Engine.clear(engine);
simulation.splashReturn(); simulation.splashReturn();
}, 6000); }, 6000);
@@ -353,7 +353,7 @@ const spawn = {
level.difficultyIncrease(simulation.difficultyMode) //ramp up damage level.difficultyIncrease(simulation.difficultyMode) //ramp up damage
//remove power Ups, to avoid spamming console //remove power Ups, to avoid spamming console
function removeAll(array) { function removeAll(array) {
for (let i = 0; i < array.length; ++i) Matter.World.remove(engine.world, array[i]); for (let i = 0; i < array.length; ++i) Matter.Composite.remove(engine.world, array[i]);
} }
removeAll(powerUp); removeAll(powerUp);
powerUp = []; powerUp = [];
@@ -388,7 +388,9 @@ const spawn = {
me.endCycle = 780; me.endCycle = 780;
me.totalCycles = 0 me.totalCycles = 0
me.mode = 0; me.mode = 0;
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
// Matter.Body.setPosition(this, { // Matter.Body.setPosition(this, {
// x: x, // x: x,
// y: y // y: y
@@ -727,10 +729,9 @@ const spawn = {
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.stroke = "transparent" me.stroke = "transparent"
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.isCell = true; me.isCell = true;
me.cellID = cellID me.cellID = cellID
me.accelMag = 0.00016 * simulation.accelScale; me.accelMag = 0.000165 * simulation.accelScale;
me.memory = 40; me.memory = 40;
me.isVerticesChange = true me.isVerticesChange = true
me.frictionAir = 0.012 me.frictionAir = 0.012
@@ -753,7 +754,9 @@ const spawn = {
me.onDamage = function(dmg) { me.onDamage = function(dmg) {
if (Math.random() < 0.33 * dmg * Math.sqrt(this.mass) && this.health > dmg) this.split(); if (Math.random() < 0.33 * dmg * Math.sqrt(this.mass) && this.health > dmg) this.split();
} }
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
if (!m.isBodiesAsleep) { if (!m.isBodiesAsleep) {
this.seePlayerByDistOrLOS(); this.seePlayerByDistOrLOS();
this.checkStatus(); this.checkStatus();
@@ -805,7 +808,7 @@ const spawn = {
mobs.spawn(x + Math.random(), y + Math.random(), 4, radius, "rgba(255,60,0,0.3)") //); mobs.spawn(x + Math.random(), y + Math.random(), 4, radius, "rgba(255,60,0,0.3)") //);
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.isSpawnBoss = true; me.isSpawnBoss = true;
me.spawnID = spawnID me.spawnID = spawnID
me.accelMag = 0.0002 * simulation.accelScale; me.accelMag = 0.0002 * simulation.accelScale;
@@ -824,8 +827,10 @@ const spawn = {
me.onHit = function() { //run this function on hitting player me.onHit = function() { //run this function on hitting player
this.explode(); this.explode();
}; };
me.damageReduction = 0.25
me.doAwake = function() { me.doAwake = function() {
if (!m.isBodiesAsleep) { if (!m.isBodiesAsleep) {
// this.armor();
this.alwaysSeePlayer(); this.alwaysSeePlayer();
this.checkStatus(); this.checkStatus();
this.attraction(); this.attraction();
@@ -898,7 +903,7 @@ const spawn = {
mobs.spawn(x + Math.random(), y + Math.random(), 6, radius, "hsl(144, 15%, 50%)") //); mobs.spawn(x + Math.random(), y + Math.random(), 6, radius, "hsl(144, 15%, 50%)") //);
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.isBuffBoss = true; me.isBuffBoss = true;
me.buffID = buffID me.buffID = buffID
me.memory = Infinity; me.memory = Infinity;
@@ -917,7 +922,7 @@ const spawn = {
this.accelMag += 0.000035 //* Math.sqrt(simulation.accelScale) this.accelMag += 0.000035 //* Math.sqrt(simulation.accelScale)
// Matter.Body.setDensity(this, 0.001 + 0.0003 * this.buffCount) // normal density is 0.001 //+ 0.0005 * Math.sqrt(simulation.difficulty) // Matter.Body.setDensity(this, 0.001 + 0.0003 * this.buffCount) // normal density is 0.001 //+ 0.0005 * Math.sqrt(simulation.difficulty)
this.fill = `hsl(144, ${5+10*this.buffCount}%, 50%)` this.fill = `hsl(144, ${5+10*this.buffCount}%, 50%)`
const scale = 1.13; const scale = 1.132;
Matter.Body.scale(this, scale, scale); Matter.Body.scale(this, scale, scale);
this.radius *= scale; this.radius *= scale;
// this.health += 0.03 // this.health += 0.03
@@ -939,7 +944,9 @@ const spawn = {
if (!count % 2) powerUps.spawnRandomPowerUp(this.position.x, this.position.y) // higher then normal chance to drop heals and ammo if (!count % 2) powerUps.spawnRandomPowerUp(this.position.x, this.position.y) // higher then normal chance to drop heals and ammo
} }
} }
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.alwaysSeePlayer(); this.alwaysSeePlayer();
this.checkStatus(); this.checkStatus();
this.attraction(); this.attraction();
@@ -965,7 +972,7 @@ const spawn = {
mobs.spawn(x, y, vertices, radius, "transparent"); mobs.spawn(x, y, vertices, radius, "transparent");
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.frictionAir = 0.01 me.frictionAir = 0.01
me.seeAtDistance2 = 1000000; me.seeAtDistance2 = 1000000;
me.accelMag = 0.0005 * simulation.accelScale; me.accelMag = 0.0005 * simulation.accelScale;
@@ -999,7 +1006,9 @@ const spawn = {
} }
for (let i = 0; i < powerUp.length; i++) powerUp[i].collisionFilter.mask = cat.map | cat.powerUp for (let i = 0; i < powerUp.length; i++) powerUp[i].collisionFilter.mask = cat.map | cat.powerUp
}; };
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.stroke = `hsl(0,0%,${80+25*Math.sin(simulation.cycle*0.01)}%)` this.stroke = `hsl(0,0%,${80+25*Math.sin(simulation.cycle*0.01)}%)`
//steal all power ups //steal all power ups
@@ -1073,7 +1082,7 @@ const spawn = {
stiffness: springStiffness, stiffness: springStiffness,
damping: springDampening damping: springDampening
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
cons[len].length = 100 + 1.5 * radius; cons[len].length = 100 + 1.5 * radius;
me.cons = cons[len]; me.cons = cons[len];
@@ -1089,7 +1098,7 @@ const spawn = {
stiffness: springStiffness, stiffness: springStiffness,
damping: springDampening damping: springDampening
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
cons[len2].length = 100 + 1.5 * radius; cons[len2].length = 100 + 1.5 * radius;
me.cons2 = cons[len2]; me.cons2 = cons[len2];
me.do = function() { me.do = function() {
@@ -1147,7 +1156,7 @@ const spawn = {
mobs.spawn(x, y, 5, radius, "rgb(0,200,180)"); mobs.spawn(x, y, 5, radius, "rgb(0,200,180)");
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.g = 0.005; //required if using 'gravity' me.g = 0.005; //required if using 'gravity'
me.frictionAir = 0.01; me.frictionAir = 0.01;
me.friction = 1 me.friction = 1
@@ -1166,7 +1175,9 @@ const spawn = {
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)
}; };
me.lastSpeed = me.speed me.lastSpeed = me.speed
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.gravity(); this.gravity();
this.seePlayerCheck(); this.seePlayerCheck();
this.checkStatus(); this.checkStatus();
@@ -1365,7 +1376,7 @@ const spawn = {
mobs.spawn(x, y, 12, radius, "#000"); mobs.spawn(x, y, 12, radius, "#000");
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.stroke = "transparent"; //used for drawSneaker me.stroke = "transparent"; //used for drawSneaker
me.eventHorizon = 1100; //required for black hole me.eventHorizon = 1100; //required for black hole
me.seeAtDistance2 = (me.eventHorizon + 1200) * (me.eventHorizon + 1200); //vision limit is event horizon me.seeAtDistance2 = (me.eventHorizon + 1200) * (me.eventHorizon + 1200); //vision limit is event horizon
@@ -1395,7 +1406,9 @@ const spawn = {
// toMe(bullet, this.position, this.eventHorizon) // toMe(bullet, this.position, this.eventHorizon)
} }
}; };
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
//keep it slow, to stop issues from explosion knock backs //keep it slow, to stop issues from explosion knock backs
if (this.speed > 1) { if (this.speed > 1) {
Matter.Body.setVelocity(this, { Matter.Body.setVelocity(this, {
@@ -1477,7 +1490,7 @@ const spawn = {
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
Matter.Body.setDensity(me, 0.0035); //extra dense //normal is 0.001 //makes effective life much larger Matter.Body.setDensity(me, 0.0035); //extra dense //normal is 0.001 //makes effective life much larger
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
targets.push(me.id) //add to shield protection targets.push(me.id) //add to shield protection
me.friction = 0; me.friction = 0;
me.frictionAir = 0.0065; me.frictionAir = 0.0065;
@@ -1498,7 +1511,7 @@ const spawn = {
stiffness: springStiffness, stiffness: springStiffness,
damping: springDampening damping: springDampening
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
cons[len].length = 100 + 1.5 * radius; cons[len].length = 100 + 1.5 * radius;
me.cons = cons[len]; me.cons = cons[len];
@@ -1514,10 +1527,12 @@ const spawn = {
damping: springDampening, damping: springDampening,
length: 0 length: 0
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
cons[len2].length = 100 + 1.5 * radius; cons[len2].length = 100 + 1.5 * radius;
me.cons2 = cons[len2]; me.cons2 = cons[len2];
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.gravity(); this.gravity();
this.searchSpring(); this.searchSpring();
this.checkStatus(); this.checkStatus();
@@ -1552,7 +1567,7 @@ const spawn = {
stiffness: attachmentStiffness, stiffness: attachmentStiffness,
damping: 0.01 damping: 0.01
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
} }
//spawn shield around all nodes //spawn shield around all nodes
spawn.groupShield(targets, x, y, sideLength + 1 * radius + nodes * 5 - 25); spawn.groupShield(targets, x, y, sideLength + 1 * radius + nodes * 5 - 25);
@@ -1561,7 +1576,7 @@ const spawn = {
// timeSkipBoss(x, y, radius = 55) { // timeSkipBoss(x, y, radius = 55) {
// mobs.spawn(x, y, 6, radius, '#000'); // mobs.spawn(x, y, 6, radius, '#000');
// let me = mob[mob.length - 1]; // let me = mob[mob.length - 1];
// me.isBoss = true; me.damageReduction = 0.25; // me.isBoss = true;
// // me.stroke = "transparent"; //used for drawSneaker // // me.stroke = "transparent"; //used for drawSneaker
// me.timeSkipLastCycle = 0 // me.timeSkipLastCycle = 0
// me.eventHorizon = 1800; //required for black hole // me.eventHorizon = 1800; //required for black hole
@@ -1668,7 +1683,7 @@ const spawn = {
me.laserRange = 300; me.laserRange = 300;
me.seeAtDistance2 = 2000000; me.seeAtDistance2 = 2000000;
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.showHealthBar = false; //drawn in this.awake me.showHealthBar = false; //drawn in this.awake
me.delayLimit = 60 + Math.floor(30 * Math.random()); me.delayLimit = 60 + Math.floor(30 * Math.random());
me.followDelay = 600 - Math.floor(60 * Math.random()) me.followDelay = 600 - Math.floor(60 * Math.random())
@@ -1678,7 +1693,9 @@ const spawn = {
me.onDeath = function() { me.onDeath = function() {
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)
}; };
me.damageReduction = 0.25
me.awake = function() { me.awake = function() {
// this.armor();
this.checkStatus(); this.checkStatus();
//health bar needs to be here because the position is being set //health bar needs to be here because the position is being set
const h = this.radius * 0.3; const h = this.radius * 0.3;
@@ -1834,7 +1851,7 @@ const spawn = {
mobs.spawn(x, y, 3, radius, color); mobs.spawn(x, y, 3, radius, color);
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.vertices = Matter.Vertices.rotate(me.vertices, Math.PI, me.position); //make the pointy side of triangle the front me.vertices = Matter.Vertices.rotate(me.vertices, Math.PI, me.position); //make the pointy side of triangle the front
Matter.Body.rotate(me, Math.random() * Math.PI * 2); Matter.Body.rotate(me, Math.random() * Math.PI * 2);
me.accelMag = 0.00018 * Math.sqrt(simulation.accelScale); me.accelMag = 0.00018 * Math.sqrt(simulation.accelScale);
@@ -1860,7 +1877,9 @@ const spawn = {
me.onDeath = function() { me.onDeath = function() {
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)
}; };
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.seePlayerByLookingAt(); this.seePlayerByLookingAt();
this.checkStatus(); this.checkStatus();
this.attraction(); this.attraction();
@@ -1975,12 +1994,12 @@ const spawn = {
Matter.Body.rotate(me, Math.PI * 0.1); Matter.Body.rotate(me, Math.PI * 0.1);
Matter.Body.setDensity(me, 0.02); //extra dense //normal is 0.001 //makes effective life much larger Matter.Body.setDensity(me, 0.02); //extra dense //normal is 0.001 //makes effective life much larger
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.frictionStatic = 0; me.frictionStatic = 0;
me.friction = 0; me.friction = 0;
me.memory = 240 me.memory = 240
me.seePlayerFreq = 60 me.seePlayerFreq = 60
me.delay = 16 + 30 * simulation.CDScale; me.delay = 20 + 30 * simulation.CDScale;
me.nextBlinkCycle = me.delay; me.nextBlinkCycle = me.delay;
me.blinkRange = 235 me.blinkRange = 235
me.grenadeDelay = 30 + 60 * simulation.CDScale me.grenadeDelay = 30 + 60 * simulation.CDScale
@@ -2003,7 +2022,9 @@ const spawn = {
} }
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)
} }
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.seePlayerByHistory() this.seePlayerByHistory()
if (this.nextBlinkCycle < simulation.cycle && this.seePlayer.yes) { //teleport towards the player if (this.nextBlinkCycle < simulation.cycle && this.seePlayer.yes) { //teleport towards the player
this.nextBlinkCycle = simulation.cycle + this.delay; this.nextBlinkCycle = simulation.cycle + this.delay;
@@ -2041,7 +2062,7 @@ const spawn = {
stiffness: 0.0001, stiffness: 0.0001,
damping: 0.3 damping: 0.3
}); });
World.add(engine.world, me.constraint); Composite.add(engine.world, me.constraint);
}, 2000); //add in a delay in case the level gets flipped left right }, 2000); //add in a delay in case the level gets flipped left right
me.vertices = Matter.Vertices.rotate(me.vertices, Math.PI, me.position); //make the pointy side of triangle the front me.vertices = Matter.Vertices.rotate(me.vertices, Math.PI, me.position); //make the pointy side of triangle the front
@@ -2057,7 +2078,7 @@ const spawn = {
me.isFiring = false me.isFiring = false
Matter.Body.setDensity(me, 0.01); //extra dense //normal is 0.001 //makes effective life much larger Matter.Body.setDensity(me, 0.01); //extra dense //normal is 0.001 //makes effective life much larger
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
spawn.shield(me, x, y, 1); spawn.shield(me, x, y, 1);
spawn.spawnOrbitals(me, radius + 200 + 300 * Math.random(), 1) spawn.spawnOrbitals(me, radius + 200 + 300 * Math.random(), 1)
me.onDeath = function() { me.onDeath = function() {
@@ -2067,7 +2088,9 @@ const spawn = {
me.do = function() { me.do = function() {
if (player.speed > 5) this.do = this.fire //don't attack until player moves if (player.speed > 5) this.do = this.fire //don't attack until player moves
} }
me.damageReduction = 0.25
me.fire = function() { me.fire = function() {
// this.armor();
this.checkStatus(); this.checkStatus();
if (!m.isBodiesAsleep) { if (!m.isBodiesAsleep) {
if (!m.isCloak && !this.isStunned) { if (!m.isCloak && !this.isStunned) {
@@ -2306,11 +2329,11 @@ const spawn = {
stiffness: 1, stiffness: 1,
damping: 1 damping: 1
}); });
World.add(engine.world, me.constraint); Composite.add(engine.world, me.constraint);
}, 2000); //add in a delay in case the level gets flipped left right }, 2000); //add in a delay in case the level gets flipped left right
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
// me.startingPosition = { // me.startingPosition = {
// x: x, // x: x,
// y: y // y: y
@@ -2326,7 +2349,9 @@ const spawn = {
}; };
me.rotateVelocity = Math.min(0.0045, 0.0015 * simulation.accelScale * simulation.accelScale) * (level.levelsCleared > 8 ? 1 : -1) * (simulation.isHorizontalFlipped ? -1 : 1) me.rotateVelocity = Math.min(0.0045, 0.0015 * simulation.accelScale * simulation.accelScale) * (level.levelsCleared > 8 ? 1 : -1) * (simulation.isHorizontalFlipped ? -1 : 1)
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.fill = '#' + Math.random().toString(16).substr(-6); //flash colors this.fill = '#' + Math.random().toString(16).substr(-6); //flash colors
this.checkStatus(); this.checkStatus();
@@ -2734,12 +2759,12 @@ const spawn = {
mobs.spawn(x, y, 3, radius, "rgba(255,0,200,0.5)"); mobs.spawn(x, y, 3, radius, "rgba(255,0,200,0.5)");
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
Matter.Body.setDensity(me, 0.002 + 0.0001 * Math.sqrt(simulation.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger Matter.Body.setDensity(me, 0.002 + 0.0001 * Math.sqrt(simulation.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger
me.stroke = "transparent"; //used for drawGhost me.stroke = "transparent"; //used for drawGhost
me.seeAtDistance2 = 1500000; me.seeAtDistance2 = 1500000;
me.fireFreq = Math.floor(100 * simulation.CDScale); me.fireFreq = 10 + Math.floor(70 * simulation.CDScale);
me.searchTarget = map[Math.floor(Math.random() * (map.length - 1))].position; //required for search me.searchTarget = map[Math.floor(Math.random() * (map.length - 1))].position; //required for search
me.hoverElevation = 460 + (Math.random() - 0.5) * 200; //squared me.hoverElevation = 460 + (Math.random() - 0.5) * 200; //squared
me.hoverXOff = (Math.random() - 0.5) * 100; me.hoverXOff = (Math.random() - 0.5) * 100;
@@ -2765,7 +2790,9 @@ const spawn = {
me.onDeath = function() { me.onDeath = function() {
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)
}; };
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.seePlayerCheckByDistance(); this.seePlayerCheckByDistance();
this.checkStatus(); this.checkStatus();
if (this.seePlayer.recall) { if (this.seePlayer.recall) {
@@ -2819,11 +2846,11 @@ const spawn = {
stiffness: 0.00004, stiffness: 0.00004,
damping: 0.1 damping: 0.1
}); });
World.add(engine.world, me.constraint); Composite.add(engine.world, me.constraint);
}, 2000); //add in a delay in case the level gets flipped left right }, 2000); //add in a delay in case the level gets flipped left right
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.vertices = Matter.Vertices.rotate(me.vertices, Math.PI, me.position); //make the pointy side of triangle the front me.vertices = Matter.Vertices.rotate(me.vertices, Math.PI, me.position); //make the pointy side of triangle the front
me.isVerticesChange = true me.isVerticesChange = true
me.memory = 240; me.memory = 240;
@@ -2851,7 +2878,9 @@ const spawn = {
// this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed // this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed
}; };
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.seePlayerByLookingAt(); this.seePlayerByLookingAt();
this.checkStatus(); this.checkStatus();
this.fire(); this.fire();
@@ -3113,14 +3142,14 @@ const spawn = {
mobs.spawn(x, y, 6, radius, "rgb(150,150,255)"); mobs.spawn(x, y, 6, radius, "rgb(150,150,255)");
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.accelMag = 0.00008 * simulation.accelScale; me.accelMag = 0.0001 * simulation.accelScale;
me.fireFreq = Math.floor(360 * simulation.CDScale) me.fireFreq = Math.floor(330 * simulation.CDScale)
me.frictionStatic = 0; me.frictionStatic = 0;
me.friction = 0; me.friction = 0;
me.frictionAir = 0.02; me.frictionAir = 0.02;
me.memory = 420; me.memory = 420;
me.repulsionRange = 1200000; //squared me.repulsionRange = 1000000; //squared
spawn.shield(me, x, y, 1); spawn.shield(me, x, y, 1);
spawn.spawnOrbitals(me, radius + 50 + 200 * Math.random()) spawn.spawnOrbitals(me, radius + 50 + 200 * Math.random())
@@ -3130,7 +3159,9 @@ const spawn = {
// this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed // this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed
}; };
me.onDamage = function() {}; me.onDamage = function() {};
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.seePlayerCheck(); this.seePlayerCheck();
this.checkStatus(); this.checkStatus();
this.attraction(); this.attraction();
@@ -3154,7 +3185,7 @@ const spawn = {
mobs.spawn(x, y, 6, radius, "rgb(215,80,190)"); mobs.spawn(x, y, 6, radius, "rgb(215,80,190)");
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.accelMag = 0.0001 * simulation.accelScale; me.accelMag = 0.0001 * simulation.accelScale;
me.fireFreq = Math.floor(360 * simulation.CDScale) me.fireFreq = Math.floor(360 * simulation.CDScale)
me.frictionStatic = 0; me.frictionStatic = 0;
@@ -3193,7 +3224,9 @@ const spawn = {
}); });
} }
}; };
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
if (this.grenadeLimiter > 1) this.grenadeLimiter-- if (this.grenadeLimiter > 1) this.grenadeLimiter--
this.seePlayerCheck(); this.seePlayerCheck();
this.checkStatus(); this.checkStatus();
@@ -3334,15 +3367,14 @@ const spawn = {
stiffness: 0.0001, stiffness: 0.0001,
damping: 1 damping: 1
}); });
World.add(engine.world, me.constraint); Composite.add(engine.world, me.constraint);
}, 2000); //add in a delay in case the level gets flipped left right }, 2000); //add in a delay in case the level gets flipped left right
Matter.Body.rotate(me, Math.random() * 2 * Math.PI) Matter.Body.rotate(me, Math.random() * 2 * Math.PI)
// me.stroke = "rgb(220,220,255)" // me.stroke = "rgb(220,220,255)"
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.cycle = 0 me.cycle = 0
me.maxCycles = 120; me.maxCycles = 110;
me.frictionStatic = 0; me.frictionStatic = 0;
me.friction = 0; me.friction = 0;
me.frictionAir = 0.5; me.frictionAir = 0.5;
@@ -3350,7 +3382,7 @@ const spawn = {
spawn.shield(me, x, y, 1); spawn.shield(me, x, y, 1);
spawn.spawnOrbitals(me, radius + 50 + 200 * Math.random()) spawn.spawnOrbitals(me, radius + 50 + 200 * Math.random())
Matter.Body.setDensity(me, 0.004); //extra dense //normal is 0.001 //makes effective life much larger Matter.Body.setDensity(me, 0.0045); //extra dense //normal is 0.001 //makes effective life much larger
me.onDeath = function() { me.onDeath = function() {
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)
// this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed // this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed
@@ -3358,9 +3390,10 @@ const spawn = {
me.onDamage = function() { me.onDamage = function() {
this.cycle = 0 this.cycle = 0
}; };
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.checkStatus(); this.checkStatus();
ctx.beginPath(); //draw cycle timer ctx.beginPath(); //draw cycle timer
ctx.moveTo(this.vertices[this.vertices.length - 1].x, this.vertices[this.vertices.length - 1].y) ctx.moveTo(this.vertices[this.vertices.length - 1].x, this.vertices[this.vertices.length - 1].y)
const phase = (this.vertices.length + 1) * this.cycle / this.maxCycles const phase = (this.vertices.length + 1) * this.cycle / this.maxCycles
@@ -3396,7 +3429,6 @@ const spawn = {
mobs.spawn(x, y, 5, radius, "rgb(245,180,255)"); mobs.spawn(x, y, 5, radius, "rgb(245,180,255)");
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
// me.accelMag = 0.00023 * simulation.accelScale; // me.accelMag = 0.00023 * simulation.accelScale;
me.accelMag = 0.00008 * simulation.accelScale; me.accelMag = 0.00008 * simulation.accelScale;
// me.fireFreq = Math.floor(30 * simulation.CDScale) // me.fireFreq = Math.floor(30 * simulation.CDScale)
@@ -3418,7 +3450,9 @@ const spawn = {
// this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed // this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed
}; };
me.onDamage = function() {}; me.onDamage = function() {};
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.seePlayerCheck(); this.seePlayerCheck();
this.checkStatus(); this.checkStatus();
this.attraction(); this.attraction();
@@ -3606,16 +3640,19 @@ const spawn = {
this.attraction(); this.attraction();
}; };
}, },
snakeBoss(x, y, radius = 60) { //snake boss with a laser head snakeBoss(x, y, radius = 50) { //snake boss with a laser head
const nodes = Math.min(8 + Math.ceil(0.5 * simulation.difficulty), 40)
let angle = Math.PI
let mag = 300
const color1 = "#f27" const color1 = "#f27"
mobs.spawn(x, y, 8, radius, color1); //"rgb(55,170,170)" mobs.spawn(x + mag * Math.cos(angle), y + mag * Math.sin(angle), 8, radius, color1); //"rgb(55,170,170)"
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25; me.accelMag = 0.00077 * simulation.accelScale;
me.accelMag = 0.00075 * simulation.accelScale;
me.memory = 250; me.memory = 250;
me.laserRange = 500; me.laserRange = 500;
Matter.Body.setDensity(me, 0.0016 + 0.0001 * Math.sqrt(simulation.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger Matter.Body.setDensity(me, 0.00165 + 0.00011 * Math.sqrt(simulation.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger
me.onDeath = function() { me.onDeath = function() {
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)
for (let i = 0; i < mob.length; i++) { //wake up tail mobs for (let i = 0; i < mob.length; i++) { //wake up tail mobs
@@ -3626,17 +3663,23 @@ const spawn = {
} }
} }
}; };
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.seePlayerCheck(); // this.armor();
this.seePlayerByHistory() this.seePlayerByHistory()
this.checkStatus(); this.checkStatus();
this.attraction(); this.attraction();
this.harmZone(); this.harmZone();
}; };
//extra space to give head room
//snake tail angle -= 0.1
const nodes = Math.min(8 + Math.ceil(0.5 * simulation.difficulty), 40) mag -= 10
spawn.lineGroup(x + 105, y, "snakeBody", nodes); for (let i = 0; i < nodes; ++i) {
angle -= 0.15 + i * 0.008
mag -= 5
spawn.snakeBody(x + mag * Math.cos(angle), y + mag * Math.sin(angle), 20);
}
this.constrain2AdjacentMobs(nodes, Math.random() * 0.06 + 0.01);
for (let i = mob.length - 1, len = i - nodes; i > len; i--) { //set alternating colors for (let i = mob.length - 1, len = i - nodes; i > len; i--) { //set alternating colors
if (i % 2) { if (i % 2) {
@@ -3651,28 +3694,24 @@ const spawn = {
bodyB: mob[mob.length - 1 - nodes], bodyB: mob[mob.length - 1 - nodes],
stiffness: 0.05 stiffness: 0.05
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
consBB[consBB.length] = Constraint.create({ consBB[consBB.length] = Constraint.create({
bodyA: mob[mob.length - nodes + 1], bodyA: mob[mob.length - nodes + 1],
bodyB: mob[mob.length - 1 - nodes], bodyB: mob[mob.length - 1 - nodes],
stiffness: 0.05 stiffness: 0.05
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
consBB[consBB.length] = Constraint.create({ consBB[consBB.length] = Constraint.create({
bodyA: mob[mob.length - nodes + 2], bodyA: mob[mob.length - nodes + 2],
bodyB: mob[mob.length - 1 - nodes], bodyB: mob[mob.length - 1 - nodes],
stiffness: 0.05 stiffness: 0.05
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
// spawn.shield(me, x, y, 1); // spawn.shield(me, x, y, 1);
}, },
snakeBody(x, y, radius = 10) { snakeBody(x, y, radius = 10) {
mobs.spawn(x, y, 8, radius, "rgba(0,180,180,0.4)"); mobs.spawn(x, y, 8, radius, "rgba(0,180,180,0.4)");
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
// me.onHit = function() {
// //run this function on hitting player
// this.explode();
// };
me.collisionFilter.mask = cat.bullet | cat.player | cat.mob //| cat.body me.collisionFilter.mask = cat.bullet | cat.player | cat.mob //| cat.body
me.accelMag = 0.0004 * simulation.accelScale; me.accelMag = 0.0004 * simulation.accelScale;
me.leaveBody = false; me.leaveBody = false;
@@ -3681,7 +3720,6 @@ const spawn = {
me.frictionAir = 0.02; me.frictionAir = 0.02;
me.isSnakeTail = true; me.isSnakeTail = true;
me.stroke = "transparent" me.stroke = "transparent"
me.onDeath = function() { me.onDeath = function() {
if (this.isSnakeTail) { //wake up tail mobs if (this.isSnakeTail) { //wake up tail mobs
for (let i = 0; i < mob.length; i++) { for (let i = 0; i < mob.length; i++) {
@@ -3708,7 +3746,7 @@ const spawn = {
mobs.spawn(x, y, 8, radius, "rgb(0,60,80)"); mobs.spawn(x, y, 8, radius, "rgb(0,60,80)");
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
me.g = 0.0001; //required if using 'gravity' me.g = 0.0001; //required if using 'gravity'
me.accelMag = 0.002 * simulation.accelScale; me.accelMag = 0.002 * simulation.accelScale;
me.memory = 20; me.memory = 20;
@@ -3722,7 +3760,7 @@ const spawn = {
bodyB: me, bodyB: me,
stiffness: 0.00012 stiffness: 0.00012
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
spawn.shield(me, x, y, 1); spawn.shield(me, x, y, 1);
setTimeout(() => { spawn.spawnOrbitals(me, radius + 50 + 200 * Math.random()) }, 100); //have to wait a sec so the tether constraint doesn't attach to an orbital setTimeout(() => { spawn.spawnOrbitals(me, radius + 50 + 200 * Math.random()) }, 100); //have to wait a sec so the tether constraint doesn't attach to an orbital
@@ -3730,7 +3768,9 @@ const spawn = {
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)
this.removeCons(); //remove constraint this.removeCons(); //remove constraint
}; };
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.gravity(); this.gravity();
this.seePlayerCheck(); this.seePlayerCheck();
this.checkStatus(); this.checkStatus();
@@ -3754,7 +3794,7 @@ const spawn = {
stiffness: 0.4, stiffness: 0.4,
damping: 0.1 damping: 0.1
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
me.onDamage = function() { me.onDamage = function() {
//make sure the mob that owns the shield can tell when damage is done //make sure the mob that owns the shield can tell when damage is done
@@ -3804,7 +3844,7 @@ const spawn = {
stiffness: stiffness, stiffness: stiffness,
damping: 0.1 damping: 0.1
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
} }
me.onDamage = function() { me.onDamage = function() {
this.alertNearByMobs(); //makes sure the mob that owns the shield can tell when damage is done this.alertNearByMobs(); //makes sure the mob that owns the shield can tell when damage is done
@@ -3884,25 +3924,25 @@ const spawn = {
mobs.spawn(x, y, nodes, radius, "rgb(255,0,150)"); mobs.spawn(x, y, nodes, radius, "rgb(255,0,150)");
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.damageReduction = 0.25;
Matter.Body.setDensity(me, 0.002 + 0.00015 * Math.sqrt(simulation.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger Matter.Body.setDensity(me, 0.002 + 0.00025 * Math.sqrt(simulation.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger
me.stroke = "transparent"; //used for drawGhost me.stroke = "transparent"; //used for drawGhost
me.seeAtDistance2 = 2000000; me.seeAtDistance2 = 2000000;
me.memory = Infinity; me.memory = Infinity;
me.frictionAir = 0.02; me.frictionAir = 0.02;
me.accelMag = 0.00014 * Math.sqrt(simulation.accelScale) me.accelMag = 0.00015 * Math.sqrt(simulation.accelScale)
me.collisionFilter.mask = cat.player | cat.bullet //| cat.body me.collisionFilter.mask = cat.player | cat.bullet //| cat.body
spawn.shield(me, x, y, 1); spawn.shield(me, x, y, 1);
const rangeInnerVsOuter = Math.random() const rangeInnerVsOuter = Math.random()
let speed = (0.003 + 0.0015 * Math.sqrt(simulation.difficulty)) * ((Math.random() < 0.5) ? 1 : -1) let speed = (0.009 + 0.0011 * Math.sqrt(simulation.difficulty)) * ((Math.random() < 0.5) ? 1 : -1)
let range = radius + 150 + 200 * rangeInnerVsOuter + nodes * 5 let range = radius + 400 + 200 * rangeInnerVsOuter + nodes * 7
for (let i = 0; i < nodes; i++) spawn.orbital(me, range, i / nodes * 2 * Math.PI, speed) for (let i = 0; i < nodes; i++) spawn.orbital(me, range, i / nodes * 2 * Math.PI, speed)
const orbitalIndexes = [] //find indexes for all the current nodes const orbitalIndexes = [] //find indexes for all the current nodes
for (let i = 0; i < nodes; i++) orbitalIndexes.push(mob.length - 1 - i) for (let i = 0; i < nodes; i++) orbitalIndexes.push(mob.length - 1 - i)
// add orbitals for each orbital // add orbitals for each orbital
range = Math.max(60, 150 - nodes * 3 - rangeInnerVsOuter * 80) range = Math.max(60, 100 + 100 * Math.random() - nodes * 3 - rangeInnerVsOuter * 80)
speed = speed * (1.25 + 2 * Math.random()) speed = speed * (1.25 + 2 * Math.random())
const subNodes = Math.max(2, Math.floor(6 - 5 * nodeBalance + 0.5 * Math.sqrt(simulation.difficulty))) const subNodes = Math.max(2, Math.floor(6 - 5 * nodeBalance + 0.5 * Math.sqrt(simulation.difficulty)))
for (let j = 0; j < nodes; j++) { for (let j = 0; j < nodes; j++) {
@@ -3911,7 +3951,9 @@ const spawn = {
me.onDeath = function() { me.onDeath = function() {
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)
}; };
me.damageReduction = 0.25
me.do = function() { me.do = function() {
// this.armor();
this.seePlayerCheckByDistance(); this.seePlayerCheckByDistance();
this.checkStatus(); this.checkStatus();
this.attraction(); this.attraction();
@@ -3988,7 +4030,7 @@ const spawn = {
bodyB: mob[mob.length - j], bodyB: mob[mob.length - j],
stiffness: stiffness stiffness: stiffness
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
} }
} }
}, },
@@ -4000,7 +4042,7 @@ const spawn = {
bodyB: mob[mob.length - i - 2], bodyB: mob[mob.length - i - 2],
stiffness: stiffness stiffness: stiffness
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
} }
if (nodes > 2) { if (nodes > 2) {
for (let i = 0; i < nodes - 2; ++i) { for (let i = 0; i < nodes - 2; ++i) {
@@ -4009,7 +4051,7 @@ const spawn = {
bodyB: mob[mob.length - i - 3], bodyB: mob[mob.length - i - 3],
stiffness: stiffness stiffness: stiffness
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
} }
} }
//optional connect the tail to head //optional connect the tail to head
@@ -4019,19 +4061,19 @@ const spawn = {
bodyB: mob[mob.length - nodes], bodyB: mob[mob.length - nodes],
stiffness: stiffness stiffness: stiffness
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
consBB[consBB.length] = Constraint.create({ consBB[consBB.length] = Constraint.create({
bodyA: mob[mob.length - 2], bodyA: mob[mob.length - 2],
bodyB: mob[mob.length - nodes], bodyB: mob[mob.length - nodes],
stiffness: stiffness stiffness: stiffness
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
consBB[consBB.length] = Constraint.create({ consBB[consBB.length] = Constraint.create({
bodyA: mob[mob.length - 1], bodyA: mob[mob.length - 1],
bodyB: mob[mob.length - nodes + 1], bodyB: mob[mob.length - nodes + 1],
stiffness: stiffness stiffness: stiffness
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
} }
}, },
constraintPB(x, y, bodyIndex, stiffness) { constraintPB(x, y, bodyIndex, stiffness) {
@@ -4043,7 +4085,7 @@ const spawn = {
bodyB: body[bodyIndex], bodyB: body[bodyIndex],
stiffness: stiffness stiffness: stiffness
}); });
World.add(engine.world, cons[cons.length - 1]); Composite.add(engine.world, cons[cons.length - 1]);
}, },
constraintBB(bodyIndexA, bodyIndexB, stiffness) { constraintBB(bodyIndexA, bodyIndexB, stiffness) {
consBB[consBB.length] = Constraint.create({ consBB[consBB.length] = Constraint.create({
@@ -4051,7 +4093,7 @@ const spawn = {
bodyB: body[bodyIndexB], bodyB: body[bodyIndexB],
stiffness: stiffness stiffness: stiffness
}); });
World.add(engine.world, consBB[consBB.length - 1]); Composite.add(engine.world, consBB[consBB.length - 1]);
}, },
// body and map spawns ****************************************************************************** // body and map spawns ******************************************************************************
//********************************************************************************************** //**********************************************************************************************

View File

@@ -157,8 +157,10 @@
for (i = 0, len = b.inventory.length; i < len; i++) { for (i = 0, len = b.inventory.length; i < len; i++) {
if (b.guns[b.inventory[i]].name === name) return true if (b.guns[b.inventory[i]].name === name) return true
} }
return false
} else {
return b.inventory.length > 0 && b.guns[b.activeGun].name === name
} }
return b.inventory.length > 0 && b.guns[b.activeGun].name === name
}, },
damageFromTech() { damageFromTech() {
let dmg = 1 //m.fieldDamage let dmg = 1 //m.fieldDamage
@@ -178,9 +180,9 @@
if (tech.isEnergyLoss) dmg *= 1.55; if (tech.isEnergyLoss) dmg *= 1.55;
if (tech.isAcidDmg && m.health > 1) dmg *= 1.35; if (tech.isAcidDmg && m.health > 1) dmg *= 1.35;
if (tech.restDamage > 1 && player.speed < 1) dmg *= tech.restDamage if (tech.restDamage > 1 && player.speed < 1) dmg *= tech.restDamage
if (tech.isEnergyDamage) dmg *= 1 + m.energy / 9; if (tech.isEnergyDamage) dmg *= 1 + m.energy / 11;
if (tech.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.005 if (tech.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.005
if (tech.isRerollDamage) dmg *= 1 + 0.04 * powerUps.research.count if (tech.isRerollDamage) dmg *= 1 + 0.037 * powerUps.research.count
if (tech.isOneGun && b.inventory.length < 2) dmg *= 1.23 if (tech.isOneGun && b.inventory.length < 2) dmg *= 1.23
if (tech.isNoFireDamage && m.cycle > m.fireCDcycle + 120) dmg *= 2 if (tech.isNoFireDamage && m.cycle > m.fireCDcycle + 120) dmg *= 2
if (tech.isSpeedDamage) dmg *= 1 + Math.min(0.66, player.speed * 0.0165) if (tech.isSpeedDamage) dmg *= 1 + Math.min(0.66, player.speed * 0.0165)
@@ -193,15 +195,21 @@
maxDuplicationEvent() { maxDuplicationEvent() {
if (tech.is100Duplicate && tech.duplicationChance() > 0.99) { if (tech.is100Duplicate && tech.duplicationChance() > 0.99) {
tech.is100Duplicate = false tech.is100Duplicate = false
const range = 450
spawn.randomLevelBoss(m.pos.x + range, m.pos.y, spawn.nonCollideBossList); const range = 550
spawn.randomLevelBoss(m.pos.x, m.pos.y + range, spawn.nonCollideBossList); for (let i = 0, len = 8; i < len; i++) {
spawn.randomLevelBoss(m.pos.x - range, m.pos.y, spawn.nonCollideBossList); const angle = 2 * Math.PI * i / len
spawn.randomLevelBoss(m.pos.x, m.pos.y - range, spawn.nonCollideBossList); spawn.randomLevelBoss(m.pos.x + range * Math.cos(angle), m.pos.y + range * Math.sin(angle), spawn.nonCollideBossList);
spawn.randomLevelBoss(m.pos.x + range, m.pos.y + range, spawn.nonCollideBossList); }
spawn.randomLevelBoss(m.pos.x + range, m.pos.y - range, spawn.nonCollideBossList);
spawn.randomLevelBoss(m.pos.x - range, m.pos.y + range, spawn.nonCollideBossList); // spawn.randomLevelBoss(m.pos.x + range, m.pos.y, spawn.nonCollideBossList);
spawn.randomLevelBoss(m.pos.x - range, m.pos.y - range, spawn.nonCollideBossList); // spawn.randomLevelBoss(m.pos.x, m.pos.y + range, spawn.nonCollideBossList);
// spawn.randomLevelBoss(m.pos.x - range, m.pos.y, spawn.nonCollideBossList);
// spawn.randomLevelBoss(m.pos.x, m.pos.y - range, spawn.nonCollideBossList);
// spawn.randomLevelBoss(m.pos.x + range, m.pos.y + range, spawn.nonCollideBossList);
// spawn.randomLevelBoss(m.pos.x + range, m.pos.y - range, spawn.nonCollideBossList);
// spawn.randomLevelBoss(m.pos.x - range, m.pos.y + range, spawn.nonCollideBossList);
// spawn.randomLevelBoss(m.pos.x - range, m.pos.y - range, spawn.nonCollideBossList);
} }
}, },
setTechFrequency(name, frequency) { setTechFrequency(name, frequency) {
@@ -1409,16 +1417,16 @@
}, },
{ {
name: "bot fabrication", name: "bot fabrication",
description: "anytime you collect <strong>3</strong> <strong class='color-r'>research</strong><br>use them to build a random <strong class='color-bot'>bot</strong>", description: "anytime you collect <strong>4</strong> <strong class='color-r'>research</strong><br>use them to build a random <strong class='color-bot'>bot</strong>",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
frequency: 2, frequency: 2,
frequencyDefault: 2, frequencyDefault: 2,
isBotTech: true, isBotTech: true,
allowed() { allowed() {
return powerUps.research.count > 2 || build.isExperimentSelection return powerUps.research.count > 3 || build.isExperimentSelection
}, },
requires: "at least 3 research", requires: "at least 4 research",
effect() { effect() {
tech.isRerollBots = true; tech.isRerollBots = true;
powerUps.research.changeRerolls(0) powerUps.research.changeRerolls(0)
@@ -2259,7 +2267,7 @@
}, },
{ {
name: "electrolytes", name: "electrolytes",
description: "increase <strong class='color-d'>damage</strong> by <strong>1%</strong><br>for every <strong>9</strong> stored <strong class='color-f'>energy</strong>", description: "increase <strong class='color-d'>damage</strong> by <strong>1%</strong><br>for every <strong>11</strong> stored <strong class='color-f'>energy</strong>",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
frequency: 2, frequency: 2,
@@ -2757,27 +2765,9 @@
tech.isImmortal = false; tech.isImmortal = false;
} }
}, },
{
name: "many-worlds",
description: "each <strong>level</strong> is an <strong class='alt'>alternate reality</strong>, where you<br>find a <strong class='color-m'>tech</strong> at the start of each level",
maxCount: 1,
count: 0,
frequency: 1,
frequencyDefault: 1,
allowed() {
return !tech.isResearchReality && !tech.isCollisionRealitySwitch
},
requires: "not Ψ(t) collapse, non-unitary",
effect() {
tech.isSwitchReality = true;
},
remove() {
tech.isSwitchReality = false;
}
},
{ {
name: "non-unitary operator", name: "non-unitary operator",
description: "reduce combat <strong>difficulty</strong> by <strong>2 levels</strong><br>after a <strong>collision</strong> enter an <strong class='alt'>alternate reality</strong>", description: "reduce combat <strong>difficulty</strong> by <strong>2 levels</strong>, but<br>after a <strong>collision</strong> enter an <strong class='alt'>alternate reality</strong>",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
frequency: 1, frequency: 1,
@@ -2797,6 +2787,25 @@
} }
} }
}, },
{
name: "many-worlds",
// description: "each <strong>level</strong> is an <strong class='alt'>alternate reality</strong>, where you<br>find a <strong class='color-m'>tech</strong> at the start of each level",
description: "on each new <strong>level</strong> use <strong>1</strong> <strong class='color-r'>research</strong> to enter an<br><strong class='alt'>alternate reality</strong> and spawn a <strong class='color-m'>tech</strong> power up",
maxCount: 1,
count: 0,
frequency: 1,
frequencyDefault: 1,
allowed() {
return !tech.isResearchReality && !tech.isCollisionRealitySwitch
},
requires: "not Ψ(t) collapse, non-unitary",
effect() {
tech.isSwitchReality = true;
},
remove() {
tech.isSwitchReality = false;
}
},
{ {
name: "Ψ(t) collapse", name: "Ψ(t) collapse",
description: "enter an <strong class='alt'>alternate reality</strong> after you <strong class='color-r'>research</strong><br>spawn <strong>16</strong> <strong class='color-r'>research</strong>", description: "enter an <strong class='alt'>alternate reality</strong> after you <strong class='color-r'>research</strong><br>spawn <strong>16</strong> <strong class='color-r'>research</strong>",
@@ -2818,7 +2827,7 @@
}, },
{ {
name: "decoherence", name: "decoherence",
description: "<strong class='color-r'>researched</strong> or <strong>canceled</strong> <strong class='color-m'>tech</strong> won't <strong>reoccur</strong> <br>spawn <strong>5</strong> <strong class='color-r'>research</strong>", description: "<strong class='color-r'>researched</strong> or <strong>canceled</strong> <strong class='color-m'>tech</strong> won't <strong>reoccur</strong> <br>spawn <strong>9</strong> <strong class='color-r'>research</strong>",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
frequency: 2, frequency: 2,
@@ -2829,7 +2838,7 @@
requires: "not determinism, at least 3 research", requires: "not determinism, at least 3 research",
effect() { effect() {
tech.isBanish = true tech.isBanish = true
for (let i = 0; i < 5; i++) powerUps.spawn(m.pos.x + 60 * (Math.random() - 0.5), m.pos.y + 60 * (Math.random() - 0.5), "research", false); for (let i = 0; i < 9; i++) powerUps.spawn(m.pos.x + 60 * (Math.random() - 0.5), m.pos.y + 60 * (Math.random() - 0.5), "research", false);
}, },
remove() { remove() {
tech.isBanish = false tech.isBanish = false
@@ -2896,7 +2905,7 @@
}, },
{ {
name: "Bayesian statistics", name: "Bayesian statistics",
description: "increase <strong class='color-d'>damage</strong> by <strong>4%</strong><br>for each <strong class='color-r'>research</strong> in your inventory", description: "increase <strong class='color-d'>damage</strong> by <strong>3.7%</strong><br>for each <strong class='color-r'>research</strong> in your inventory",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
frequency: 2, frequency: 2,
@@ -2945,7 +2954,7 @@
requires: "more than 6 tech", requires: "more than 6 tech",
effect: () => { effect: () => {
//remove active bullets //to get rid of bots //remove active bullets //to get rid of bots
for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]); for (let i = 0; i < bullet.length; ++i) Matter.Composite.remove(engine.world, bullet[i]);
bullet = []; bullet = [];
let count = 1 //count tech let count = 1 //count tech
for (let i = 0, len = tech.tech.length; i < len; i++) { // spawn new tech power ups for (let i = 0, len = tech.tech.length; i < len; i++) { // spawn new tech power ups
@@ -3409,7 +3418,7 @@
}, },
{ {
name: "dark patterns", name: "dark patterns",
description: "reduce combat <strong>difficulty</strong> by <strong>1 level</strong><br><strong>+21</strong> <strong class='color-j'>JUNK</strong> to the potential <strong class='color-m'>tech</strong> pool", description: "reduce combat <strong>difficulty</strong> by <strong>1 level</strong><br><strong>+31</strong> <strong class='color-j'>JUNK</strong> to the potential <strong class='color-m'>tech</strong> pool",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
frequency: 1, frequency: 1,
@@ -3427,7 +3436,7 @@
}, },
remove() { remove() {
if (this.count > 0) { if (this.count > 0) {
tech.removeJunkTechFromPool(21) tech.removeJunkTechFromPool(31)
level.difficultyIncrease(simulation.difficultyMode) level.difficultyIncrease(simulation.difficultyMode)
} }
} }
@@ -4444,7 +4453,7 @@
}, },
{ {
name: "booby trap", name: "booby trap",
description: "drop a <strong>mine</strong> after picking up a <strong>power up</strong><br><strong>+13</strong> <strong class='color-j'>JUNK</strong> to the potential <strong class='color-m'>tech</strong> pool", description: "drop a <strong>mine</strong> after picking up a <strong>power up</strong><br><strong>+23</strong> <strong class='color-j'>JUNK</strong> to the potential <strong class='color-m'>tech</strong> pool",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
frequency: 2, frequency: 2,
@@ -4456,7 +4465,7 @@
effect() { effect() {
tech.isMineDrop = true; tech.isMineDrop = true;
if (tech.isMineDrop) b.mine(m.pos, { x: 0, y: 0 }, 0, tech.isMineAmmoBack) if (tech.isMineDrop) b.mine(m.pos, { x: 0, y: 0 }, 0, tech.isMineAmmoBack)
tech.addJunkTechToPool(13) tech.addJunkTechToPool(23)
}, },
remove() { remove() {
tech.isMineDrop = false; tech.isMineDrop = false;
@@ -5954,7 +5963,7 @@
}, },
{ {
name: "virtual particles", name: "virtual particles",
description: "use <strong>3</strong> <strong class='color-r'>research</strong> to exploit your <strong>wormhole</strong> for a<br><strong>19%</strong> chance to <strong class='color-dup'>duplicate</strong> spawned <strong>power ups</strong>", description: "use <strong>3</strong> <strong class='color-r'>research</strong> to exploit your <strong>wormhole</strong> for a<br><strong>17%</strong> chance to <strong class='color-dup'>duplicate</strong> spawned <strong>power ups</strong>",
isFieldTech: true, isFieldTech: true,
maxCount: 1, maxCount: 1,
count: 0, count: 0,
@@ -5965,7 +5974,7 @@
}, },
requires: "wormhole,below 100% duplication chance", requires: "wormhole,below 100% duplication chance",
effect() { effect() {
tech.wormDuplicate = 0.19 tech.wormDuplicate = 0.17
powerUps.setDo(); //needed after adjusting duplication chance powerUps.setDo(); //needed after adjusting duplication chance
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
if (powerUps.research.count > 0) powerUps.research.changeRerolls(-1) if (powerUps.research.count > 0) powerUps.research.changeRerolls(-1)
@@ -6940,7 +6949,7 @@
body[index].collisionFilter.category = cat.body; body[index].collisionFilter.category = cat.body;
body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
body[index].classType = "body"; body[index].classType = "body";
World.add(engine.world, body[index]); //add to world Composite.add(engine.world, body[index]); //add to world
}, i * 100); }, i * 100);
} }

View File

@@ -1,19 +1,57 @@
******************************************************** NEXT PATCH ******************************************************** ******************************************************** NEXT PATCH ********************************************************
tech: chain reaction now requires vacuum bomb, but it increases grenade radius and damage 33% Matter.World has been replaced with Matter.Composite
(and makes blocks explode) matter.js deprecated World
could cause problems merging your old code
(replace World with Composite in your code)
needle gun fires with more regular timing tech: many worlds - now costs 1 research at the start of each level to activate
needles despawn 1.5s faster, for performance reasons a nerf, but also a buff because if you like a build you can freeze it by not getting research
intro level power ups are relocated
tech: decomposers renamed necrophage mine gun has 25% less ammo and 33% more damage
if mobs are one shotted before they see you, they no longer alert nearby mobs
clicking on a mob in testing will log that mob in console railgun now gets 50% more ammo, but it fires slower
fixed rail gun ammo drain on misfire bug
fixed experiment gun display bug
******************************************************** TODO ******************************************************** ******************************************************** TODO ********************************************************
dark mode
build color pallets in a photo editor by redrawing in game screenshots
what about just starting with setting the background to be a dark grey?
const color = {
map:
blocks:
background:
shadows: (0,0,0,0.1)?
bullets:
mob:
heal powerUps:
tech powerUps:
field powerUps:
gun powerUps:
damage circle:
harm circle:
}
re-word the "reduce difficulty" text, so it's more clear what you get
tech: Standing Wave: Shockwave. Use FIELD button to shrink your shield and charge up, release to unleash a Shockwave.
make an area that prevents mob vision, like a bush you can hide in
a static block with non collide on most things?
it would be helpful if there was a mechanism to recover mobs that fly off the map
add a ceiling system and a left/right walls system similar to the floor checks but only for mobs
make non moving bosses not move after getting hit
shooter, shielding,
buff missiles? buff missiles?
maybe they can release grenades after they explode, like CPT grenades? maybe they can release grenades after they explode, like CPT grenades?
make the crouch rapid fire a tech, and make the missiles fire faster, and use less ammo?
buff railgun
buff mines
make the player get a buff after using wormhole make the player get a buff after using wormhole
while energy lasts: drain energy and give damage buff while energy lasts: drain energy and give damage buff
@@ -193,9 +231,25 @@ n-gon outreach ideas
******************************************************** BUGS ******************************************************** ******************************************************** BUGS ********************************************************
map elements from labs not getting removed from matter.js, but they are removed from map[]
seems to always be the top right room near the center. why???
these 1-2 elements are probalby the last elements added to the engine
floor in labs loot room, showed up on warehouse map once, invisible
button floor and shelf that drops blocks from labs showed up invisible on next levels
2 thin floors in loot room, rectangles
2 of the 5 elements were not rectangles
is labs too big?
add a delay for loading maps?
Matter.World module has now been replaced by Matter.Composite (is this a possible fix?)
// for (let i = 0; i < array.length; ++i) Matter.World.remove(engine.world, array[i]);
for (let i = 0; i < array.length; ++i) Matter.Composite.remove(engine.world, array[i]);
sharing builds as html doesn't work for long lists... sharing builds as html doesn't work for long lists...
it shouldn't be sharing undefined at all it shouldn't be sharing undefined at all
probably some other problems too probably some other problems too
(might be fixed...)
blocks on buttons teleport into the button endlessly if they are being slowly floated away blocks on buttons teleport into the button endlessly if they are being slowly floated away
maybe add a cooldown? maybe add a cooldown?
@@ -203,7 +257,7 @@ blocks on buttons teleport into the button endlessly if they are being slowly fl
ants marching outline doesn't sync right on safari anymore. ants marching outline doesn't sync right on safari anymore.
door to exit in vats does nothing door to exit in level: vats does nothing
did I do that? did I do that?
death while in power up selection menu doesn't reset properly death while in power up selection menu doesn't reset properly