total rewrite of collision system (spore buff)
This commit is contained in:
118
js/bullets.js
118
js/bullets.js
@@ -360,8 +360,8 @@ const b = {
|
||||
dmg: b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||
classType: "bullet",
|
||||
collisionFilter: {
|
||||
category: 0x000100,
|
||||
mask: 0x010011 //mask: 0x000101, //for self collision
|
||||
category: cat.bullet,
|
||||
mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
|
||||
},
|
||||
minDmgSpeed: 10,
|
||||
onDmg() {}, //this.endCycle = 0 //triggers despawn
|
||||
@@ -377,8 +377,8 @@ const b = {
|
||||
dmg: 0, //damage done in addition to the damage from momentum
|
||||
classType: "bullet",
|
||||
collisionFilter: {
|
||||
category: 0x000100,
|
||||
mask: 0x010011 //mask: 0x000101, //for self collision
|
||||
category: cat.bullet,
|
||||
mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
|
||||
},
|
||||
minDmgSpeed: 10,
|
||||
onDmg() {}, //this.endCycle = 0 //triggers despawn
|
||||
@@ -515,12 +515,12 @@ const b = {
|
||||
restitution: 0.5,
|
||||
angle: Math.random() * 2 * Math.PI,
|
||||
friction: 0,
|
||||
frictionAir: 0.011,
|
||||
frictionAir: 0.018,
|
||||
dmg: 1.8, //damage done in addition to the damage from momentum
|
||||
classType: "bullet",
|
||||
collisionFilter: {
|
||||
category: 0x000100,
|
||||
mask: 0x000011 //no collide with body
|
||||
category: cat.bullet,
|
||||
mask: cat.map | cat.mob | cat.mobBullet | cat.mobShield //no collide with body
|
||||
},
|
||||
endCycle: game.cycle + Math.floor((360 + Math.floor(Math.random() * 240)) * b.isModBulletsLastLonger),
|
||||
minDmgSpeed: 0,
|
||||
@@ -528,7 +528,7 @@ const b = {
|
||||
this.endCycle = 0; //bullet ends cycle after doing damage
|
||||
},
|
||||
onEnd() {},
|
||||
lookFrequency: 67 + Math.floor(47 * Math.random()),
|
||||
lookFrequency: 87 + Math.floor(47 * Math.random()),
|
||||
do() {
|
||||
//find mob targets
|
||||
if (!(game.cycle % this.lookFrequency)) {
|
||||
@@ -550,7 +550,7 @@ const b = {
|
||||
}
|
||||
}
|
||||
//accelerate towards mobs
|
||||
const THRUST = this.mass * 0.0009
|
||||
const THRUST = this.mass * 0.001
|
||||
if (this.lockedOn) {
|
||||
this.force.x -= THRUST * this.lockedOn.x
|
||||
this.force.y -= THRUST * this.lockedOn.y
|
||||
@@ -559,7 +559,7 @@ const b = {
|
||||
}
|
||||
},
|
||||
});
|
||||
const SPEED = 9;
|
||||
const SPEED = 19;
|
||||
const ANGLE = 2 * Math.PI * Math.random()
|
||||
Matter.Body.setVelocity(bullet[bIndex], {
|
||||
x: SPEED * Math.cos(ANGLE),
|
||||
@@ -747,8 +747,8 @@ const b = {
|
||||
dmg: b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||
classType: "bullet",
|
||||
collisionFilter: {
|
||||
category: 0x000000,
|
||||
mask: 0x010011 //mask: 0x000101, //for self collision
|
||||
category: 0,
|
||||
mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
|
||||
},
|
||||
minDmgSpeed: 5,
|
||||
onDmg() {}, //this.endCycle = 0 //triggers despawn
|
||||
@@ -766,7 +766,7 @@ const b = {
|
||||
mech.fireCDcycle = mech.cycle + 2; // set fire cool down
|
||||
Matter.Body.scale(this, 8000, 8000) // show the bullet by scaling it up (don't judge me... I know this is a bad way to do it)
|
||||
this.endCycle = game.cycle + Math.floor(140 * b.isModBulletsLastLonger)
|
||||
this.collisionFilter.category = 0x000100
|
||||
this.collisionFilter.category = cat.bullet
|
||||
Matter.Body.setPosition(this, {
|
||||
x: mech.pos.x,
|
||||
y: mech.pos.y
|
||||
@@ -1004,8 +1004,8 @@ const b = {
|
||||
dmg: 0.13 + b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||
classType: "bullet",
|
||||
collisionFilter: {
|
||||
category: 0x000100,
|
||||
mask: 0x000010
|
||||
category: cat.bullet,
|
||||
mask: cat.mob | cat.mobBullet | cat.mobShield
|
||||
},
|
||||
onDmg() {},
|
||||
onEnd() {},
|
||||
@@ -1420,7 +1420,7 @@ const b = {
|
||||
const me = bullet.length;
|
||||
const dir = mech.angle;
|
||||
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 ? 40 : 30, mech.crouch ? 34 : 22, dir, me); //cd , speed
|
||||
b.fireProps(mech.crouch ? 60 : 40, mech.crouch ? 34 : 22, dir, me); //cd , speed
|
||||
bullet[me].endCycle = game.cycle + Math.floor(60 * b.isModBulletsLastLonger);
|
||||
bullet[me].restitution = 0.3;
|
||||
// bullet[me].frictionAir = 0.01;
|
||||
@@ -1518,65 +1518,7 @@ const b = {
|
||||
bullet[me].onEnd = function () {
|
||||
const NUM = 9;
|
||||
for (let i = 0; i < NUM; i++) {
|
||||
const bIndex = bullet.length;
|
||||
const RADIUS = 3 * b.modBulletSize;
|
||||
bullet[bIndex] = Bodies.circle(this.position.x, this.position.y, RADIUS, {
|
||||
// density: 0.0015, //frictionAir: 0.01,
|
||||
inertia: Infinity,
|
||||
restitution: 0.5,
|
||||
angle: dir,
|
||||
friction: 0,
|
||||
frictionAir: 0.011,
|
||||
dmg: 1.8 + b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||
classType: "bullet",
|
||||
collisionFilter: {
|
||||
category: 0x000100,
|
||||
mask: 0x000011 //no collide with body
|
||||
},
|
||||
endCycle: game.cycle + Math.floor((360 + Math.floor(Math.random() * 240)) * b.isModBulletsLastLonger),
|
||||
minDmgSpeed: 0,
|
||||
onDmg() {
|
||||
this.endCycle = 0; //bullet ends cycle after doing damage
|
||||
},
|
||||
onEnd() {},
|
||||
lookFrequency: 67 + Math.floor(47 * Math.random()),
|
||||
do() {
|
||||
//find mob targets
|
||||
if (!(game.cycle % this.lookFrequency)) {
|
||||
this.closestTarget = null;
|
||||
this.lockedOn = null;
|
||||
let closeDist = Infinity;
|
||||
for (let i = 0, len = mob.length; i < len; ++i) {
|
||||
if (Matter.Query.ray(map, this.position, mob[i].position).length === 0) {
|
||||
// Matter.Query.ray(body, this.position, mob[i].position).length === 0
|
||||
const targetVector = Matter.Vector.sub(this.position, mob[i].position)
|
||||
const dist = Matter.Vector.magnitude(targetVector);
|
||||
if (dist < closeDist) {
|
||||
this.closestTarget = mob[i].position;
|
||||
closeDist = dist;
|
||||
this.lockedOn = Matter.Vector.normalise(targetVector);
|
||||
if (0.3 > Math.random()) break //doesn't always target the closest mob
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//accelerate towards mobs
|
||||
const THRUST = this.mass * 0.0009
|
||||
if (this.lockedOn) {
|
||||
this.force.x -= THRUST * this.lockedOn.x
|
||||
this.force.y -= THRUST * this.lockedOn.y
|
||||
} else {
|
||||
this.force.y += this.mass * 0.00025; //gravity
|
||||
}
|
||||
},
|
||||
});
|
||||
const SPEED = 9;
|
||||
const ANGLE = 2 * Math.PI * Math.random()
|
||||
Matter.Body.setVelocity(bullet[bIndex], {
|
||||
x: SPEED * Math.cos(ANGLE),
|
||||
y: SPEED * Math.sin(ANGLE)
|
||||
});
|
||||
World.add(engine.world, bullet[bIndex]); //add bullet to world
|
||||
b.spore(this)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1605,8 +1547,8 @@ const b = {
|
||||
endCycle: game.cycle + Math.floor((1080 + 360 * Math.random()) * b.isModBulletsLastLonger),
|
||||
classType: "bullet",
|
||||
collisionFilter: {
|
||||
category: 0x000100,
|
||||
mask: 0x010111 //self collide
|
||||
category: cat.bullet,
|
||||
mask: cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield //self collide
|
||||
},
|
||||
minDmgSpeed: 0,
|
||||
lockedOn: null,
|
||||
@@ -1709,8 +1651,8 @@ const b = {
|
||||
endCycle: Infinity,
|
||||
classType: "bullet",
|
||||
collisionFilter: {
|
||||
category: 0x000100,
|
||||
mask: 0x010111 //self, mob,map,body collide
|
||||
category: cat.bullet,
|
||||
mask: cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield
|
||||
},
|
||||
lockedOn: null,
|
||||
onDmg() {
|
||||
@@ -1806,30 +1748,31 @@ const b = {
|
||||
dmg: b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||
classType: "bullet",
|
||||
collisionFilter: {
|
||||
category: 0x000100,
|
||||
mask: 0x010011
|
||||
category: cat.bullet,
|
||||
mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
|
||||
},
|
||||
minDmgSpeed: 0,
|
||||
endCycle: Infinity, //game.cycle + Math.floor(265 * b.isModBulletsLastLonger),
|
||||
count: 0,
|
||||
radius: RADIUS,
|
||||
target: null,
|
||||
targetSub: null,
|
||||
onDmg(who) {
|
||||
if (!this.target && who.alive && who.dropPowerUp) {
|
||||
this.target = who;
|
||||
this.collisionFilter.category = 0x000000;
|
||||
// this.targetSub = Matter.Vector.sub(this.position, this.target.position)
|
||||
this.collisionFilter.category = 0;
|
||||
}
|
||||
},
|
||||
onEnd() {},
|
||||
do() {
|
||||
this.force.y += this.mass * 0.00006; //gravity
|
||||
//draw white circle
|
||||
ctx.beginPath()
|
||||
ctx.beginPath() //draw white circle
|
||||
ctx.arc(this.position.x, this.position.y, this.radius * 0.97 - 1.6, 0, 2 * Math.PI);
|
||||
ctx.fillStyle = "#fff"
|
||||
ctx.fill()
|
||||
|
||||
if (!mech.isBodiesAsleep) { //if time dilation isn't active
|
||||
this.force.y += this.mass * 0.00006; //gravity
|
||||
if (this.count < 17) {
|
||||
this.count++
|
||||
//grow
|
||||
@@ -1845,13 +1788,14 @@ const b = {
|
||||
}
|
||||
|
||||
if (this.target && this.target.alive) { //if stuck to a target
|
||||
// Matter.Body.setPosition(this, Matter.Vector.add(this.target.position, this.targetSub))
|
||||
Matter.Body.setPosition(this, this.target.position)
|
||||
Matter.Body.setVelocity(this.target, Matter.Vector.mult(this.target.velocity, 0.94))
|
||||
Matter.Body.setAngularVelocity(this.target, this.target.angularVelocity * 0.94)
|
||||
this.target.damage(b.dmgScale * 0.0045);
|
||||
} else { //look for a new target
|
||||
} else if (this.target !== null) { //look for a new target
|
||||
this.target = null
|
||||
this.collisionFilter.category = 0x000100;
|
||||
this.collisionFilter.category = cat.bullet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
js/index.js
12
js/index.js
@@ -114,6 +114,18 @@ map: 0x000001 0x111111
|
||||
|
||||
|
||||
*/
|
||||
//collision groups
|
||||
// cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet | cat.mobShield
|
||||
const cat = {
|
||||
player: 0x1,
|
||||
map: 0x10,
|
||||
body: 0x100,
|
||||
bullet: 0x1000,
|
||||
powerUp: 0x10000,
|
||||
mob: 0x100000,
|
||||
mobBullet: 0x1000000,
|
||||
mobShield: 0x10000000,
|
||||
}
|
||||
|
||||
//build build grid display
|
||||
const build = {
|
||||
|
||||
27
js/level.js
27
js/level.js
@@ -14,7 +14,7 @@ const level = {
|
||||
start() {
|
||||
if (level.levelsCleared === 0) {
|
||||
// game.difficulty = 6; //for testing to simulate possible mobs spawns
|
||||
// b.giveGuns(15)
|
||||
b.giveGuns(12)
|
||||
// mech.fieldUpgrades[1].effect();
|
||||
// b.giveMod(21)
|
||||
|
||||
@@ -96,21 +96,22 @@ const level = {
|
||||
spawn.spawnBuilding(-200, -250, 275, 240, false, true, "left"); //far left; player spawns in side
|
||||
// spawn.boost(350, 0, -1000);
|
||||
// for (let i = 0; i < 10; i++) {
|
||||
// powerUps.spawn(950, -425, "gun", false);
|
||||
// }
|
||||
// for (let i = 0; i < 5; i++) {
|
||||
// powerUps.spawn(2500 + i * 20, -1300, "gun", false);
|
||||
// powerUps.spawn(2500 + i * 20, -1100, "ammo", false);
|
||||
powerUps.spawn(950, -425, "gun", false);
|
||||
powerUps.spawn(950, -425, "gun", false);
|
||||
// }
|
||||
|
||||
// spawn.nodeBoss(-500, -600, spawn.allowedBossList[Math.floor(Math.random() * spawn.allowedBossList.length)]);
|
||||
// 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);
|
||||
spawn.bodyRect(-135, -50, 50, 50);
|
||||
spawn.bodyRect(-140, -100, 50, 50);
|
||||
// powerUps.spawn(420, -400, "ammo", false);
|
||||
// powerUps.spawn(450, -400, "mod", false, 6);
|
||||
// powerUps.spawn(450, -400, "mod", false);
|
||||
// spawn.bodyRect(-45, -100, 40, 50);
|
||||
spawn.shooter(800, -1050);
|
||||
spawn.starter(800, -1050);
|
||||
spawn.starter(800, -1050);
|
||||
spawn.starter(800, -1050);
|
||||
spawn.starter(800, -1050);
|
||||
// spawn.groupBoss(-600, -550);
|
||||
// spawn.hopper(800, -150);
|
||||
// spawn.beamer(800, -150);
|
||||
@@ -1576,15 +1577,15 @@ 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 = 0x010000;
|
||||
body[i].collisionFilter.mask = 0x111111;
|
||||
body[i].collisionFilter.category = cat.body;
|
||||
body[i].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
|
||||
body[i].classType = "body";
|
||||
World.add(engine.world, body[i]); //add to world
|
||||
}
|
||||
for (let i = 0; i < map.length; i++) {
|
||||
//map[i].collisionFilter.group = 0;
|
||||
map[i].collisionFilter.category = 0x000001;
|
||||
map[i].collisionFilter.mask = 0x111111;
|
||||
map[i].collisionFilter.category = cat.map;
|
||||
map[i].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet;
|
||||
Matter.Body.setStatic(map[i], true); //make static
|
||||
World.add(engine.world, map[i]); //add to world
|
||||
}
|
||||
|
||||
12
js/mobs.js
12
js/mobs.js
@@ -71,8 +71,8 @@ const mobs = {
|
||||
restitution: 0.5,
|
||||
collisionFilter: {
|
||||
group: 0,
|
||||
category: 0x000010,
|
||||
mask: 0x011111
|
||||
category: cat.mob,
|
||||
mask: cat.player | cat.map | cat.body | cat.bullet | cat.mob
|
||||
},
|
||||
onHit: undefined,
|
||||
alive: true,
|
||||
@@ -1025,14 +1025,12 @@ 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 = 0x010000;
|
||||
body[len].collisionFilter.mask = 0x011111;
|
||||
// body[len].collisionFilter.category = body[len].collisionFilter.category //0x000001;
|
||||
// body[len].collisionFilter.mask = body[len].collisionFilter.mask //0x011111;
|
||||
body[len].collisionFilter.category = cat.body;
|
||||
body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet;
|
||||
|
||||
//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 = 0x001100;
|
||||
body[len].collisionFilter.mask = cat.player | cat.bullet | cat.mob | cat.mobBullet;
|
||||
}
|
||||
body[len].classType = "body";
|
||||
World.add(engine.world, body[len]); //add to world
|
||||
|
||||
40
js/player.js
40
js/player.js
@@ -31,8 +31,8 @@ const mech = {
|
||||
sleepThreshold: Infinity,
|
||||
collisionFilter: {
|
||||
group: 0,
|
||||
category: 0x001000,
|
||||
mask: 0x010011
|
||||
category: cat.player,
|
||||
mask: cat.body | cat.map | cat.mob | cat.mobBullet | cat.mobShield
|
||||
},
|
||||
death() {
|
||||
mech.death();
|
||||
@@ -649,7 +649,7 @@ const mech = {
|
||||
this.fieldFire = false;
|
||||
this.fieldCDcycle = 0;
|
||||
this.isStealth = false;
|
||||
player.collisionFilter.mask = 0x010011 //0x010011 is normal
|
||||
player.collisionFilter.mask = cat.body | cat.map | cat.mob | cat.mobBullet | cat.mobShield
|
||||
this.holdingMassScale = 0.5;
|
||||
this.fieldFireCD = 15;
|
||||
this.fieldShieldingScale = 1; //scale energy loss after collision with mob
|
||||
@@ -658,7 +658,6 @@ const mech = {
|
||||
this.calculateFieldThreshold(); //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
|
||||
mech.isBodiesAsleep = true;
|
||||
mech.wakeCheck();
|
||||
// this.phaseBlocks(0x011111)
|
||||
},
|
||||
drawFieldMeter(range = 60) {
|
||||
if (this.fieldMeter < this.fieldEnergyMax) {
|
||||
@@ -690,8 +689,8 @@ const mech = {
|
||||
if (this.isHolding) {
|
||||
this.isHolding = false;
|
||||
this.definePlayerMass()
|
||||
this.holdingTarget.collisionFilter.category = 0x010000;
|
||||
this.holdingTarget.collisionFilter.mask = 0x011111;
|
||||
this.holdingTarget.collisionFilter.category = cat.body;
|
||||
this.holdingTarget.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet
|
||||
this.holdingTarget = null;
|
||||
this.throwCharge = 0;
|
||||
}
|
||||
@@ -776,15 +775,15 @@ const mech = {
|
||||
this.fireCDcycle = mech.cycle + this.fieldFireCD;
|
||||
this.isHolding = false;
|
||||
//bullet-like collisions
|
||||
this.holdingTarget.collisionFilter.category = 0x000100;
|
||||
this.holdingTarget.collisionFilter.mask = 0x110111;
|
||||
this.holdingTarget.collisionFilter.category = cat.body;
|
||||
this.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 = 0x010000; //make solid
|
||||
that.collisionFilter.mask = 0x011111;
|
||||
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);
|
||||
}
|
||||
@@ -799,9 +798,10 @@ const mech = {
|
||||
y: player.velocity.y + Math.sin(this.angle) * speed
|
||||
});
|
||||
//player recoil //stronger in x-dir to prevent jump hacking
|
||||
|
||||
Matter.Body.setVelocity(player, {
|
||||
x: player.velocity.x - Math.cos(this.angle) * speed / 20 * Math.sqrt(this.holdingTarget.mass),
|
||||
y: player.velocity.y - Math.sin(this.angle) * speed / 80 * Math.sqrt(this.holdingTarget.mass)
|
||||
x: player.velocity.x - Math.cos(this.angle) * speed / (mech.crouch ? 30 : 5) * Math.sqrt(this.holdingTarget.mass),
|
||||
y: player.velocity.y - Math.sin(this.angle) * speed / 40 * Math.sqrt(this.holdingTarget.mass)
|
||||
});
|
||||
this.definePlayerMass() //return to normal player mass
|
||||
}
|
||||
@@ -945,7 +945,7 @@ const mech = {
|
||||
Matter.Vector.magnitude(Matter.Vector.sub(body[i].position, this.pos)) < range &&
|
||||
this.lookingAt(body[i]) &&
|
||||
Matter.Query.ray(map, body[i].position, this.pos).length === 0 &&
|
||||
body[i].collisionFilter.category === 0x010000
|
||||
body[i].collisionFilter.category === cat.body
|
||||
) {
|
||||
mech.pushMass(body[i]);
|
||||
}
|
||||
@@ -997,12 +997,8 @@ const mech = {
|
||||
this.isHolding = true;
|
||||
this.definePlayerMass(mech.defaultMass + this.holdingTarget.mass * this.holdingMassScale)
|
||||
//collide with nothing
|
||||
this.holdingTarget.collisionFilter.category = 0x000000;
|
||||
this.holdingTarget.collisionFilter.mask = 0x000000;
|
||||
// if (this.holdingTarget) {
|
||||
// this.holdingTarget.collisionFilter.category = 0x010000;
|
||||
// this.holdingTarget.collisionFilter.mask = 0x011111;
|
||||
// }
|
||||
this.holdingTarget.collisionFilter.category = 0;
|
||||
this.holdingTarget.collisionFilter.mask = 0;
|
||||
// combine momentum // this doesn't feel right in game
|
||||
// const px = player.velocity.x * player.mass + this.holdingTarget.velocity.x * this.holdingTarget.mass;
|
||||
// const py = player.velocity.y * player.mass + this.holdingTarget.velocity.y * this.holdingTarget.mass;
|
||||
@@ -1486,7 +1482,7 @@ const mech = {
|
||||
// mech.grabRange = 230
|
||||
mech.hold = function () {
|
||||
mech.isStealth = false //isStealth is checked in mob foundPlayer()
|
||||
player.collisionFilter.mask = 0x010011 //0x010011 is normal
|
||||
player.collisionFilter.mask = cat.body | cat.map | cat.mob | cat.mobBullet | cat.mobShield //normal collisions
|
||||
if (mech.isHolding) {
|
||||
mech.drawHold(mech.holdingTarget);
|
||||
mech.holding();
|
||||
@@ -1497,7 +1493,7 @@ const mech = {
|
||||
mech.fieldMeter -= DRAIN;
|
||||
|
||||
mech.isStealth = true //isStealth is checked in mob foundPlayer()
|
||||
player.collisionFilter.mask = 0x000001 //0x010011 is normals
|
||||
player.collisionFilter.mask = cat.map
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.arc(mech.pos.x, mech.pos.y, mech.grabRange, 0, 2 * Math.PI);
|
||||
@@ -1534,7 +1530,7 @@ const mech = {
|
||||
// // mech.grabRange = 230
|
||||
// mech.hold = function () {
|
||||
// mech.isStealth = false //isStealth is checked in mob foundPlayer()
|
||||
// player.collisionFilter.mask = 0x010011 //0x010011 is normal
|
||||
// player.collisionFilter.mask = 0x010011
|
||||
// if (mech.isHolding) {
|
||||
// mech.hackProgress = 0
|
||||
// mech.drawHold(mech.holdingTarget);
|
||||
|
||||
@@ -218,8 +218,8 @@ const powerUps = {
|
||||
inertia: Infinity, //prevents rotation
|
||||
collisionFilter: {
|
||||
group: 0,
|
||||
category: 0x100000,
|
||||
mask: 0x100001
|
||||
category: cat.powerUp,
|
||||
mask: cat.map | cat.powerUp
|
||||
},
|
||||
color: target.color,
|
||||
effect: target.effect,
|
||||
|
||||
51
js/spawn.js
51
js/spawn.js
@@ -471,7 +471,7 @@ const spawn = {
|
||||
me.eventHorizon = 1100; //required for black hole
|
||||
me.seeAtDistance2 = (me.eventHorizon + 1000) * (me.eventHorizon + 1000); //vision limit is event horizon
|
||||
me.accelMag = 0.00003 * game.accelScale;
|
||||
me.collisionFilter.mask = 0x001100
|
||||
me.collisionFilter.mask = cat.player | cat.bullet
|
||||
// me.frictionAir = 0.005;
|
||||
me.memory = 1600;
|
||||
Matter.Body.setDensity(me, 0.05); //extra dense //normal is 0.001 //makes effective life much larger
|
||||
@@ -680,7 +680,7 @@ const spawn = {
|
||||
me.alpha = 1; //used in drawSneaker
|
||||
// me.leaveBody = false;
|
||||
me.canTouchPlayer = false; //used in drawSneaker
|
||||
me.collisionFilter.mask = 0x010111; //can't touch player
|
||||
me.collisionFilter.mask = cat.map | cat.body | cat.bullet | cat.mob //can't touch player
|
||||
me.showHealthBar = false;
|
||||
// me.memory = 420;
|
||||
me.do = function () {
|
||||
@@ -701,7 +701,7 @@ const spawn = {
|
||||
this.healthBar();
|
||||
if (!this.canTouchPlayer) {
|
||||
this.canTouchPlayer = true;
|
||||
this.collisionFilter.mask = 0x011111; //can touch player
|
||||
this.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob; //can touch player
|
||||
}
|
||||
}
|
||||
//draw body
|
||||
@@ -716,7 +716,7 @@ const spawn = {
|
||||
ctx.fill();
|
||||
} else if (this.canTouchPlayer) {
|
||||
this.canTouchPlayer = false;
|
||||
this.collisionFilter.mask = 0x000111; //can't touch player
|
||||
this.collisionFilter.mask = cat.map | cat.body | cat.bullet | cat.mob //can't touch player
|
||||
}
|
||||
};
|
||||
},
|
||||
@@ -724,7 +724,7 @@ const spawn = {
|
||||
let me;
|
||||
mobs.spawn(x, y, 7, radius, "transparent");
|
||||
me = mob[mob.length - 1];
|
||||
me.seeAtDistance2 = 1000000;
|
||||
me.seeAtDistance2 = 700000;
|
||||
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
|
||||
@@ -732,7 +732,7 @@ const spawn = {
|
||||
me.alpha = 1; //used in drawGhost
|
||||
me.canTouchPlayer = false; //used in drawGhost
|
||||
// me.leaveBody = false;
|
||||
me.collisionFilter.mask = 0x000100; //move through walls and player
|
||||
me.collisionFilter.mask = cat.bullet
|
||||
me.showHealthBar = false;
|
||||
me.memory = 480;
|
||||
me.do = function () {
|
||||
@@ -757,7 +757,7 @@ const spawn = {
|
||||
this.healthBar();
|
||||
if (!this.canTouchPlayer) {
|
||||
this.canTouchPlayer = true;
|
||||
this.collisionFilter.mask = 0x001100; //can touch player but not walls
|
||||
this.collisionFilter.mask = cat.player | cat.bullet
|
||||
}
|
||||
}
|
||||
//draw body
|
||||
@@ -773,7 +773,7 @@ const spawn = {
|
||||
ctx.stroke();
|
||||
} else if (this.canTouchPlayer) {
|
||||
this.canTouchPlayer = false;
|
||||
this.collisionFilter.mask = 0x000100; //can't touch player or walls
|
||||
this.collisionFilter.mask = cat.bullet; //can't touch player or walls
|
||||
}
|
||||
};
|
||||
},
|
||||
@@ -823,7 +823,7 @@ const spawn = {
|
||||
Matter.Body.setDensity(me, 0.0015 + 0.0005 * Math.sqrt(game.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger
|
||||
|
||||
me.stroke = "rgba(255,0,200)"; //used for drawGhost
|
||||
me.seeAtDistance2 = 2000000;
|
||||
me.seeAtDistance2 = 1500000;
|
||||
me.fireFreq = Math.ceil(30 + 2000 / radius);
|
||||
me.searchTarget = map[Math.floor(Math.random() * (map.length - 1))].position; //required for search
|
||||
me.hoverElevation = 400 + (Math.random() - 0.5) * 200; //squared
|
||||
@@ -835,7 +835,7 @@ const spawn = {
|
||||
me.frictionAir = 0.01;
|
||||
// me.memory = 300;
|
||||
// Matter.Body.setDensity(me, 0.0015); //extra dense //normal is 0.001
|
||||
me.collisionFilter.mask = 0x001100; //move through walls
|
||||
me.collisionFilter.mask = cat.player | cat.bullet
|
||||
spawn.shield(me, x, y);
|
||||
me.onDeath = function () {
|
||||
powerUps.spawnBossPowerUp(this.position.x, this.position.y)
|
||||
@@ -910,8 +910,8 @@ const spawn = {
|
||||
me.leaveBody = false;
|
||||
me.dropPowerUp = false;
|
||||
me.showHealthBar = false;
|
||||
me.collisionFilter.category = 0x000010;
|
||||
me.collisionFilter.mask = 0x011101;
|
||||
me.collisionFilter.category = cat.mobBullet;
|
||||
me.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet;
|
||||
me.do = function () {
|
||||
this.gravity();
|
||||
this.timeLimit();
|
||||
@@ -1041,7 +1041,8 @@ 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.category = cat.mobShield
|
||||
me.collisionFilter.mask = cat.bullet;
|
||||
consBB[consBB.length] = Constraint.create({
|
||||
//attach shield to last spawned mob
|
||||
bodyA: me,
|
||||
@@ -1069,7 +1070,8 @@ 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.category = cat.mobShield
|
||||
me.collisionFilter.mask = cat.bullet;
|
||||
//constrain to all mob nodes in boss
|
||||
for (let i = 0; i < nodes; ++i) {
|
||||
consBB[consBB.length] = Constraint.create({
|
||||
@@ -1224,9 +1226,8 @@ const spawn = {
|
||||
const breakingPoint = 1300
|
||||
mobs.spawn(breakingPoint, -100, 0, 7.5, "transparent");
|
||||
let me = mob[mob.length - 1];
|
||||
//touch nothing
|
||||
me.collisionFilter.category = 0x010000; //act like a body
|
||||
me.collisionFilter.mask = 0x000101; //only collide with map
|
||||
me.collisionFilter.category = cat.body;
|
||||
me.collisionFilter.mask = cat.map;
|
||||
me.inertia = Infinity;
|
||||
me.g = 0.0004; //required for gravity
|
||||
me.restitution = 0;
|
||||
@@ -1291,8 +1292,8 @@ const spawn = {
|
||||
mobs.spawn(breakingPoint, -100, 0, 2, "transparent");
|
||||
let me = mob[mob.length - 1];
|
||||
//touch nothing
|
||||
me.collisionFilter.category = 0x010000; //act like a body
|
||||
me.collisionFilter.mask = 0x000101; //only collide with map
|
||||
me.collisionFilter.category = cat.body;
|
||||
me.collisionFilter.mask = cat.map;
|
||||
me.g = 0.0003; //required for gravity
|
||||
// me.restitution = 0;
|
||||
me.stroke = "transparent"
|
||||
@@ -1341,8 +1342,8 @@ const spawn = {
|
||||
mobs.spawn(breakingPoint, -100, 0, 2, "transparent");
|
||||
let me = mob[mob.length - 1];
|
||||
//touch nothing
|
||||
me.collisionFilter.category = 0x010000; //act like a body
|
||||
me.collisionFilter.mask = 0x000101; //only collide with map
|
||||
me.collisionFilter.category = cat.body;
|
||||
me.collisionFilter.mask = cat.map;
|
||||
me.g = 0.0003; //required for gravity
|
||||
// me.restitution = 0;
|
||||
me.stroke = "transparent"
|
||||
@@ -1391,8 +1392,8 @@ const spawn = {
|
||||
mobs.spawn(breakingPoint, -100, 0, 2, "transparent");
|
||||
let me = mob[mob.length - 1];
|
||||
//touch nothing
|
||||
me.collisionFilter.category = 0x010000; //act like a body
|
||||
me.collisionFilter.mask = 0x000101; //only collide with map
|
||||
me.collisionFilter.category = cat.body;
|
||||
me.collisionFilter.mask = cat.map;
|
||||
me.g = 0.0003; //required for gravity
|
||||
me.restitution = 0;
|
||||
me.stroke = "transparent"
|
||||
@@ -1440,8 +1441,8 @@ const spawn = {
|
||||
mobs.spawn(breakingPoint, -100, 0, 2, "transparent");
|
||||
let me = mob[mob.length - 1];
|
||||
//touch nothing
|
||||
me.collisionFilter.category = 0x010000; //act like a body
|
||||
me.collisionFilter.mask = 0x000101; //only collide with map
|
||||
me.collisionFilter.category = cat.body;
|
||||
me.collisionFilter.mask = cat.map;
|
||||
me.g = 0.0003; //required for gravity
|
||||
me.restitution = 0;
|
||||
me.stroke = "transparent"
|
||||
|
||||
Reference in New Issue
Block a user