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 = `

choose a field

` text += `
  ${mech.fieldUpgrades[choice1].name}
${mech.fieldUpgrades[choice1].description}
` if (choice2 > -1) text += `
  ${mech.fieldUpgrades[choice2].name}
${mech.fieldUpgrades[choice2].description}
` - if (choice3 > -1) text += `
  ${mech.fieldUpgrades[choice3].name}
${mech.fieldUpgrades[choice3].description}
` + if (!b.isModBayesian) { + choice3 = doNotHave(mech.fieldUpgrades, choice1, choice2) + if (choice3 > -1) text += `
  ${mech.fieldUpgrades[choice3].name}
${mech.fieldUpgrades[choice3].description}
` + } + if (b.modIsFourOptions) { + let choice4 = doNotHave(mech.fieldUpgrades, choice1, choice2, choice3) + if (choice4 > -1) text += `
  ${mech.fieldUpgrades[choice4].name}
${mech.fieldUpgrades[choice4].description}
` + } // text += `
${game.SVGrightMouse} activate the shield with the right mouse
fields shield you from damage
and let you pick up and throw blocks
` document.getElementById("choose-grid").innerHTML = text powerUps.showDraft(); @@ -117,22 +126,29 @@ const powerUps = { return 42; }, effect() { - function doNotHave(who, skip1 = -1, skip2 = -1) { + function doNotHave(who, skip1 = -1, skip2 = -1, skip3 = -1) { let options = []; for (let i = 0; i < who.length; i++) { - if (!who[i].have && i !== skip1 && i !== skip2) options.push(i); + if (!who[i].have && i !== skip1 && i !== skip2 && i !== skip3) options.push(i); } if (options.length > 0) return options[Math.floor(Math.random() * options.length)] } let choice1 = doNotHave(b.mods) let choice2 = doNotHave(b.mods, choice1) - let choice3 = doNotHave(b.mods, choice1, choice2) + let choice3 = -1 if (choice1 > -1) { let text = "

choose a mod

" text += `
  ${b.mods[choice1].name}
${b.mods[choice1].description}
` if (choice2 > -1) text += `
  ${b.mods[choice2].name}
${b.mods[choice2].description}
` - if (choice3 > -1) text += `
  ${b.mods[choice3].name}
${b.mods[choice3].description}
` + if (!b.isModBayesian) { + choice3 = doNotHave(b.mods, choice1, choice2) + if (choice3 > -1) text += `
  ${b.mods[choice3].name}
${b.mods[choice3].description}
` + } + if (b.modIsFourOptions) { + let choice4 = doNotHave(b.mods, choice1, choice2, choice3) + if (choice4 > -1) text += `
  ${b.mods[choice4].name}
${b.mods[choice4].description}
` + } document.getElementById("choose-grid").innerHTML = text powerUps.showDraft(); } else { @@ -147,23 +163,29 @@ const powerUps = { return 35; }, effect() { - function doNotHave(who, skip1 = -1, skip2 = -1) { + function doNotHave(who, skip1 = -1, skip2 = -1, skip3 = -1) { let options = []; for (let i = 0; i < who.length; i++) { - if (!who[i].have && i !== skip1 && i !== skip2) options.push(i); + if (!who[i].have && i !== skip1 && i !== skip2 && i !== skip3) options.push(i); } if (options.length > 0) return options[Math.floor(Math.random() * options.length)] } let choice1 = doNotHave(b.guns) let choice2 = doNotHave(b.guns, choice1) - let choice3 = doNotHave(b.guns, choice1, choice2) - + let choice3 = -1 if (choice1 > -1) { let text = "

choose a gun

" text += `
  ${b.guns[choice1].name}
${b.guns[choice1].description}
` if (choice2 > -1) text += `
  ${b.guns[choice2].name}
${b.guns[choice2].description}
` - if (choice3 > -1) text += `
  ${b.guns[choice3].name}
${b.guns[choice3].description}
` + if (!b.isModBayesian) { + choice3 = doNotHave(b.guns, choice1, choice2) + if (choice3 > -1) text += `
  ${b.guns[choice3].name}
${b.guns[choice3].description}
` + } + if (b.modIsFourOptions) { + let choice4 = doNotHave(b.guns, choice1, choice2, choice3) + if (choice4 > -1) text += `
  ${b.guns[choice4].name}
${b.guns[choice4].description}
` + } document.getElementById("choose-grid").innerHTML = text powerUps.showDraft(); } else { @@ -181,54 +203,54 @@ const powerUps = { spawnRandomPowerUp(x, y) { //mostly used after mob dies if (Math.random() * Math.random() - 0.25 > Math.sqrt(mech.health) || Math.random() < 0.04) { //spawn heal chance is higher at low health powerUps.spawn(x, y, "heal"); - if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "heal"); + if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "heal"); return; } if (Math.random() < 0.2 && b.inventory.length > 0) { powerUps.spawn(x, y, "ammo"); - if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "ammo"); + if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "ammo"); return; } if (Math.random() < 0.004 * (4 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun up to 4 powerUps.spawn(x, y, "gun"); - if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "gun"); + if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "gun"); return; } if (Math.random() < 0.0035 * (9 - b.modCount)) { //a new mod has a low chance for each not acquired mod up to 7 powerUps.spawn(x, y, "mod"); - if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "mod"); + if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod"); return; } if (Math.random() < 0.003) { powerUps.spawn(x, y, "field"); - if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "field"); + if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field"); return; } }, spawnBossPowerUp(x, y) { //boss spawns field and gun mod upgrades if (mech.fieldMode === 0) { powerUps.spawn(x, y, "field") - if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "field") + if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field") } else if (Math.random() < 0.55) { powerUps.spawn(x, y, "mod") - if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "mod") + if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod") } else if (Math.random() < 0.2) { powerUps.spawn(x, y, "gun") - if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "gun") + if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "gun") } else if (Math.random() < 0.1) { powerUps.spawn(x, y, "field"); - if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "field"); + if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field"); } else if (mech.health < 0.65) { powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal"); - if (Math.random() < b.modMoreDrops) { + if (Math.random() < b.isModBayesian) { powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal"); } } else { powerUps.spawn(x, y, "ammo"); powerUps.spawn(x, y, "ammo"); - if (Math.random() < b.modMoreDrops) { + if (Math.random() < b.isModBayesian) { powerUps.spawn(x, y, "ammo"); powerUps.spawn(x, y, "ammo"); } diff --git a/js/spawn.js b/js/spawn.js index ebff30d..b054f49 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -479,13 +479,51 @@ const spawn = { //applying forces to player doesn't seem to work inside this method, not sure why powerUps.spawnBossPowerUp(this.position.x, this.position.y) if (game.difficulty > 5) { - for (let i = 0; i < (game.difficulty - 3); ++i) { - spawn.sucker(this.position.x + (Math.random() - 0.5) * radius * 2, this.position.y + (Math.random() - 0.5) * radius * 2, 70 * Math.random()); - Matter.Body.setVelocity(mob[mob.length - 1], { - x: (Math.random() - 0.5) * 70, - y: (Math.random() - 0.5) * 70 - }); + //teleport everything to center + function toMe(who, where, range) { + for (let i = 0, len = who.length; i < len; i++) { + const SUB = Vector.sub(who[i].position, where) + const DISTANCE = Vector.magnitude(SUB) + if (DISTANCE < range) { + Matter.Body.setPosition(who[i], where) + } + } } + toMe(body, this.position, this.eventHorizon) + toMe(mob, this.position, this.eventHorizon) + toMe(bullet, this.position, this.eventHorizon) + + + + + //push everything away + + // function push(who, pos, range) { + // for (let i = 0, len = who.length; i < len; ++i) { + // const SUB = Vector.sub(who[i].position, pos) + // const DISTANCE = Vector.magnitude(SUB) + + // if (DISTANCE < range) { + // const depth = range - DISTANCE + // const force = Vector.mult(Vector.normalise(SUB), 30 * who[i].mass / depth) + // who[i].force.x += force.x; + // who[i].force.y += force.y; + // } + // } + // } + // push(body, this.position, this.eventHorizon) + // push(mob, this.position, this.eventHorizon) + // push(bullet, this.position, this.eventHorizon) + // push([player], this.position, this.eventHorizon) + + + // for (let i = 0; i < (game.difficulty - 3); ++i) { + // spawn.sucker(this.position.x + (Math.random() - 0.5) * radius * 2, this.position.y + (Math.random() - 0.5) * radius * 2, 70 * Math.random()); + // Matter.Body.setVelocity(mob[mob.length - 1], { + // x: (Math.random() - 0.5) * 70, + // y: (Math.random() - 0.5) * 70 + // }); + // } } }; me.do = function () { @@ -724,7 +762,7 @@ const spawn = { let me; mobs.spawn(x, y, 7, radius, "transparent"); me = mob[mob.length - 1]; - me.seeAtDistance2 = 700000; + me.seeAtDistance2 = 300000; me.accelMag = 0.00012 * game.accelScale; if (map.length) me.searchTarget = map[Math.floor(Math.random() * (map.length - 1))].position; //required for search Matter.Body.setDensity(me, 0.00065); //normal is 0.001 //makes effective life much lower