lore disabled" : ""}
const el = document.getElementById("pause-grid-right")
el.style.display = "grid"
el.innerHTML = text
+
+ //add event listener for pressing enter key when in sort
+ function pressEnterSort(event) {
+ if (event.key === 'Enter') {
+ requestAnimationFrame(() => { document.getElementById("sort-input").focus(); });
+ // event.preventDefault(); // Prevent the default action to avoid form submission or any other default action
+ build.sortTech('input')
+ }
+ }
+ document.getElementById("sort-input").addEventListener('keydown', pressEnterSort);
+ requestAnimationFrame(() => { document.getElementById("sort-input").focus(); });
},
sortTech(find, isExperiment = false) {
const sortKeyword = (a, b) => {
@@ -621,6 +607,16 @@ ${simulation.isCheating ? "
lore disabled" : ""}
if (!aHasKeyword && bHasKeyword) return 1;
return 0;
}
+
+ // if (find === '') {
+ // tech.tech.sort((a, b) => { //sorts tech into the order the player got them using tech.tech[i].cycle = m.cycle
+ // console.log(a.cycle, b.cycle)
+ // if (a.cycle === undefined && b.cycle !== undefined) return -1;
+ // if (a.cycle !== undefined && b.cycle === undefined) return 1;
+ // if (a.cycle === undefined && b.cycle === undefined) return 0;
+ // if (a.cycle !== b.cycle) return a.cycle - b.cycle;
+ // });
+ // } else
if (find === 'guntech') {
tech.tech.sort((a, b) => {
if (a.isGunTech && b.isGunTech) {
@@ -704,6 +700,7 @@ ${simulation.isCheating ? "
lore disabled" : ""}
build.generatePauseRight() //makes the right side of the pause menu with the tech
}
document.getElementById("sort-input").value = find; //make the sorted string display in the keyword search input field
+ simulation.updateTechHUD();
},
unPauseGrid() {
document.getElementById("guns").style.display = "inline"
@@ -961,10 +958,17 @@ ${simulation.isCheating ? "
lore disabled" : ""}
}
}
document.getElementById("experiment-grid").innerHTML = text
- // for (let i = 0, len = tech.tech.length; i < len; i++) {
- // if (tech.tech[i].count)
- // document.getElementById("tech-" + i).classList.add("build-tech-selected")
- // }
+
+
+
+ //add event listener for pressing enter key when in sort
+ function pressEnterSort(event) {
+ if (event.key === 'Enter') {
+ // event.preventDefault(); // Prevent the default action to avoid form submission or any other default action
+ build.sortTech('input', true)
+ }
+ }
+ document.getElementById("sort-input").addEventListener('keydown', pressEnterSort);
document.getElementById("difficulty-select-experiment").value = document.getElementById("difficulty-select").value
document.getElementById("difficulty-select-experiment").addEventListener("input", () => {
@@ -1348,12 +1352,15 @@ window.addEventListener("keydown", function (event) {
simulation.previousGun();
break
case input.key.pause:
- if (!simulation.isChoosing && input.isPauseKeyReady && m.alive) {
+
+ if (input.isPauseKeyReady && m.alive && !build.isExperimentSelection) {
input.isPauseKeyReady = false
- setTimeout(function () {
- input.isPauseKeyReady = true
- }, 300);
- if (simulation.paused) {
+ setTimeout(function () { input.isPauseKeyReady = true }, 300);
+ if (simulation.isChoosing) {
+
+ build.pauseGrid()
+
+ } else if (simulation.paused) {
build.unPauseGrid()
simulation.paused = false;
// level.levelAnnounce();
@@ -1404,7 +1411,7 @@ window.addEventListener("keydown", function (event) {
}
break
case input.key.testing:
- if (m.alive && localSettings.loreCount > 0 && !simulation.paused) {
+ if (m.alive && localSettings.loreCount > 0 && !simulation.paused && !build.isExperimentSelection) {
if (simulation.difficultyMode > 4) {
simulation.makeTextLog("testing mode disabled for this difficulty");
break
diff --git a/js/level.js b/js/level.js
index cfb4fba..884f39a 100644
--- a/js/level.js
+++ b/js/level.js
@@ -33,26 +33,25 @@ const level = {
// m.energy = 0
// simulation.molecularMode = 2
// m.damage(0.1);
- // b.giveGuns("drones") //0 nail gun 1 shotgun 2 super balls 3 wave 4 missiles 5 grenades 6 spores 7 drones 8 foam 9 harpoon 10 mine 11 laser
+ // b.giveGuns("mine") //0 nail gun 1 shotgun 2 super balls 3 wave 4 missiles 5 grenades 6 spores 7 drones 8 foam 9 harpoon 10 mine 11 laser
// b.giveGuns("laser") //0 nail gun 1 shotgun 2 super balls 3 wave 4 missiles 5 grenades 6 spores 7 drones 8 foam 9 harpoon 10 mine 11 laser
// b.guns[8].ammo = 100000000
- // requestAnimationFrame(() => { tech.giveTech("Higgs mechanism") });
- // for (let i = 0; i < 1; ++i) tech.giveTech("flame test")
- // for (let i = 0; i < 1; ++i) tech.giveTech("dazzler")
- // for (let i = 0; i < 1; ++i) tech.giveTech("mass production")
- // requestAnimationFrame(() => { for (let i = 0; i < 10; i++) tech.giveTech("orbital-bot") });
+ // requestAnimationFrame(() => { tech.giveTech("eternalism") });
+ // for (let i = 0; i < 1; ++i) tech.giveTech("beforeunload")
+ // for (let i = 0; i < 1; ++i) tech.giveTech("Sleipnir")
+ // for (let i = 0; i < 1; ++i) tech.giveTech("dark patterns")
+ // requestAnimationFrame(() => { for (let i = 0; i < 1; i++) tech.giveTech("paradigm shift") });
// requestAnimationFrame(() => { for (let i = 0; i < 10; i++) b.orbitBot(m.pos, false) });
// m.skin.hexagon();
-
// for (let i = 0; i < 1; i++) tech.giveTech("tungsten carbide")
// m.lastKillCycle = m.cycle
- // for (let i = 0; i < 1; ++i) tech.giveTech("swarf")
+ // for (let i = 0; i < 1; ++i) tech.giveTech("what the block?")
// for (let i = 0; i < 1; ++i) tech.giveTech("unified field theory")
// for (let i = 0; i < 3; i++) powerUps.directSpawn(450, -50, "tech");
// for (let i = 0; i < 10; i++) powerUps.directSpawn(1750, -500, "research");
// for (let i = 0; i < 100; i++) powerUps.directSpawn(1750, -500, "coupling");
// spawn.mapRect(575, -700, 25, 425); //block mob line of site on testing
- // level.testing();
+ // level.testChamber();
// for (let i = 0; i < 1; ++i) spawn.laserLayer(1400, -500)
// Matter.Body.setPosition(player, { x: -200, y: -3330 });
@@ -75,7 +74,7 @@ const level = {
// simulation.isAutoZoom = false; //look in close
// simulation.zoomScale *= 0.5;
// simulation.setZoom();
- // for (let i = 0; i < 2; ++i) powerUps.directSpawn(m.pos.x + 50 * Math.random(), m.pos.y + 50 * Math.random(), "tech");
+ // for (let i = 0; i < 10; ++i) powerUps.directSpawn(m.pos.x + 50 * Math.random(), m.pos.y + 50 * Math.random(), "tech");
// for (let i = 0; i < 2; ++i) powerUps.directSpawn(m.pos.x + 450, m.pos.y + 50 * Math.random(), "boost");
// for (let i = 0; i < 20; ++i) powerUps.directSpawn(m.pos.x + 50 * Math.random(), m.pos.y + 50 * Math.random(), "heal");
// for (let i = 0; i < 2; i++) powerUps.spawn(player.position.x + Math.random() * 50, player.position.y - Math.random() * 50, "field", false);
@@ -1570,7 +1569,6 @@ const level = {
}
}
}
- // if (body.length) {
for (let i = 0, len = body.length; i < len; i++) {
if (body[i] !== m.holdingTarget) {
// body[i].bounds.max.x - body[i].bounds.min.x < 100 && body[i].bounds.max.y - body[i].bounds.min.y < 100
@@ -1591,17 +1589,20 @@ const level = {
}
//rotate velocity
let mag
- if (this.portalPair.angle !== 0 && this.portalPair.angle !== Math.PI) { //portal that fires the player up
+ if (this.portalPair.angle !== 0 && this.portalPair.angle !== Math.PI) { //portal that fires up
mag = Math.max(10, Math.min(50, body[i].velocity.y * 0.8)) + 11
+ let v = Vector.mult(this.portalPair.unit, mag)
+ //rotate the velocity vector of blocks fired directly up to keep them from getting stuck endlessly in vertical portals
+ Matter.Body.setVelocity(body[i], Vector.rotate(v, 0.5 * (Math.random() - 0.5)));
} else {
mag = Math.max(6, Math.min(50, Vector.magnitude(body[i].velocity)))
+ let v = Vector.mult(this.portalPair.unit, mag)
+ Matter.Body.setVelocity(body[i], v);
}
- let v = Vector.mult(this.portalPair.unit, mag)
- Matter.Body.setVelocity(body[i], v);
+
}
}
}
- // }
//remove block if touching
// if (body.length) {
diff --git a/js/player.js b/js/player.js
index afdab53..e65d5af 100644
--- a/js/player.js
+++ b/js/player.js
@@ -362,10 +362,10 @@ const m = {
// tech.removeLoreTechFromPool();
// tech.addLoreTechToPool();
// tech.removeJunkTechFromPool();
+ tech.junkChance = 0;
tech.duplication = 0;
tech.extraMaxHealth = 0;
tech.totalCount = 0;
- tech.countJunkTech();
const randomBotCount = b.totalBots()
b.zeroBotCount()
//remove all bullets, respawn bots
@@ -547,7 +547,6 @@ const m = {
if (m.health > m.maxHealth) m.health = m.maxHealth;
m.displayHealth();
},
-
defaultFPSCycle: 0, //tracks when to return to normal fps
immuneCycle: 0, //used in engine
lastCalculatedDamage: 0, //used to decided if damage bar needs to be redrawn (in simulation.checks)
@@ -2329,7 +2328,8 @@ const m = {
m.isHolding = false
}
},
- throwBlock() {
+ throwBlock() { },
+ throwBlockDefault() {
if (m.holdingTarget) {
if (input.field) {
if (m.energy > 0.001) {
@@ -2478,6 +2478,116 @@ const m = {
m.isHolding = false
}
},
+ throwSelf() {
+ if (m.holdingTarget) {
+ if (input.field) {
+ if (m.energy > 0.001) {
+ if (m.fireCDcycle < m.cycle) m.fireCDcycle = m.cycle
+ if (tech.isCapacitor && m.throwCharge < 4) m.throwCharge = 4
+ m.throwCharge += 0.5 / m.holdingTarget.mass / b.fireCDscale
+ if (m.throwCharge < 6) m.energy -= 0.001 / b.fireCDscale; // m.throwCharge caps at 5
+
+ //trajectory path prediction
+ //draw charge
+ const x = m.pos.x + 15 * Math.cos(m.angle);
+ const y = m.pos.y + 15 * Math.sin(m.angle);
+ const len = m.holdingTarget.vertices.length - 1;
+ const edge = m.throwCharge * m.throwCharge * m.throwCharge;
+ const grd = ctx.createRadialGradient(x, y, edge, x, y, edge + 5);
+ grd.addColorStop(0, "rgba(255,50,150,0.3)");
+ grd.addColorStop(1, "transparent");
+ ctx.fillStyle = grd;
+ ctx.beginPath();
+ ctx.moveTo(x, y);
+ ctx.lineTo(m.holdingTarget.vertices[len].x, m.holdingTarget.vertices[len].y);
+ ctx.lineTo(m.holdingTarget.vertices[0].x, m.holdingTarget.vertices[0].y);
+ ctx.fill();
+ for (let i = 0; i < len; i++) {
+ ctx.beginPath();
+ ctx.moveTo(x, y);
+ ctx.lineTo(m.holdingTarget.vertices[i].x, m.holdingTarget.vertices[i].y);
+ ctx.lineTo(m.holdingTarget.vertices[i + 1].x, m.holdingTarget.vertices[i + 1].y);
+ ctx.fill();
+ }
+ //trajectory prediction
+ const cycles = 30
+ const charge = Math.min(m.throwCharge / 5, 1)
+ const speed = (tech.isPrinter ? 15 + 80 * charge * Math.min(0.85, 0.8 / Math.pow(m.holdingTarget.mass, 0.1)) : 80 * charge * Math.min(0.85, 0.8 / Math.pow(m.holdingTarget.mass, 0.25)))
+ const v = { x: speed * Math.cos(m.angle), y: speed * Math.sin(m.angle) }
+ ctx.beginPath()
+ for (let i = 1, len = 10; i < len + 1; i++) {
+ const time = cycles * i / len
+ ctx.lineTo(m.pos.x + time * v.x, m.pos.y + time * v.y + 0.34 * time * time)
+ }
+ ctx.strokeStyle = "rgba(68, 68, 68, 0.15)" //color.map
+ ctx.lineWidth = 2
+ ctx.stroke()
+
+ } else {
+ m.drop()
+ }
+ } else if (m.throwCharge > 0) { //Matter.Query.region(mob, player.bounds)
+ if (m.holdingTarget.isPrinted) m.holdingTarget.isPrinted = undefined
+ //throw the body
+ m.fieldCDcycle = m.cycle + 20;
+ m.fireCDcycle = m.cycle + 20;
+
+ m.isHolding = false;
+ //bullet-like collisions
+ m.holdingTarget.collisionFilter.category = cat.bullet
+ m.holdingTarget.collisionFilter.mask = cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield;
+ if (tech.isBlockRestitution) {
+ m.holdingTarget.restitution = 0.999 //extra bouncy
+ m.holdingTarget.friction = m.holdingTarget.frictionStatic = m.holdingTarget.frictionAir = 0.001
+ }
+ //check every second to see if player is away from thrown body, and make solid
+ const solid = function (that) {
+ const dx = that.position.x - player.position.x;
+ const dy = that.position.y - player.position.y;
+ // if (that.speed < 3 && dx * dx + dy * dy > 10000 && that !== m.holdingTarget) {
+ if (dx * dx + dy * dy > 10000 && that !== m.holdingTarget) {
+ that.collisionFilter.category = cat.body; //make solid
+ that.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet; //can hit player now
+ } else {
+ setTimeout(solid, 40, that);
+ }
+ };
+ setTimeout(solid, 200, m.holdingTarget);
+
+ const charge = Math.min(m.throwCharge / 5, 1)
+ //***** scale throw speed with the first number, 80 *****
+ // let speed = 80 * charge * Math.min(0.85, 0.8 / Math.pow(m.holdingTarget.mass, 0.25));
+ let speed = (tech.isPrinter ? 15 + 80 * charge * Math.min(0.85, 0.8 / Math.pow(m.holdingTarget.mass, 0.1)) : 80 * charge * Math.min(0.85, 0.8 / Math.pow(m.holdingTarget.mass, 0.25)))
+
+
+ m.throwCharge = 0;
+ m.throwCycle = m.cycle + 180 //used to detect if a block was thrown in the last 3 seconds
+ Matter.Body.setVelocity(m.holdingTarget, {
+ x: Math.cos(m.angle) * speed / (m.crouch ? 30 : 10) * Math.sqrt(m.holdingTarget.mass),
+ y: player.velocity.y - Math.sin(m.angle) * speed / 30 * Math.sqrt(m.holdingTarget.mass)
+ });
+ Matter.Body.setVelocity(player, {
+ x: player.velocity.x - player.velocity.x * 0.5 + Math.cos(m.angle) * speed,
+ y: player.velocity.y - player.velocity.y * 0.5 + Math.sin(m.angle) * speed
+ });
+ m.definePlayerMass() //return to normal player mass
+
+ if (tech.isAddBlockMass) {
+ const expand = function (that, massLimit) {
+ if (that.mass < massLimit) {
+ const scale = 1.04;
+ Matter.Body.scale(that, scale, scale);
+ setTimeout(expand, 20, that, massLimit);
+ }
+ };
+ expand(m.holdingTarget, Math.min(20, m.holdingTarget.mass * 3))
+ }
+
+ }
+ } else {
+ m.isHolding = false
+ }
+ },
drawField() {
if (m.holdingTarget) {
ctx.fillStyle = "rgba(110,170,200," + (m.energy * (0.05 + 0.05 * Math.random())) + ")";
diff --git a/js/powerup.js b/js/powerup.js
index c836f6e..d70b30a 100644
--- a/js/powerup.js
+++ b/js/powerup.js
@@ -326,7 +326,7 @@ const powerUps = {
return
}
if (tech.isCancelDuplication) {
- tech.duplication += 0.047
+ tech.duplication += 0.05
tech.maxDuplicationEvent()
simulation.makeTextLog(`tech.duplicationChance() += ${0.043}`)
simulation.circleFlare(0.043);
@@ -344,7 +344,7 @@ const powerUps = {
powerUps.spawn(m.pos.x + 40 * (Math.random() - 0.5), m.pos.y + 40 * (Math.random() - 0.5), spawnType, false);
}
}
- if (tech.isCancelCouple) powerUps.spawnDelay("coupling", 6)
+ if (tech.isCancelCouple) powerUps.spawnDelay("coupling", 8)
// if (tech.isCancelTech && Math.random() < 0.3) {
// powerUps.spawn(m.pos.x + 40 * (Math.random() - 0.5), m.pos.y + 40 * (Math.random() - 0.5), "tech", false);
// simulation.makeTextLog(`options exchange: returns 1 tech`)
@@ -958,9 +958,6 @@ const powerUps = {
if (tech.tech[i].isBotTech && tech.tech[i].count < tech.tech[i].maxCount && tech.tech[i].allowed()) botTech.push(i)
}
if (botTech.length > 0) { //pick random bot tech
- // const choose = botTech[Math.floor(Math.random() * botTech.length)];
- // const isCount = tech.tech[choose].count > 0 ? `(${tech.tech[choose].count+1}x)` : "";
- // text += `