diff --git a/js/bullets.js b/js/bullets.js index 1e44599..60f9ace 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -124,7 +124,7 @@ const b = { }, activeGun: null, //current gun in use by player inventoryGun: 0, - inventory: [0], //list of what guns player has // 0 starts with basic gun + inventory: [], //list of what guns player has // 0 starts with basic gun giveGuns(gun = "all", ammoPacks = 2) { if (gun === "all") { b.activeGun = 0; @@ -1085,15 +1085,15 @@ const b = { name: "grenades", description: "fire a bomb that explodes on contact or after 1.6 seconds", ammo: 0, - ammoPack: 17, + ammoPack: 14, have: false, fire() { const me = bullet.length; const dir = mech.angle; // + Math.random() * 0.05; bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 15 * b.modBulletSize, b.fireAttributes(dir, false)); - b.fireProps(mech.crouch ? 45 : 32, mech.crouch ? 41 : 32, dir, me); //cd , speed + b.fireProps(mech.crouch ? 40 : 25, mech.crouch ? 41 : 32, dir, me); //cd , speed b.drawOneBullet(bullet[me].vertices); - Matter.Body.setDensity(bullet[me], 0.000001); + // Matter.Body.setDensity(bullet[me], 0.000001); bullet[me].totalCycles = 100; bullet[me].endCycle = game.cycle + Math.floor(70 * b.modBulletsLastLonger); bullet[me].restitution = 0.25; @@ -1112,7 +1112,7 @@ const b = { }, { name: "vacuum bomb", - description: "fire a huge bomb that sucks before it explodes
2 second fuse", + description: "fire a huge bomb that sucks before it explodes", ammo: 0, ammoPack: 5, have: false, @@ -1125,7 +1125,7 @@ const b = { b.drawOneBullet(bullet[me].vertices); // Matter.Body.setDensity(bullet[me], 0.001); - bullet[me].endCycle = game.cycle + Math.floor(120 * b.modBulletsLastLonger); + bullet[me].endCycle = game.cycle + Math.floor((mech.crouch ? 100 : 150) * b.modBulletsLastLonger); bullet[me].endCycleLength = bullet[me].endCycle - game.cycle // bullet[me].restitution = 0.3; // bullet[me].frictionAir = 0.01; @@ -1145,7 +1145,7 @@ const b = { this.force.y += this.mass * 0.0022; //before the explosion suck in stuff - if (game.cycle > this.endCycle - 35) { + if (game.cycle > this.endCycle - 35 && !mech.isBodiesAsleep) { const that = this let mag = 0.1 @@ -1165,11 +1165,13 @@ const b = { suck(body) suck(mob) suck(powerUp) + suck([player]) } else { mag = 0.1 suck(body) suck(mob) suck(powerUp) + suck([player]) } //keep bomb in place @@ -1177,6 +1179,12 @@ const b = { x: 0, y: 0 }); + //draw suck + const radius = 9 * this.explodeRad * (this.endCycle - game.cycle) / this.endCycleLength + ctx.fillStyle = "rgba(255,255,255,0.2)"; + ctx.beginPath(); + ctx.arc(this.position.x, this.position.y, radius, 0, 2 * Math.PI); + ctx.fill(); } //draw timer diff --git a/js/game.js b/js/game.js index 666e0cb..acd5d0d 100644 --- a/js/game.js +++ b/js/game.js @@ -297,9 +297,9 @@ const game = { powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "gun"); powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "ammo"); powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "field"); - powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "mod"); powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "heal"); powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "heal"); + if (!powerUps.haveAllMods) powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "mod"); } if (keys[89]) { //add all mods with y for (let i = 0; i < b.mods.length; i++) { diff --git a/js/player.js b/js/player.js index 61da0dd..5fa1152 100644 --- a/js/player.js +++ b/js/player.js @@ -374,26 +374,28 @@ const mech = { } function randomizeHealth() { - mech.health = 0.5 + 0.5 * Math.random() + mech.health = 0.5 + 1 * Math.random() mech.displayHealth(); } function randomizeGuns() { + const length = b.inventory.length + //removes guns and ammo + b.inventory = []; b.activeGun = null; - b.inventory = []; //removes guns and ammo + b.inventoryGun = 0; for (let i = 0, len = b.guns.length; i < len; ++i) { b.guns[i].have = false; if (b.guns[i].ammo !== Infinity) b.guns[i].ammo = 0; } - if (game.levelsCleared > 0 && Math.random() < 0.95) powerUps.gun.effect(); - if (game.levelsCleared > 1 && Math.random() < 0.89) powerUps.gun.effect(); - if (game.levelsCleared > 3 && Math.random() < 0.6) powerUps.gun.effect(); - if (game.levelsCleared > 5 && Math.random() < 0.5) powerUps.gun.effect(); - if (game.levelsCleared > 7 && Math.random() < 0.4) powerUps.gun.effect(); + for (let i = 0; i < length; i++) { + powerUps.gun.effect(); + } + //randomize ammo for (let i = 0, len = b.inventory.length; i < len; i++) { if (b.guns[b.inventory[i]].ammo !== Infinity) { - b.guns[b.inventory[i]].ammo = Math.max(0, Math.floor(2.2 * b.guns[b.inventory[i]].ammo * (Math.random() - 0.15))) + b.guns[b.inventory[i]].ammo = Math.max(0, Math.floor(5 * b.guns[b.inventory[i]].ammo * (Math.random() - 0.25))) } } game.makeGunHUD(); //update gun HUD diff --git a/js/powerups.js b/js/powerups.js index f4040b3..9b80850 100644 --- a/js/powerups.js +++ b/js/powerups.js @@ -76,7 +76,7 @@ const powerUps = { } } }, - + haveAllMods: false, mod: { name: "mod", color: "#a8f", @@ -94,8 +94,7 @@ const powerUps = { let newMod = options[Math.floor(Math.random() * options.length)] b.giveMod(newMod) game.makeTextLog(`${b.mods[newMod].name}

${b.mods[newMod].description}

`, 1200); - } else { - //what should happen if you have all the mods? + if (options.length < 2) powerUps.haveAllMods = true } } }, @@ -121,18 +120,9 @@ const powerUps = { // newGun = 4; //makes every gun you pick up this type //enable for testing one gun if (b.activeGun === null) { b.activeGun = newGun //if no active gun switch to new gun - game.makeTextLog( - // "



left mouse: fire weapon
", - "Use left mouse to fire weapon.", - Infinity - ); + game.makeTextLog("Use left mouse to fire weapon.", Infinity); } game.makeTextLog(`${b.guns[newGun].name}
(left click)

${b.guns[newGun].description}

`, 1000); - // if (b.inventory.length === 1) { //on the second gun pick up tell player how to change guns - // game.makeTextLog(`(Q, E, and mouse wheel change weapons)

${b.guns[newGun].name}
(left click)

${b.guns[newGun].description}

`, 1000); - // } else { - // game.makeTextLog(`${b.guns[newGun].name}
(left click)

${b.guns[newGun].description}

`, 1000); - // } b.guns[newGun].have = true; b.inventory.push(newGun); b.guns[newGun].ammo += b.guns[newGun].ammoPack * 2; @@ -160,7 +150,7 @@ const powerUps = { powerUps.spawn(x, y, "gun"); return; } - if (Math.random() < 0.008) { + if (Math.random() < 0.008 && !powerUps.haveAllMods) { powerUps.spawn(x, y, "mod"); return; } @@ -172,7 +162,7 @@ const powerUps = { spawnBossPowerUp(x, y) { //boss spawns field and gun mod upgrades if (mech.fieldMode === 0) { powerUps.spawn(x, y, "field") - } else if (Math.random() < 0.35) { + } else if (Math.random() < 0.35 && !powerUps.haveAllMods) { powerUps.spawn(x, y, "mod") } else if (Math.random() < 0.27) { powerUps.spawn(x, y, "field");