diff --git a/.DS_Store b/.DS_Store
index 3edfce3..a208d48 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/js/bullet.js b/js/bullet.js
index 6296e76..5b8132c 100644
--- a/js/bullet.js
+++ b/js/bullet.js
@@ -459,7 +459,7 @@ const b = {
},
pulse(charge, angle = m.angle, where = m.pos) {
let best;
- let explosionRadius = 6 * charge
+ let explosionRadius = 5.5 * charge
let range = 5000
const path = [{
x: where.x + 20 * Math.cos(angle),
@@ -547,7 +547,7 @@ const b = {
}
if (best.who) {
b.explosion(path[1], explosionRadius)
- const off = explosionRadius
+ const off = explosionRadius * 1.2
b.explosion({ x: path[1].x + off * (Math.random() - 0.5), y: path[1].y + off * (Math.random() - 0.5) }, explosionRadius)
b.explosion({ x: path[1].x + off * (Math.random() - 0.5), y: path[1].y + off * (Math.random() - 0.5) }, explosionRadius)
}
@@ -2107,7 +2107,7 @@ const b = {
}
}
//power ups
- if (!this.isImproved && !simulation.isChoosing && !tech.isArmorFromPowerUps) {
+ if (!this.isImproved && !simulation.isChoosing && !tech.isExtraMaxHealth) {
if (this.lockedOn) {
//grab, but don't lock onto nearby power up
for (let i = 0, len = powerUp.length; i < len; ++i) {
@@ -3623,7 +3623,7 @@ const b = {
}
}, {
name: "super balls",
- description: "fire four balls in a wide arc
balls bounce with no momentum loss",
+ description: "fire 3 balls in a wide arc
balls bounce with no momentum loss",
ammo: 0,
ammoPack: 11,
have: false,
diff --git a/js/level.js b/js/level.js
index f0df606..1d23970 100644
--- a/js/level.js
+++ b/js/level.js
@@ -21,13 +21,15 @@ const level = {
// b.giveGuns("grenades")
// tech.isExplodeRadio = true
// tech.giveTech("chain reaction")
- // tech.giveTech("MACHO")
+ // tech.giveTech("quenching")
+ // tech.giveTech("decoherence")
// tech.giveTech("supertemporal")
// for (let i = 0; i < 3; i++) tech.giveTech("packet length")
// for (let i = 0; i < 3; i++) tech.giveTech("propagation")
// for (let i = 0; i < 3; i++) tech.giveTech("bound state")
// for (let i = 0; i < 9; i++) tech.giveTech("WIMPs")
+
level.intro(); //starting level
// level.labs();
// level.testing(); //not in rotation, used for testing
@@ -54,6 +56,7 @@ const level = {
// level.vats() //community level
// level["n-gon"]() //community level
// level.tunnel() //community level
+ // for (let i = 0; i < 39; i++) powerUps.spawn(player.position.x + Math.random() * 50, player.position.y - Math.random() * 50, "tech", false);
// for (let i = 0; i < 7; i++) tech.giveTech("undefined")
// lore.techCount = 6
// localSettings.loreCount = 1;
@@ -77,8 +80,8 @@ const level = {
simulation.draw.setPaths();
b.respawnBots();
m.resetHistory();
- if (tech.isArmorFromPowerUps) {
- tech.armorFromPowerUps += Math.min(0.03 * powerUps.totalPowerUps, 0.51)
+ if (tech.isExtraMaxHealth) {
+ tech.extraMaxHealth += Math.min(0.03 * powerUps.totalPowerUps, 0.51)
m.setMaxHealth();
}
if (tech.isGunCycle) {
@@ -1101,16 +1104,25 @@ const level = {
const y = offset.y
level.setPosToSpawn(x + 2300, y - 800);
spawn.mapRect(level.enter.x, level.enter.y + 20, 100, 20);
- spawn.mapRect(x + 1450, y - 750, 1300, 50); //entrance shelf
spawn.mapRect(x + 1850, y - 1350, 50, 450); //entrance left wall
spawn.bodyRect(x + 1860, y - 900, 30, 150); //entrance door
spawn.mapRect(x + 2000, y - 350, 750, 150); //toggle shelf
const toggle = level.toggle(x + 2050, y - 350, true) //(x,y,isOn,isLockOn = true/false)
- const hazard = level.hazard(x + 1040, y - 660, 1700, 10, 0.4) //laser
- spawn.mapRect(x + 1050, y - 665, 10, 20); //laser nose
- spawn.mapRect(x + 650, y - 705, 400, 100); //laser body
+ let hazard
+ if (Math.random() > 0.5) {
+ spawn.mapRect(x + 550, y - 750, 2200, 50); //entrance shelf
+ hazard = level.hazard(x + 850, y - 920, 1000, 10, 0.4) //laser
+ spawn.mapRect(x + 860, y - 925, 10, 20); //laser nose
+ spawn.mapRect(x + 660, y - 975, 200, 120); //laser body
+ } else {
+ spawn.mapRect(x + 1450, y - 750, 1300, 50); //entrance shelf
+ hazard = level.hazard(x + 1040, y - 660, 1700, 10, 0.4) //laser
+ spawn.mapRect(x + 1050, y - 665, 10, 20); //laser nose
+ spawn.mapRect(x + 650, y - 705, 400, 100); //laser body
+ }
+
const hazard2 = level.hazard(x - 150, y - 330, 600, 10, 0.4) //laser
spawn.mapRect(x + 440, y - 335, 10, 20); //laser nose
spawn.mapRect(x + 450, y - 375, 400, 100); //laser body
@@ -1118,8 +1130,10 @@ const level = {
const Xoffset = Math.floor(400 * Math.random())
const hazard3 = level.hazard(x + Xoffset, y - 1300, 10, 1300, 0.4) //laser
spawn.mapRect(x + Xoffset - 5, y - 1310, 20, 20); //laser nose
- const hazard4 = level.hazard(x + 2100, y - 200, 10, 200, 0.4) //laser
- spawn.mapRect(x + 2100 - 5, y - 210, 20, 20); //laser nose
+
+ const Xoffset2 = 2050 + Math.floor(550 * Math.random())
+ const hazard4 = level.hazard(x + Xoffset2, y - 200, 10, 200, 0.4) //laser
+ spawn.mapRect(x + Xoffset2 - 5, y - 210, 20, 20); //laser nose
spawn.randomSmallMob(x + 2225, y - 100);
spawn.randomMob(x + 0, y - 125, 0);
@@ -1149,7 +1163,7 @@ const level = {
// }
]
exitOptions = [
- () => { //9 spinners
+ () => { //8 spinners
const x = offset.x
const y = offset.y
level.exit.x = x + 1250;
@@ -1225,6 +1239,78 @@ const level = {
ctx.fill();
}
)
+ },
+ () => { //7 spinners
+ const x = offset.x
+ const y = offset.y
+ level.exit.x = x + 2450;
+ level.exit.y = y - 980;
+ spawn.mapRect(level.exit.x, level.exit.y + 20, 100, 20);
+ spawn.mapRect(x + 2250, y - 950, 500, 25); //exit platform
+ spawn.mapRect(x + 2300, y - 1300, 25, 175); //exit side wall
+
+ spawn.bodyRect(x + 1275, y - 475, 125, 125, 0.25);
+ spawn.bodyRect(x + 1825, y - 125, 125, 125, 0.25);
+ spawn.bodyRect(x + 500, y - 100, 125, 100, 0.25);
+ spawn.bodyRect(x + 0, y - 150, 100, 150, 0.25);
+ spawn.bodyRect(x + 2375, y - 150, 125, 150, 0.25);
+
+ if (Math.random() > 0.5) {
+ const density = 0.0013
+ const angle = Math.PI / 2
+ const variance = 0.3 //Math.PI
+ const frictionAir = 0.01
+ balance1 = level.spinner(x + 1150, y - 500, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir) // spinner(x, y, width, height, density = 0.001, angle=0,frictionAir=0.001,angularVelocity=0) {
+ balance3 = level.spinner(x + 600, y - 600, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ balance2 = level.spinner(x + 125, y - 850, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ balance4 = level.spinner(x + 650, y - 1145, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ balance5 = level.spinner(x + 1100, y - 1145, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ balance6 = level.spinner(x + 1550, y - 1145, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ balance7 = level.spinner(x + 2000, y - 1145, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ } else {
+ const density = 0.0013
+ const angle = Math.PI / 2
+ const variance = 0 //Math.PI
+ const frictionAir = 0.01
+ balance1 = level.spinner(x + 150, y - 500, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir) // spinner(x, y, width, height, density = 0.001, angle=0,frictionAir=0.001,angularVelocity=0) {
+ balance2 = level.spinner(x + 2300, y - 550, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ balance4 = level.spinner(x + 1850, y - 550, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ balance3 = level.spinner(x + 650, y - 700, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ balance5 = level.spinner(x + 1100, y - 900, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ balance6 = level.spinner(x + 1550, y - 900, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ balance7 = level.spinner(x + 1970, y - 1150, 25, 410, density, angle + variance * (Math.random() - 0.5), frictionAir)
+ }
+ spawn.randomMob(x + 1175, y - 725, 0.1);
+ spawn.randomMob(x + 1450, y - 725, 0.2);
+ spawn.randomMob(x + 425, y - 100, 0.3);
+ spawn.randomMob(x + 2300, y - 125, 0.4);
+ spawn.randomMob(x + 1300, y - 375, 0.5);
+ doCustom.push(
+ () => {
+ ctx.fillStyle = "#d4f4f4"
+ ctx.fillRect(x + 2300, y - 1300, 400, 350)
+ }
+ )
+ doCustomTopLayer.push(
+ () => {
+ ctx.fillStyle = "#233"
+ ctx.beginPath();
+ ctx.arc(balance1.pointA.x, balance1.pointA.y, 9, 0, 2 * Math.PI);
+ ctx.moveTo(balance2.pointA.x, balance2.pointA.y)
+ ctx.arc(balance2.pointA.x, balance2.pointA.y, 9, 0, 2 * Math.PI);
+ ctx.moveTo(balance3.pointA.x, balance3.pointA.y)
+ ctx.arc(balance3.pointA.x, balance3.pointA.y, 9, 0, 2 * Math.PI);
+ ctx.moveTo(balance4.pointA.x, balance4.pointA.y)
+ ctx.arc(balance4.pointA.x, balance4.pointA.y, 9, 0, 2 * Math.PI);
+ ctx.moveTo(balance5.pointA.x, balance5.pointA.y)
+ ctx.arc(balance5.pointA.x, balance5.pointA.y, 9, 0, 2 * Math.PI);
+ ctx.moveTo(balance6.pointA.x, balance6.pointA.y)
+ ctx.arc(balance6.pointA.x, balance6.pointA.y, 9, 0, 2 * Math.PI);
+ ctx.moveTo(balance7.pointA.x, balance7.pointA.y)
+ ctx.arc(balance7.pointA.x, balance7.pointA.y, 9, 0, 2 * Math.PI);
+ ctx.fill();
+ }
+ )
}
]
emptyOptions = [ //nothing good here
@@ -1245,7 +1331,17 @@ const level = {
() => {
const x = offset.x
const y = offset.y
- if (simulation.difficulty > 3) spawn.randomLevelBoss(x + 1250, y - 600);
+
+
+ const elevator = level.elevator(x + 1200, y - 100, 380, 50, -2000, 0.001) // elevator(x, y, width, height, maxHeight, force = 0.003, friction = { up: 0.01, down: 0.2 }, isTeleport = false) {
+
+ // if (simulation.difficulty > 3)
+ spawn.randomLevelBoss(x + 1250, y - 1400);
+ doCustomTopLayer.push(
+ () => {
+ elevator.move()
+ }
+ )
}
]
@@ -1273,8 +1369,7 @@ const level = {
if (rooms[i] === "empty") rooms[i] = empty
if (rooms[i] === "loot") rooms[i] = loot
}
- //*********************************DON"T RUN THIS LINE IN THE FINAL VERSION ***************************************
- rooms = [exit, enter, empty, loot] //this is used to control what level spawns while building
+ rooms = [empty, loot, exit, enter, ] //controls what level spawns for map designing building //********************************* DO !NOT! RUN THIS LINE IN THE FINAL VERSION ***************************************
outlineDoors = () => {
spawn.mapRect(offset.x - 200, offset.y, 3000, 100); //floor
@@ -1290,52 +1385,53 @@ const level = {
}
}
outlineUpDown = () => {
- spawn.mapRect(offset.x - 200, offset.y + 1400, 3000, 100); //floor
- spawn.mapRect(offset.x - 200, offset.y - 1400, 3000, 100); //ceiling
- if (!isDoorLeft) spawn.mapRect(offset.x - 200, offset.y - 1400, 100, 2800); //left wall
+ spawn.mapRect(offset.x - 200, offset.y + 0, 3000, 100); //floor
+ spawn.mapRect(offset.x - 200, offset.y - 2800, 3000, 100); //ceiling
+ if (!isDoorLeft) spawn.mapRect(offset.x - 200, offset.y - 2800, 100, 2800); //left wall
if (isDoorRight) { //if door only add wall on right side
//upper door
+ spawn.mapRect(offset.x + 2700, offset.y - 2800, 100, 1225); //right wall
+ spawn.mapRect(offset.x + 2700, offset.y - 1410, 100, 20); //right doorstep
+ const doorWidth = 15 + Math.floor(100 * Math.random() * Math.random())
+ spawn.bodyRect(offset.x + 2750 - doorWidth / 2, offset.y - 1225, doorWidth, 165); //block door
+ //lower door
spawn.mapRect(offset.x + 2700, offset.y - 1400, 100, 1225); //right wall
spawn.mapRect(offset.x + 2700, offset.y - 10, 100, 20); //right doorstep
- const doorWidth = 15 + Math.floor(100 * Math.random() * Math.random())
- spawn.bodyRect(offset.x + 2750 - doorWidth / 2, offset.y - 175, doorWidth, 165); //block door
- //lower door
- spawn.mapRect(offset.x + 2700, offset.y - 1400 + 1400, 100, 1225); //right wall
- spawn.mapRect(offset.x + 2700, offset.y - 10 + 1400, 100, 20); //right doorstep
const doorWidth2 = 15 + Math.floor(100 * Math.random() * Math.random())
- spawn.bodyRect(offset.x + 2750 - doorWidth2 / 2, offset.y - 175 + 1400, doorWidth2, 165); //block door
+ spawn.bodyRect(offset.x + 2750 - doorWidth2 / 2, offset.y - 175, doorWidth2, 165); //block door
} else {
- spawn.mapRect(offset.x + 2700, offset.y - 1400, 100, 2800); //right wall
+ spawn.mapRect(offset.x + 2700, offset.y - 2800, 100, 2800); //right wall
}
}
let rows = [
() => {
offset.y = 0
- rooms[0]()
- outlineDoors()
-
- offset.y = -1400
- rooms[1]()
- outlineDoors()
- },
- () => {
- offset.y = -1400
- upDown()
outlineUpDown()
+ upDown()
},
() => {
offset.y = 0
- rooms[2]()
outlineDoors()
+ rooms[0]()
offset.y = -1400
- rooms[3]()
outlineDoors()
+ rooms[1]()
+ },
+ () => {
+ offset.y = 0
+ outlineDoors()
+ rooms[2]()
+
+ offset.y = -1400
+ outlineDoors()
+ rooms[3]()
}
]
- //*********************************RUN THIS LINE IN THE FINAL VERSION ***************************************
- // rows = shuffle(rows)
+
+ // rows = shuffle(rows) //********************************* RUN THIS LINE IN THE FINAL VERSION ***************************************
+
for (let i = 0; i < 3; i++) {
if (i === 0) {
isDoorLeft = false
@@ -1360,6 +1456,8 @@ const level = {
for (let i = 0, len = doCustomTopLayer.length; i < len; i++) doCustomTopLayer[i]() //runs all the active code from each room
};
powerUps.addResearchToLevel() //needs to run after mobs are spawned
+
+ level.setPosToSpawn(0, 0); //********************************* DO !NOT! RUN THIS LINE IN THE FINAL VERSION ***************************************
},
null() {
level.levels.pop(); //remove lore level from rotation
diff --git a/js/player.js b/js/player.js
index f29205c..c6f6036 100644
--- a/js/player.js
+++ b/js/player.js
@@ -174,20 +174,8 @@ const m = {
transSmoothY: 0,
lastGroundedPositionY: 0,
// mouseZoom: 0,
- look() {
- //always on mouse look
- m.angle = Math.atan2(
- simulation.mouseInGame.y - m.pos.y,
- simulation.mouseInGame.x - m.pos.x
- );
- //smoothed mouse look translations
- const scale = 0.8;
- m.transSmoothX = canvas.width2 - m.pos.x - (simulation.mouse.x - canvas.width2) * scale;
- m.transSmoothY = canvas.height2 - m.pos.y - (simulation.mouse.y - canvas.height2) * scale;
-
- m.transX += (m.transSmoothX - m.transX) * 0.07;
- m.transY += (m.transSmoothY - m.transY) * 0.07;
- },
+ lookSmoothing: 0.07, //1 is instant jerky, 0.001 is slow smooth zoom, 0.07 is standard
+ look() {}, //set to lookDefault()
lookDefault() {
//always on mouse look
m.angle = Math.atan2(
@@ -199,8 +187,8 @@ const m = {
m.transSmoothX = canvas.width2 - m.pos.x - (simulation.mouse.x - canvas.width2) * scale;
m.transSmoothY = canvas.height2 - m.pos.y - (simulation.mouse.y - canvas.height2) * scale;
- m.transX += (m.transSmoothX - m.transX) * 0.07;
- m.transY += (m.transSmoothY - m.transY) * 0.07;
+ m.transX += (m.transSmoothX - m.transX) * m.lookSmoothing;
+ m.transY += (m.transSmoothY - m.transY) * m.lookSmoothing;
},
doCrouch() {
if (!m.crouch) {
@@ -333,7 +321,7 @@ const m = {
// tech.addLoreTechToPool();
// tech.removeJunkTechFromPool();
tech.cancelCount = 0;
- tech.armorFromPowerUps = 0;
+ tech.extraMaxHealth = 0;
tech.totalCount = 0;
const randomBotCount = b.totalBots()
b.zeroBotCount()
@@ -485,7 +473,7 @@ const m = {
},
baseHealth: 1,
setMaxHealth() {
- m.maxHealth = m.baseHealth + tech.armorFromPowerUps + tech.isFallingDamage //+ tech.bonusHealth
+ m.maxHealth = m.baseHealth + tech.extraMaxHealth + tech.isFallingDamage //+ tech.bonusHealth
document.getElementById("health-bg").style.width = `${Math.floor(300*m.maxHealth)}px`
simulation.makeTextLog(`m.maxHealth = ${m.maxHealth.toFixed(2)}`)
if (m.health > m.maxHealth) m.health = m.maxHealth;
@@ -1250,9 +1238,9 @@ const m = {
const dyP = m.pos.y - powerUp[i].position.y;
const dist2 = dxP * dxP + dyP * dyP;
// float towards player if looking at and in range or if very close to player
- if (dist2 < m.grabPowerUpRange2 &&
+ if (
+ dist2 < m.grabPowerUpRange2 &&
(m.lookingAt(powerUp[i]) || dist2 < 16000) &&
- !(m.health === m.maxHealth && powerUp[i].name === "heal") &&
Matter.Query.ray(map, powerUp[i].position, m.pos).length === 0
) {
powerUp[i].force.x += 0.05 * (dxP / Math.sqrt(dist2)) * powerUp[i].mass;
@@ -1262,7 +1250,11 @@ const m = {
x: powerUp[i].velocity.x * 0.11,
y: powerUp[i].velocity.y * 0.11
});
- if (dist2 < 5000 && !simulation.isChoosing) { //use power up if it is close enough
+ if ( //use power up if it is close enough
+ dist2 < 5000 &&
+ !simulation.isChoosing &&
+ !(m.health === m.maxHealth && powerUp[i].name === "heal" && !tech.isOverHeal)
+ ) {
powerUps.onPickUp(powerUp[i]);
Matter.Body.setVelocity(player, { //player knock back, after grabbing power up
x: player.velocity.x + powerUp[i].velocity.x / player.mass * 5,
@@ -1320,6 +1312,8 @@ const m = {
x: player.velocity.x - (15 * unit.x) / massRoot,
y: player.velocity.y - (15 * unit.y) / massRoot
});
+ if (mob[i].isOrbital) Matter.Body.setVelocity(who, { x: 0, y: 0 });
+
if (m.crouch) {
Matter.Body.setVelocity(player, {
x: player.velocity.x + 0.1 * m.blockingRecoil * unit.x * massRoot,
@@ -1338,6 +1332,8 @@ const m = {
x: player.velocity.x - (20 * unit.x) / massRoot,
y: player.velocity.y - (20 * unit.y) / massRoot
});
+ if (mob[i].isOrbital) Matter.Body.setVelocity(who, { x: 0, y: 0 });
+
if (who.isDropPowerUp && player.speed < 12) {
const massRootCap = Math.sqrt(Math.min(10, Math.max(0.4, who.mass))); // masses above 12 can start to overcome the push back
Matter.Body.setVelocity(player, {
@@ -2946,7 +2942,6 @@ const m = {
const d = Math.max(dx * dx, dy * dy)
simulation.edgeZoomOutSmooth = (1 + 4 * d * d) * 0.04 + simulation.edgeZoomOutSmooth * 0.96
-
ctx.save();
ctx.translate(canvas.width2, canvas.height2); //center
ctx.scale(simulation.zoom / simulation.edgeZoomOutSmooth, simulation.zoom / simulation.edgeZoomOutSmooth); //zoom in once centered
diff --git a/js/powerup.js b/js/powerup.js
index 7cb9513..2fee77a 100644
--- a/js/powerup.js
+++ b/js/powerup.js
@@ -275,14 +275,32 @@ const powerUps = {
size() {
return 40 * (simulation.healScale ** 0.25) * Math.sqrt(tech.largerHeals) * Math.sqrt(0.1 + Math.random() * 0.5); //(simulation.healScale ** 0.25) gives a smaller radius as heal scale goes down
},
+ calculateHeal(size) {
+ return tech.largerHeals * (size / 40 / Math.sqrt(tech.largerHeals) / (simulation.healScale ** 0.25)) ** 2 //heal scale is undone here because heal scale is properly affected on m.addHealth()
+ },
effect() {
if (!tech.isEnergyHealth && m.alive) {
- const heal = tech.largerHeals * (this.size / 40 / Math.sqrt(tech.largerHeals) / (simulation.healScale ** 0.25)) ** 2 //heal scale is undone here because heal scale is properly affected on m.addHealth()
+ const heal = powerUps.heal.calculateHeal(this.size)
if (heal > 0) {
- const healOutput = Math.min(m.maxHealth - m.health, heal) * simulation.healScale
- m.addHealth(heal);
- simulation.makeTextLog(`m.health += ${(healOutput).toFixed(3)}`) //
${m.health.toFixed(3)}
- // simulation.makeTextLog("