diff --git a/js/bullets.js b/js/bullets.js index 2ed43ae..9f1be1a 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -40,7 +40,7 @@ const b = { classType: "bullet", collisionFilter: { category: 0x000100, - mask: 0x000011 //mask: 0x000101, //for self collision + mask: 0x010011 //mask: 0x000101, //for self collision }, minDmgSpeed: 10, onDmg() {}, //this.endCycle = 0 //triggers despawn @@ -236,7 +236,7 @@ const b = { fire() { // mech.fireCDcycle = game.cycle + 1 //laser drains energy as well as bullets - const FIELD_DRAIN = 0.004 + const FIELD_DRAIN = 0.003 if (mech.fieldMeter < FIELD_DRAIN) { mech.fireCDcycle = game.cycle + 100; // cool down if out of energy } else { @@ -777,7 +777,7 @@ const b = { const me = bullet.length; const dir = mech.angle; bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 20, 4.5, b.fireAttributes(dir)); - b.fireProps(mech.crouch ? 70 : 50, mech.crouch ? 25 : 14, dir, me); //cd , speed + b.fireProps(mech.crouch ? 75 : 55, mech.crouch ? 25 : 14, dir, me); //cd , speed b.drawOneBullet(bullet[me].vertices); Matter.Body.setDensity(bullet[me], 0.000001); bullet[me].endCycle = game.cycle + 100; @@ -816,7 +816,7 @@ const b = { classType: "bullet", collisionFilter: { category: 0x000100, - mask: 0x000011 //mask: 0x000101, //for self collision + mask: 0x000011 //no collide with body }, endCycle: game.cycle + 300 + Math.floor(Math.random() * 240), minDmgSpeed: 0, @@ -892,7 +892,7 @@ const b = { classType: "bullet", collisionFilter: { category: 0x000100, - mask: 0x000111 + mask: 0x010111 //self collide }, minDmgSpeed: 0, lockedOn: null, @@ -951,7 +951,7 @@ const b = { }, ], fire() { - if (game.mouseDown && mech.fireCDcycle < game.cycle && !(keys[32] || game.mouseDownRight) && !mech.isHolding && b.inventory.length) { + if (game.mouseDown && mech.fireCDcycle < game.cycle && !(keys[32] || game.mouseDownRight) && b.inventory.length) { if (b.guns[this.activeGun].ammo > 0) { b.guns[this.activeGun].fire(); b.guns[this.activeGun].ammo--; @@ -961,6 +961,9 @@ const b = { // game.makeTextLog("
NO AMMO
E / Q", 200); game.makeTextLog("
NO AMMO

Q, E, and mouse wheel change weapons

", 200); } + if (mech.isHolding) { + mech.drop(); + } } }, gamepadFire() { diff --git a/js/index.js b/js/index.js index bb1afe9..da61471 100644 --- a/js/index.js +++ b/js/index.js @@ -76,17 +76,18 @@ add bullet on damage effects -//collision info: +// collision info: category mask -powerUp: 0x 100000 0x 100001 -mobBull: 0x 010000 0x 001001 -player: 0x 001000 0x 010011 -bullet: 0x 000100 0x 000011 -mob: 0x 000010 0x 001101 -map: 0x 000001 0x 111111 -body: 0x 000001 0x 011111 +powerUp: 0x100000 0x100001 +body: 0x010000 0x011111 +player: 0x001000 0x010011 +bullet: 0x000100 0x010011 +mob: 0x000010 0x011111 +mobBull: 0x000010 0x011101 +mobshld: 0x000010 0x001100 +map: 0x000001 0x111111 + -? hold: 0x 000001 0x 000001 */ diff --git a/js/level.js b/js/level.js index 3d3e3dc..8c275d8 100644 --- a/js/level.js +++ b/js/level.js @@ -99,9 +99,9 @@ const level = { // spawn.bodyRect(-140, -200, 50, 50); // spawn.bodyRect(-95, -50, 40, 50); // spawn.bodyRect(-90, -100, 60, 50); - // spawn.bodyRect(300, -150, 140, 50); - // spawn.bodyRect(300, -150, 30, 30); - // spawn.bodyRect(300, -150, 20, 20); + spawn.bodyRect(300, -150, 140, 50); + spawn.bodyRect(300, -150, 30, 30); + spawn.bodyRect(300, -150, 20, 20); // spawn.bodyRect(300, -150, 40, 100); // spawn.bodyRect(300, -150, 40, 90); // spawn.bodyRect(300, -150, 30, 60); @@ -115,10 +115,21 @@ const level = { // powerUps.spawn(400, -400, "field", false, '4'); // powerUps.spawn(400, -400, "gun", false); // spawn.bodyRect(-45, -100, 40, 50); - spawn.focuser(800, -1150); + // spawn.focuser(800, -1150); // spawn.groupBoss(-600, -550); // for (let i = 0; i < 1; ++i) { - // spawn.shooter(800, -1150); + spawn.shooter(800, -150, 10); + spawn.shooter(800, -150, 10); + spawn.shooter(800, -100, 10); + spawn.shooter(800, -50, 10); + spawn.shooter(800, -150, 10); + spawn.shooter(800, -150, 10); + spawn.shooter(800, -100, 10); + spawn.shooter(800, -50, 10); + spawn.shooter(800, -150, 10); + spawn.shooter(800, -150, 10); + spawn.shooter(800, -100, 10); + spawn.shooter(800, -50, 10); // } // spawn.groupBoss(900, -1070); // for (let i = 0; i < 20; i++) { @@ -1409,7 +1420,7 @@ const level = { //needs to be run to put bodies into the world for (let i = 0; i < body.length; i++) { //body[i].collisionFilter.group = 0; - body[i].collisionFilter.category = 0x0000001; + body[i].collisionFilter.category = 0x010000; body[i].collisionFilter.mask = 0x011111; body[i].classType = "body"; World.add(engine.world, body[i]); //add to world diff --git a/js/mobs.js b/js/mobs.js index fec265c..eea327f 100644 --- a/js/mobs.js +++ b/js/mobs.js @@ -58,7 +58,7 @@ const mobs = { collisionFilter: { group: 0, category: 0x000010, - mask: 0x001111 + mask: 0x011111 }, onHit: undefined, alive: true, @@ -231,7 +231,8 @@ const mobs = { // ctx.lineDashOffset = 6*(game.cycle % 215); if (this.distanceToPlayer() < this.laserRange) { //if (Math.random()>0.2 && this.seePlayer.yes && this.distanceToPlayer2()<800000) { - mech.damage(0.0004 * game.dmgScale); + mech.damage(0.0003 * game.dmgScale); + if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.005 ctx.beginPath(); ctx.moveTo(this.position.x, this.position.y); ctx.lineTo(mech.pos.x, mech.pos.y); @@ -980,14 +981,14 @@ const mobs = { body[len] = Matter.Bodies.fromVertices(this.position.x, this.position.y, this.vertices); Matter.Body.setVelocity(body[len], this.velocity); Matter.Body.setAngularVelocity(body[len], this.angularVelocity); - body[len].collisionFilter.category = 0x000001; + body[len].collisionFilter.category = 0x010000; body[len].collisionFilter.mask = 0x011111; // body[len].collisionFilter.category = body[len].collisionFilter.category //0x000001; // body[len].collisionFilter.mask = body[len].collisionFilter.mask //0x011111; - //large mobs or too many bodyes go intangible and fall until removed from game to help performance + //large mobs or too many bodies go intangible and fall until removed from game to help performance if (body[len].mass > 10 || 40 + 30 * Math.random() < body.length) { - body[len].collisionFilter.mask = 0x000100; + body[len].collisionFilter.mask = 0x000000; } body[len].classType = "body"; World.add(engine.world, body[len]); //add to world diff --git a/js/player.js b/js/player.js index cca6142..12fd7dd 100644 --- a/js/player.js +++ b/js/player.js @@ -543,7 +543,7 @@ const mech = { if (this.isHolding) { this.isHolding = false; this.definePlayerMass() - this.holdingTarget.collisionFilter.category = 0x000001; + this.holdingTarget.collisionFilter.category = 0x010000; this.holdingTarget.collisionFilter.mask = 0x011111; this.holdingTarget = null; this.throwCharge = 0; @@ -621,13 +621,13 @@ const mech = { this.isHolding = false; //bullet-like collisions this.holdingTarget.collisionFilter.category = 0x000100; - this.holdingTarget.collisionFilter.mask = 0x111111; + this.holdingTarget.collisionFilter.mask = 0x110111; //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 = 0x000001; //make solid + that.collisionFilter.category = 0x010000; //make solid that.collisionFilter.mask = 0x011111; } else { setTimeout(solid, 50, that); @@ -806,8 +806,8 @@ const mech = { //triggers when a hold target exits and field button is released this.isHolding = true; if (this.holdingTarget) { - this.holdingTarget.collisionFilter.category = 0x000001; - this.holdingTarget.collisionFilter.mask = 0x111111; + this.holdingTarget.collisionFilter.category = 0x010000; + this.holdingTarget.collisionFilter.mask = 0x011111; } //combine momentum const px = player.velocity.x * player.mass + this.holdingTarget.velocity.x * this.holdingTarget.mass; @@ -907,16 +907,11 @@ const mech = { game.makeTextLog("Kinetic Energy Field
(right mouse or space bar)

field does damage on contact
blocks are thrown at a higher velocity

", 1200); mech.setHoldDefaults(); //throw quicker and harder - mech.throwChargeRate = 3; //0.5 - mech.throwChargeMax = 140; //50 - //passive field does extra damage - mech.fieldDamage = 2; - - // const startingArc = 0. + mech.throwChargeRate = 3; + mech.throwChargeMax = 140; + mech.fieldDamage = 2.5; //passive field does extra damage mech.fieldArc = 0.09 mech.calculateFieldThreshold(); //run after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) - const STARTING_RANGE = 30 - mech.grabRange = STARTING_RANGE; mech.hold = function () { if (mech.isHolding) { @@ -924,10 +919,6 @@ const mech = { mech.holding(); mech.throw(); } else if ((keys[32] || game.mouseDownRight) && mech.fieldMeter > 0.15) { //not hold but field button is pressed - - //smoothing function to grow range - mech.grabRange = mech.grabRange * 0.94 + 12 //200 * 0.08 - //draw field const range = mech.grabRange - 20; ctx.beginPath(); @@ -940,15 +931,14 @@ const mech = { ctx.fillStyle = "rgba(255,50,150," + (0.13 + 0.18 * Math.random()) + ")"; } ctx.fill(); + //draw random lines in field for cool effect eye = 15; - ctx.beginPath(); ctx.moveTo(mech.pos.x + eye * Math.cos(mech.angle), mech.pos.y + eye * Math.sin(mech.angle)); const offAngle = mech.angle + 2 * Math.PI * mech.fieldArc * (Math.random() - 0.5); ctx.lineTo(mech.pos.x + range * Math.cos(offAngle), mech.pos.y + range * Math.sin(offAngle)); ctx.strokeStyle = "rgba(100,20,50,0.2)"; - // ctx.strokeStyle = "rgba(0,0,0,0.4)"; ctx.stroke(); mech.grabPowerUp(); @@ -956,10 +946,8 @@ const mech = { mech.lookForPickUp(); } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle && mech.fieldMeter > 0.05) { //holding, but field button is released mech.pickUp(); - mech.grabRange = STARTING_RANGE; } else { mech.holdingTarget = null; //clears holding target (this is so you only pick up right after the field button is released and a hold target exists) - mech.grabRange = STARTING_RANGE; } mech.drawFieldMeter() } @@ -1053,12 +1041,12 @@ const mech = { }, () => { mech.fieldMode = 4; - game.makeTextLog("Standing Wave Harmonics
(right mouse or space bar)

oscillating shields surround player
improved energy regeneration
improved field shielding efficiency

", 1200); + game.makeTextLog("Standing Wave Harmonics
(right mouse or space bar)

oscillating shields surround player
improved field shielding efficiency

", 1200); mech.setHoldDefaults(); - mech.fieldShieldingScale = 0.3; - mech.fieldRegen = 0.007; //0.0015 + mech.fieldShieldingScale = 0.15; + // mech.fieldRegen = 0.005; //0.0015 // mech.fieldArc = 1; //field covers full 360 degrees - mech.calculateFieldThreshold(); //run after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) + // mech.calculateFieldThreshold(); //run after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) mech.hold = function () { grabRange1 = 100 + 95 * Math.sin(game.cycle / 23) @@ -1125,10 +1113,9 @@ const mech = { }, () => { mech.fieldMode = 6; - game.makeTextLog("Phase Decoherence Field
(right mouse or space bar)

phase through enemies while field is active
can't see or be seen outside field while field is active

", 1200); + game.makeTextLog("Phase Decoherence Field
(right mouse or space bar)

intangible while field is active
can't see or be seen outside field

", 1200); mech.setHoldDefaults(); - // mech.fieldShieldingScale = 3; - mech.grabRange = 220 + // mech.grabRange = 230 mech.hold = function () { mech.isStealth = false //isStealth is checked in mob foundPlayer() @@ -1138,19 +1125,13 @@ const mech = { mech.holding(); mech.throw(); } else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { - const DRAIN = 0.002 //mech.fieldRegen = 0.0015 + const DRAIN = 0.0035 //mech.fieldRegen = 0.0015 if (mech.fieldMeter > DRAIN) { mech.fieldMeter -= DRAIN; mech.isStealth = true //isStealth is checked in mob foundPlayer() player.collisionFilter.mask = 0x000001 //0x010011 is normals - // if (mech.crouch) { - // mech.grabRange = mech.grabRange * 0.96 + 400 * 0.04; - // } else { - // mech.grabRange = mech.grabRange * 0.96 + 220 * 0.04; - // } - ctx.beginPath(); ctx.arc(mech.pos.x, mech.pos.y, mech.grabRange, 0, 2 * Math.PI); ctx.globalCompositeOperation = "destination-in"; //in or atop @@ -1251,68 +1232,6 @@ const mech = { mech.drawFieldMeter() } }, - // () => { - // mech.fieldMode = 8; - // game.makeTextLog("Time Dilation Field
(right click or space bar)

slows time while field is active

", Infinity); - // mech.setHoldDefaults(); - - // mech.isTimeDilated = false - // // mech.mobMasses = [] - // mech.hold = function () { - // if (!mech.isTimeDilated) { - // engine.timing.timeScale = 1 - // // for (let i = 0, len = body.length; i < len; i++) { - // // // Matter.Body.setStatic(body[i], false) - // // // if (!body[i].isNotHoldable) body[i].timeScale = 1 - // // } - // // for (let i = 0, len = mob.length; i < len; i++) { - // // // mob[i].timeScale = 1 - // // // Matter.Body.setStatic(mob[i], false) - // // } - // } - - // if (mech.isHolding) { - // mech.drawHold(mech.holdingTarget); - // mech.holding(); - // mech.throw(); - // } else if ((keys[32] || game.mouseDownRight && mech.fieldMeter > 0.1)) { //not hold but field button is pressed - // mech.drawField(); - // mech.grabPowerUp(); - // mech.pushMobs(); - // mech.lookForPickUp(); - - - // //set time to slow - // // mech.look(); //still works when fps is slow - // // game.fpsCap = 30 - // // game.fpsInterval = 1000 / game.fpsCap; - // // for (let i = 0, len = mob.length; i < len; i++) { - // // Matter.Body.update(mob[i], 1, 1, 0) - // // } - // if (!mech.isTimeDilated) { - // mech.isTimeDilated = true - // engine.timing.timeScale = 0.01 - // // for (let i = 0, len = body.length; i < len; i++) { - // // // if (!body[i].isNotHoldable) body[i].timeScale = 0.01 - // // // mech.mobMasses.push(body[i].mass) - // // // Matter.Body.setStatic(body[i], true) - // // } - // // for (let i = 0, len = mob.length; i < len; i++) { - // // // Matter.Body.setStatic(mob[i], true) - // // // mob[i].timeScale = 0.01 - // // } - // } - - // } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle && mech.fieldMeter > 0.05) { //holding, but field button is released - // mech.pickUp(); - // mech.isTimeDilated = false - // } else { - // mech.holdingTarget = null; //clears holding target (this is so you only pick up right after the field button is released and a hold target exists) - // mech.isTimeDilated = false - // } - // mech.drawFieldMeter() - // } - // }, ], drawLeg(stroke) { // if (game.mouseInGame.x > this.pos.x) { diff --git a/js/spawn.js b/js/spawn.js index cbc5ec1..0b5a494 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -12,7 +12,7 @@ const spawn = { "beamer", "focuser", "laser", "laser", - "blinker", + // "blinker", //make blinker a boss "sucker", "exploder", "exploder", "exploder", "spawner", @@ -424,7 +424,6 @@ const spawn = { // me.frictionAir = 0.005; me.memory = 600; Matter.Body.setDensity(me, 0.004); //extra dense //normal is 0.001 //makes effective life much larger - // me.collisionFilter.mask = 0x001100; //move through walls me.do = function () { //keep it slow, to stop issues from explosion knock backs if (this.speed > 5) { @@ -619,7 +618,7 @@ const spawn = { me.alpha = 1; //used in drawSneaker // me.leaveBody = false; me.canTouchPlayer = false; //used in drawSneaker - me.collisionFilter.mask = 0x000111; //can't touch player + me.collisionFilter.mask = 0x010111; //can't touch player // me.memory = 420; // me.seePlayerFreq = 60 + Math.round(Math.random() * 30); me.do = function () { @@ -637,7 +636,7 @@ const spawn = { this.healthBar(); if (!this.canTouchPlayer) { this.canTouchPlayer = true; - this.collisionFilter.mask = 0x001111; //can touch player + this.collisionFilter.mask = 0x011111; //can touch player } } //draw body @@ -692,7 +691,7 @@ const spawn = { this.healthBar(); if (!this.canTouchPlayer) { this.canTouchPlayer = true; - this.collisionFilter.mask = 0x001110; //can touch player but not walls + this.collisionFilter.mask = 0x001100; //can touch player but not walls } } //draw body @@ -708,7 +707,7 @@ const spawn = { ctx.stroke(); } else if (this.canTouchPlayer) { this.canTouchPlayer = false; - this.collisionFilter.mask = 0x000110; //can't touch player or walls + this.collisionFilter.mask = 0x000100; //can't touch player or walls } }; }, @@ -720,9 +719,7 @@ const spawn = { Matter.Body.rotate(me, Math.random() * 2 * Math.PI); me.blinkRate = 40 + Math.round(Math.random() * 60); //required for blink me.blinkLength = 150 + Math.round(Math.random() * 200); //required for blink - // me.collisionFilter.mask = 0x001100; //move through walls me.isStatic = true; - // me.leaveBody = false; me.memory = 360; me.seePlayerFreq = 40 + Math.round(Math.random() * 30); me.isBig = false; @@ -754,23 +751,6 @@ const spawn = { } }; }, - // drifter(x, y, radius = 15 + Math.ceil(Math.random() * 40)) { - // mobs.spawn(x, y, 4.5, radius, "transparent"); - // let me = mob[mob.length - 1]; - // me.stroke = "rgb(0,200,255)"; //used for drawGhost - // Matter.Body.rotate(me, Math.random() * 2 * Math.PI); - // me.blinkRate = 30 + Math.round(Math.random() * 30); //required for blink/drift - // me.blinkLength = 160; //required for blink/drift - // //me.collisionFilter.mask = 0x001100; //move through walls - // me.isStatic = true; - // me.memory = 360; - // me.seePlayerFreq = 40 + Math.round(Math.random() * 30); - // me.do = function () { - // this.healthBar(); - // this.seePlayerCheck(); - // this.drift(); - // }; - // }, bomber(x, y, radius = 120 + Math.ceil(Math.random() * 70)) { //boss that drops bombs from above and holds a set distance from player mobs.spawn(x, y, 3, radius, "transparent"); @@ -867,8 +847,8 @@ const spawn = { me.restitution = 0.8; me.leaveBody = false; me.dropPowerUp = false; - // me.collisionFilter.mask = 0x001000; - me.collisionFilter.category = 0x010000; + me.collisionFilter.category = 0x000010; + me.collisionFilter.mask = 0x011101; me.do = function () { this.gravity(); this.timeLimit(); @@ -1005,7 +985,7 @@ const spawn = { me.stroke = "rgb(220,220,255)"; Matter.Body.setDensity(me, 0.0001) //very low density to not mess with the original mob's motion me.shield = true; - me.collisionFilter.mask = 0x000100; //don't collide with bodies, map, player, and mobs, only bullets + me.collisionFilter.mask = 0x001100; //don't collide with bodies, map, player, and mobs, only bullets consBB[consBB.length] = Constraint.create({ //attach shield to last spawned mob bodyA: me, @@ -1032,7 +1012,7 @@ const spawn = { Matter.Body.setDensity(me, 0.00005) //very low density to not mess with the original mob's motion me.frictionAir = 0; me.shield = true; - me.collisionFilter.mask = 0x000100; //don't collide with bodies, map, and mobs, only bullets and player + me.collisionFilter.mask = 0x001100; //don't collide with bodies, map, and mobs, only bullets and player //constrain to all mob nodes in boss for (let i = 0; i < nodes; ++i) { consBB[consBB.length] = Constraint.create({ @@ -1218,9 +1198,9 @@ const spawn = { const breakingPoint = 1300 mobs.spawn(breakingPoint, -100, 0, 7.5, "transparent"); let me = mob[mob.length - 1]; - //touch only walls - me.collisionFilter.category = 0x100000; - me.collisionFilter.mask = 0x100001; + //touch nothing + me.collisionFilter.category = 0x000000; + me.collisionFilter.mask = 0x000000; me.inertia = Infinity; me.g = 0.0004; //required for gravity me.restitution = 0; @@ -1282,9 +1262,9 @@ const spawn = { const breakingPoint = 1425 mobs.spawn(breakingPoint, -100, 0, 2, "transparent"); let me = mob[mob.length - 1]; - //touch only walls - me.collisionFilter.category = 0x100000; - me.collisionFilter.mask = 0x100001; + //touch nothing + me.collisionFilter.category = 0x000000; + me.collisionFilter.mask = 0x000000; me.g = 0.0003; //required for gravity // me.restitution = 0; me.stroke = "transparent" @@ -1330,9 +1310,9 @@ const spawn = { const breakingPoint = 1400 mobs.spawn(breakingPoint, -100, 0, 2, "transparent"); let me = mob[mob.length - 1]; - //touch only walls - me.collisionFilter.category = 0x100000; - me.collisionFilter.mask = 0x100001; + //touch nothing + me.collisionFilter.category = 0x000000; + me.collisionFilter.mask = 0x000000; me.g = 0.0003; //required for gravity // me.restitution = 0; me.stroke = "transparent" @@ -1378,9 +1358,9 @@ const spawn = { const breakingPoint = 1350 mobs.spawn(breakingPoint, -100, 0, 2, "transparent"); let me = mob[mob.length - 1]; - //touch only walls - me.collisionFilter.category = 0x100000; - me.collisionFilter.mask = 0x100001; + //touch nothing + me.collisionFilter.category = 0x000000; + me.collisionFilter.mask = 0x000000; me.g = 0.0003; //required for gravity me.restitution = 0; me.stroke = "transparent" @@ -1425,9 +1405,9 @@ const spawn = { const breakingPoint = 1325 mobs.spawn(breakingPoint, -100, 0, 2, "transparent"); let me = mob[mob.length - 1]; - //touch only walls - me.collisionFilter.category = 0x100000; - me.collisionFilter.mask = 0x100001; + //touch nothing + me.collisionFilter.category = 0x000000; + me.collisionFilter.mask = 0x000000; me.g = 0.0003; //required for gravity me.restitution = 0; me.stroke = "transparent"