diff --git a/js/bullets.js b/js/bullets.js
index dcba3b3..aed1b46 100644
--- a/js/bullets.js
+++ b/js/bullets.js
@@ -21,11 +21,12 @@ const b = {
isModRecursiveHealing: null,
modSquirrelFx: null,
modIsCrit: null,
- modMoreDrops: null,
+ isModBayesian: null,
isModLowHealthDmg: null,
isModFarAwayDmg: null,
isModEntanglement: null,
isModMassEnergy: null,
+ modIsFourOptions: null,
setModDefaults() {
b.modCount = 0;
b.modFireRate = 1;
@@ -44,7 +45,8 @@ const b = {
b.isModRecursiveHealing = false;
b.modSquirrelFx = 1;
b.modIsCrit = false;
- b.modMoreDrops = 0;
+ b.isModBayesian = 0;
+ b.modIsFourOptions = false;
b.isModLowHealthDmg = false;
b.isModFarAwayDmg = false;
b.isModEntanglement = false;
@@ -215,17 +217,25 @@ const b = {
}
},
{
- name: "Bayesian inference",
- description: "15% chance for double power ups to drop",
+ name: "+1 cardinality",
+ description: "one extra choice when selecting power ups",
have: false, //19
- effect: () => { // good with long term planning
- b.modMoreDrops = 0.15;
+ effect: () => {
+ b.modIsFourOptions = true;
+ }
+ },
+ {
+ name: "Bayesian inference",
+ description: "25% chance for double power ups to drop
one fewer choice when selecting power ups",
+ have: false, //20
+ effect: () => {
+ b.isModBayesian = 0.25;
}
},
{
name: "Gauss rifle",
description: "launch blocks at much higher speeds
hold onto larger blocks even after getting hit",
- have: false, //20
+ have: false, //21
effect: () => { // good with guns that run out of ammo
mech.throwChargeRate = 4;
mech.throwChargeMax = 150;
@@ -235,7 +245,7 @@ const b = {
{
name: "squirrel-cage rotor",
description: "jump higher and move faster
reduced harm from falling ",
- have: false, //21
+ have: false, //22
effect: () => { // good with melee builds, content skipping builds
b.modSquirrelFx = 1.2;
mech.Fx = 0.015 * b.modSquirrelFx;
@@ -245,7 +255,7 @@ const b = {
{
name: "quantum immortality",
description: "after dying, continue in an alternate reality
guns, ammo, and field are randomized",
- have: false, //22
+ have: false, //23
effect: () => {
b.modIsImmortal = true;
}
@@ -779,16 +789,16 @@ const b = {
name: "minigun", //0
description: "rapidly fire a stream of small bullets",
ammo: 0,
- ammoPack: 125,
+ ammoPack: 150,
have: false,
isStarterGun: true,
fire() {
const me = bullet.length;
b.muzzleFlash(15);
// if (Math.random() > 0.2) mobs.alert(500);
- const dir = mech.angle + (Math.random() - 0.5) * ((mech.crouch) ? 0.03 : 0.14);
+ const dir = mech.angle + (Math.random() - 0.5) * ((mech.crouch) ? 0.04 : 0.12);
bullet[me] = Bodies.rectangle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 17 * b.modBulletSize, 5 * b.modBulletSize, b.fireAttributes(dir));
- b.fireProps(mech.crouch ? 11 : 5, mech.crouch ? 44 : 36, dir, me); //cd , speed
+ b.fireProps(mech.crouch ? 10 : 5, mech.crouch ? 50 : 36, dir, me); //cd , speed
bullet[me].endCycle = game.cycle + Math.floor(65 * b.isModBulletsLastLonger);
bullet[me].frictionAir = mech.crouch ? 0.007 : 0.01;
bullet[me].do = function () {
@@ -871,13 +881,13 @@ const b = {
name: "fléchettes", //3
description: "fire a volley of precise high velocity needles",
ammo: 0,
- ammoPack: 75,
+ ammoPack: 65,
have: false,
isStarterGun: true,
count: 0, //used to track how many shots are in a volley before a big CD
lastFireCycle: 0, //use to remember how longs its been since last fire, used to reset count
fire() {
- const CD = (mech.crouch) ? 40 : 20
+ const CD = (mech.crouch) ? 45 : 25
if (this.lastFireCycle + CD < mech.cycle) this.count = 0 //reset count if it cycles past the CD
this.lastFireCycle = mech.cycle
@@ -962,7 +972,7 @@ const b = {
name: "rail gun", //5
description: "electro-magnetically launch a dense rod
hold left mouse to charge, release to fire", //and repel enemies
ammo: 0,
- ammoPack: 7,
+ ammoPack: 6,
have: false,
isStarterGun: false,
fire() {
@@ -1051,9 +1061,9 @@ const b = {
} else { // charging on mouse down
mech.fireCDcycle = Infinity //can't fire until mouse is released
if (mech.crouch) {
- this.charge = this.charge * 0.96 + 0.04 // this.charge converges to 1
+ this.charge = this.charge * 0.965 + 0.035 // this.charge converges to 1
} else {
- this.charge = this.charge * 0.98 + 0.02 // this.charge converges to 1
+ this.charge = this.charge * 0.985 + 0.015 // this.charge converges to 1
}
//gently push away mobs while charging
diff --git a/js/engine.js b/js/engine.js
index e3e214b..ff4ee75 100644
--- a/js/engine.js
+++ b/js/engine.js
@@ -197,7 +197,7 @@ function mobCollisionChecks(event) {
if (obj.classType === "body" && obj.speed > 5) {
const v = Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity));
if (v > 8) {
- let dmg = b.dmgScale * (b.modExtraDmg + v * Math.sqrt(obj.mass) * 0.05);
+ let dmg = b.dmgScale * (b.modExtraDmg + v * Math.sqrt(obj.mass) * 0.07);
mob[k].damage(dmg);
if (mob[k].distanceToPlayer2() < 1000000) mob[k].foundPlayer();
game.drawList.push({
diff --git a/js/game.js b/js/game.js
index 932cfcc..97cbcac 100644
--- a/js/game.js
+++ b/js/game.js
@@ -68,6 +68,7 @@ const game = {
g: 0.001,
onTitlePage: true,
paused: false,
+ isChoosing: false,
testing: false, //testing mode: shows wireframe and some variables
cycle: 0, //total cycles, 60 per second
fpsCap: null, //limits frames per second to 144/2=72, on most monitors the fps is capped at 60fps by the hardware
@@ -230,7 +231,7 @@ const game = {
// "You jump higher if you hold down the jump button.",
// "Crouching while firing makes bullets go faster, but slows the rate of fire.",
// ]
- keyPress() {
+ keyPress() { //runs on key down event
if (keys[189]) {
// - key
game.zoomScale /= 0.9;
@@ -267,8 +268,7 @@ const game = {
game.previousGun();
}
- if (keys[80]) {
- //p for pause
+ if (keys[80] && !game.isChoosing) { //p for pause
if (game.paused) {
game.paused = false;
requestAnimationFrame(cycle);
diff --git a/js/index.js b/js/index.js
index 3a7e761..109726c 100644
--- a/js/index.js
+++ b/js/index.js
@@ -325,87 +325,6 @@ document.getElementById("difficulty-select").addEventListener("input", () => {
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
});
-// function playSound(id) {
-// //play sound
-// if (false) {
-// //sounds are turned off for now
-// // if (document.getElementById(id)) {
-// var sound = document.getElementById(id); //setup audio
-// sound.currentTime = 0; //reset position of playback to zero //sound.load();
-// sound.play();
-// }
-// }
-
-// function stuff() {
-// game.cycle++; //tracks game cycles
-// mech.cycle++; //tracks player cycles //used to alow time to stop for everything, but the player
-// if (game.clearNow) {
-// game.clearNow = false;
-// game.clearMap();
-// level.start();
-// }
-// Engine.update(engine, game.delta);
-// }
-
-// function theRest() {
-// if (game.testing) {
-// mech.draw();
-// game.draw.wireFrame();
-// game.draw.cons();
-// game.draw.testing();
-// game.drawCircle();
-// ctx.restore();
-// game.testingOutput();
-// } else {
-// level.drawFillBGs();
-// level.exit.draw();
-// level.enter.draw();
-// game.draw.powerUp();
-// mobs.draw();
-// game.draw.cons();
-// game.draw.body();
-// mobs.loop();
-// mech.draw();
-// mech.hold();
-// level.drawFills();
-// game.draw.drawMapPath();
-// b.fire();
-// b.bulletActions();
-// mobs.healthBar();
-// game.drawCircle();
-// ctx.restore();
-// }
-// }
-
-// const loop = [
-// stuff,
-// game.gravity,
-// game.wipe,
-// game.wipe,
-// game.textLog,
-// mech.keyMove,
-// level.checkZones,
-// level.checkQuery,
-// mech.move,
-// mech.look,
-// game.fallChecks,
-// game.camera,
-
-// level.drawFillBGs,
-// level.exit.draw,
-// level.enter.draw,
-// game.draw.powerUp,
-// mobs.draw,
-// game.draw.cons,
-// game.draw.body,
-// mobs.loop,
-// mech.draw,
-// mech.hold,
-
-// theRest,
-// game.drawCursor
-// ]
-
//main loop ************************************************************
//**********************************************************************
game.loop = game.normalLoop;
diff --git a/js/level.js b/js/level.js
index e79c967..7a032d5 100644
--- a/js/level.js
+++ b/js/level.js
@@ -14,9 +14,9 @@ const level = {
start() {
if (level.levelsCleared === 0) {
// game.difficulty = 6; //for testing to simulate possible mobs spawns
- // b.giveGuns(21)
- // mech.fieldUpgrades[2].effect();
- // b.giveMod(22)
+ // b.giveGuns(0)
+ // mech.setField(2)
+ b.giveMod(20)
level.intro(); //starting level
// level.testingMap();
@@ -111,7 +111,7 @@ const level = {
// spawn.lineBoss(-500, -600, spawn.allowedBossList[Math.floor(Math.random() * spawn.allowedBossList.length)]);
// spawn.bodyRect(-135, -50, 50, 50);
// spawn.bodyRect(-140, -100, 50, 50);
- powerUps.spawn(420, -400, "mod", false);
+ powerUps.spawn(420, -400, "field", false);
// powerUps.spawn(420, -400, "field", false);
// powerUps.spawn(420, -400, "field", false);
// powerUps.spawn(420, -400, "field", false);
@@ -119,10 +119,10 @@ const level = {
// powerUps.spawn(450, -400, "mod", false);
// spawn.bodyRect(-45, -100, 40, 50);
// spawn.groupBoss(800, -1050);
- spawn.starter(400, -1050);
- spawn.starter(1200, -1050);
+ // spawn.starter(400, -1050);
+ // spawn.starter(1200, -1050);
// spawn.groupBoss(-600, -550);
- spawn.starter(800, -150);
+ // spawn.starter(800, -150);
// spawn.beamer(800, -150);
// spawn.grower(800, -250);
// spawn.blinker(800, -250, 40);
@@ -184,7 +184,7 @@ const level = {
}
blockDoor(710, -710);
- spawn[spawn.pickList[0]](1500, -200, 100 + game.difficulty * 8);
+ spawn[spawn.pickList[0]](1500, -200, 150 + Math.random() * 30);
spawn.mapRect(2500, -1200, 200, 750); //right wall
blockDoor(2585, -210)
spawn.mapRect(2500, -200, 200, 300); //right wall
diff --git a/js/player.js b/js/player.js
index f87abb1..300e949 100644
--- a/js/player.js
+++ b/js/player.js
@@ -410,7 +410,7 @@ const mech = {
}
},
health: 0,
- maxHealth: 1,
+ maxHealth: null, //set in game.reset()
drawHealth() {
if (mech.health < 1) {
ctx.fillStyle = "rgba(100, 100, 100, 0.5)";
@@ -689,13 +689,15 @@ const mech = {
return false;
},
drop() {
- if (mech.isHolding && mech.holdingTarget) {
+ if (mech.isHolding) {
mech.isHolding = false;
- mech.definePlayerMass()
- mech.holdingTarget.collisionFilter.category = cat.body;
- mech.holdingTarget.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
- mech.holdingTarget = null;
mech.throwCharge = 0;
+ if (mech.holdingTarget) {
+ mech.definePlayerMass()
+ mech.holdingTarget.collisionFilter.category = cat.body;
+ mech.holdingTarget.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
+ mech.holdingTarget = null;
+ }
}
},
definePlayerMass(mass = mech.defaultMass) {
@@ -746,71 +748,77 @@ const mech = {
});
Matter.Body.setVelocity(mech.holdingTarget, player.velocity);
Matter.Body.rotate(mech.holdingTarget, 0.01 / mech.holdingTarget.mass); //gently spin the block
+ } else {
+ mech.isHolding = false
}
},
throwBlock() {
- if (mech.holdingTarget && (keys[32] || game.mouseDownRight)) {
- if (mech.fieldMeter > 0.0007) {
- mech.fieldMeter -= 0.0007;
- mech.throwCharge += mech.throwChargeRate;;
- //draw charge
- const x = mech.pos.x + 15 * Math.cos(mech.angle);
- const y = mech.pos.y + 15 * Math.sin(mech.angle);
- const len = mech.holdingTarget.vertices.length - 1;
- const edge = mech.throwCharge * mech.throwCharge * 0.02;
- 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(mech.holdingTarget.vertices[len].x, mech.holdingTarget.vertices[len].y);
- ctx.lineTo(mech.holdingTarget.vertices[0].x, mech.holdingTarget.vertices[0].y);
- ctx.fill();
- for (let i = 0; i < len; i++) {
+ if (mech.holdingTarget) {
+ if (keys[32] || game.mouseDownRight) {
+ if (mech.fieldMeter > 0.0007) {
+ mech.fieldMeter -= 0.0007;
+ mech.throwCharge += mech.throwChargeRate;;
+ //draw charge
+ const x = mech.pos.x + 15 * Math.cos(mech.angle);
+ const y = mech.pos.y + 15 * Math.sin(mech.angle);
+ const len = mech.holdingTarget.vertices.length - 1;
+ const edge = mech.throwCharge * mech.throwCharge * 0.02;
+ 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(mech.holdingTarget.vertices[i].x, mech.holdingTarget.vertices[i].y);
- ctx.lineTo(mech.holdingTarget.vertices[i + 1].x, mech.holdingTarget.vertices[i + 1].y);
+ ctx.lineTo(mech.holdingTarget.vertices[len].x, mech.holdingTarget.vertices[len].y);
+ ctx.lineTo(mech.holdingTarget.vertices[0].x, mech.holdingTarget.vertices[0].y);
ctx.fill();
- }
- } else {
- mech.drop()
- }
- } else if (mech.throwCharge > 0) {
- //throw the body
- mech.fieldCDcycle = mech.cycle + 15;
- mech.isHolding = false;
- //bullet-like collisions
- mech.holdingTarget.collisionFilter.category = cat.body;
- mech.holdingTarget.collisionFilter.mask = cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet;
- //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 (dx * dx + dy * dy > 10000 && that.speed < 3 && that !== mech.holdingTarget) {
- that.collisionFilter.category = cat.body; //make solid
- that.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet;
+ for (let i = 0; i < len; i++) {
+ ctx.beginPath();
+ ctx.moveTo(x, y);
+ ctx.lineTo(mech.holdingTarget.vertices[i].x, mech.holdingTarget.vertices[i].y);
+ ctx.lineTo(mech.holdingTarget.vertices[i + 1].x, mech.holdingTarget.vertices[i + 1].y);
+ ctx.fill();
+ }
} else {
- setTimeout(solid, 50, that);
+ mech.drop()
}
- };
- setTimeout(solid, 200, mech.holdingTarget);
- //throw speed scales a bit with mass
- const speed = Math.min(85, Math.min(54 / mech.holdingTarget.mass + 5, 48) * Math.min(mech.throwCharge, mech.throwChargeMax) / 50);
+ } else if (mech.throwCharge > 0) {
+ //throw the body
+ mech.fieldCDcycle = mech.cycle + 15;
+ mech.isHolding = false;
+ //bullet-like collisions
+ mech.holdingTarget.collisionFilter.category = cat.body;
+ mech.holdingTarget.collisionFilter.mask = cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet;
+ //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 (dx * dx + dy * dy > 10000 && that.speed < 3 && that !== mech.holdingTarget) {
+ that.collisionFilter.category = cat.body; //make solid
+ that.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet;
+ } else {
+ setTimeout(solid, 50, that);
+ }
+ };
+ setTimeout(solid, 200, mech.holdingTarget);
+ //throw speed scales a bit with mass
+ const speed = Math.min(85, Math.min(54 / mech.holdingTarget.mass + 5, 48) * Math.min(mech.throwCharge, mech.throwChargeMax) / 50);
- mech.throwCharge = 0;
- Matter.Body.setVelocity(mech.holdingTarget, {
- x: player.velocity.x + Math.cos(mech.angle) * speed,
- y: player.velocity.y + Math.sin(mech.angle) * speed
- });
- //player recoil //stronger in x-dir to prevent jump hacking
+ mech.throwCharge = 0;
+ Matter.Body.setVelocity(mech.holdingTarget, {
+ x: player.velocity.x + Math.cos(mech.angle) * speed,
+ y: player.velocity.y + Math.sin(mech.angle) * speed
+ });
+ //player recoil //stronger in x-dir to prevent jump hacking
- Matter.Body.setVelocity(player, {
- x: player.velocity.x - Math.cos(mech.angle) * speed / (mech.crouch ? 30 : 5) * Math.sqrt(mech.holdingTarget.mass),
- y: player.velocity.y - Math.sin(mech.angle) * speed / 40 * Math.sqrt(mech.holdingTarget.mass)
- });
- mech.definePlayerMass() //return to normal player mass
+ Matter.Body.setVelocity(player, {
+ x: player.velocity.x - Math.cos(mech.angle) * speed / (mech.crouch ? 30 : 5) * Math.sqrt(mech.holdingTarget.mass),
+ y: player.velocity.y - Math.sin(mech.angle) * speed / 40 * Math.sqrt(mech.holdingTarget.mass)
+ });
+ mech.definePlayerMass() //return to normal player mass
+ }
+ } else {
+ mech.isHolding = false
}
},
drawField() {
diff --git a/js/powerups.js b/js/powerups.js
index f10d0c4..089fb26 100644
--- a/js/powerups.js
+++ b/js/powerups.js
@@ -19,6 +19,7 @@ const powerUps = {
document.getElementById("choose-grid").style.display = "none"
document.getElementById("choose-background").style.display = "none"
game.paused = false;
+ game.isChoosing = false; //stops p from un pausing on key down
requestAnimationFrame(cycle);
},
showDraft() {
@@ -26,6 +27,7 @@ const powerUps = {
document.getElementById("choose-background").style.display = "inline"
document.body.style.cursor = "auto";
game.paused = true;
+ game.isChoosing = true; //stops p from un pausing on key down
},
heal: {
name: "heal",
@@ -86,22 +88,29 @@ const powerUps = {
return 45;
},
effect() {
- function doNotHave(who, skip1 = -1, skip2 = -1) {
+ function doNotHave(who, skip1 = -1, skip2 = -1, skip3 = -1) {
let options = [];
for (let i = 1; i < who.length; i++) {
- if (i !== mech.fieldMode && i !== skip1 && i !== skip2) options.push(i);
+ if (i !== mech.fieldMode && i !== skip1 && i !== skip2 && i !== skip3) options.push(i);
}
if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
}
let choice1 = doNotHave(mech.fieldUpgrades)
let choice2 = doNotHave(mech.fieldUpgrades, choice1)
- let choice3 = doNotHave(mech.fieldUpgrades, choice1, choice2)
+ let choice3 = -1
if (choice1 > -1) {
let text = `