removed several !m.isBodiesAsleep
this could cause some bugs for bullets or mobs when time is dilated
This commit is contained in:
90
js/bullet.js
90
js/bullet.js
@@ -1272,7 +1272,6 @@ const b = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
do() {
|
do() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
this.cycle++
|
this.cycle++
|
||||||
// if (this.cycle > 40) {
|
// if (this.cycle > 40) {
|
||||||
// this.frictionAir = 0.003
|
// this.frictionAir = 0.003
|
||||||
@@ -1331,7 +1330,6 @@ const b = {
|
|||||||
// this.frictionAir = 0.8
|
// this.frictionAir = 0.8
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
Matter.Body.setVelocity(bullet[me], {
|
Matter.Body.setVelocity(bullet[me], {
|
||||||
@@ -1470,7 +1468,7 @@ const b = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (m.energy > 0.005 && !m.isBodiesAsleep) m.energy -= 0.005
|
if (m.energy > 0.005) m.energy -= 0.005
|
||||||
const sub = Vector.sub(this.position, m.pos)
|
const sub = Vector.sub(this.position, m.pos)
|
||||||
const rangeScale = 1 + 0.000001 * Vector.magnitude(sub) * Vector.magnitude(sub) //return faster when far from player
|
const rangeScale = 1 + 0.000001 * Vector.magnitude(sub) * Vector.magnitude(sub) //return faster when far from player
|
||||||
const returnForce = Vector.mult(Vector.normalise(sub), rangeScale * this.thrustMag * this.mass)
|
const returnForce = Vector.mult(Vector.normalise(sub), rangeScale * this.thrustMag * this.mass)
|
||||||
@@ -1503,7 +1501,6 @@ const b = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
do() {
|
do() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
this.cycle++
|
this.cycle++
|
||||||
if (isReturn) {
|
if (isReturn) {
|
||||||
if (this.cycle > totalCycles) {
|
if (this.cycle > totalCycles) {
|
||||||
@@ -1576,7 +1573,6 @@ const b = {
|
|||||||
// this.frictionAir = 0.8
|
// this.frictionAir = 0.8
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
|
||||||
this.draw()
|
this.draw()
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -1608,48 +1604,6 @@ const b = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Composite.add(engine.world, bullet[me]); //add bullet to world
|
Composite.add(engine.world, bullet[me]); //add bullet to world
|
||||||
|
|
||||||
/* todo
|
|
||||||
despawn
|
|
||||||
when player gets far away?
|
|
||||||
set time
|
|
||||||
release mouse?
|
|
||||||
|
|
||||||
*/
|
|
||||||
// if (true && input.down) {
|
|
||||||
// Matter.Body.setVelocity(bullet[me], {
|
|
||||||
// x: m.Vx / 2 + 70 * Math.cos(bullet[me].angle),
|
|
||||||
// y: m.Vy / 2 + 70 * Math.sin(bullet[me].angle)
|
|
||||||
// });
|
|
||||||
// bullet[me].frictionAir = 0.0011
|
|
||||||
// bullet[me].endCycle = simulation.cycle + Infinity
|
|
||||||
// bullet[me].do = function() {
|
|
||||||
// if (!m.isBodiesAsleep) {
|
|
||||||
// this.cycle++
|
|
||||||
// if (Matter.Query.collides(this, map).length) {
|
|
||||||
// // this.collisionFilter.mask = 0; //non collide with everything
|
|
||||||
// this.collisionFilter.category = cat.map
|
|
||||||
// this.collisionFilter.mask = cat.player | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet;
|
|
||||||
|
|
||||||
// Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(this.lastVelocity), 30))) //move a bit into the wall
|
|
||||||
// Matter.Body.setVelocity(this, { x: 0, y: 0 });
|
|
||||||
// Matter.Body.setStatic(this, true) //don't set to static if not touching map
|
|
||||||
|
|
||||||
// Matter.Body.setAngularVelocity(this, 0)
|
|
||||||
// const unit = Vector.normalise(Vector.sub({ x: this.position.x, y: this.position.y - 150 }, player.position))
|
|
||||||
// const push = Vector.mult(unit, 1)
|
|
||||||
// player.force.x += push.x
|
|
||||||
// player.force.y += push.y
|
|
||||||
// //pull player back in
|
|
||||||
// this.do = () => {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// this.lastVelocity = { x: this.velocity.x, y: this.velocity.y }
|
|
||||||
// }
|
|
||||||
// this.drawString()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
missile(where, angle, speed, size = 1) {
|
missile(where, angle, speed, size = 1) {
|
||||||
if (tech.missileSize) size *= 1.5
|
if (tech.missileSize) size *= 1.5
|
||||||
@@ -1709,7 +1663,6 @@ const b = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
do() {
|
do() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
if (!(m.cycle % this.lookFrequency)) this.tryToLockOn();
|
if (!(m.cycle % this.lookFrequency)) this.tryToLockOn();
|
||||||
if (this.lockedOn) { //rotate missile towards the target
|
if (this.lockedOn) { //rotate missile towards the target
|
||||||
const face = {
|
const face = {
|
||||||
@@ -1737,15 +1690,6 @@ const b = {
|
|||||||
11 * size, 0, 2 * Math.PI);
|
11 * size, 0, 2 * Math.PI);
|
||||||
ctx.fillStyle = "rgba(255,155,0,0.5)";
|
ctx.fillStyle = "rgba(255,155,0,0.5)";
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
} else {
|
|
||||||
//draw rocket with time stop
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(this.position.x - Math.cos(this.angle) * (30 * size - 3) + (Math.random() - 0.5) * 4,
|
|
||||||
this.position.y - Math.sin(this.angle) * (30 * size - 3) + (Math.random() - 0.5) * 4,
|
|
||||||
2 + 9 * size, 0, 2 * Math.PI);
|
|
||||||
ctx.fillStyle = "rgba(255,155,0,0.5)";
|
|
||||||
ctx.fill();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const thrust = 0.0066 * bullet[me].mass * (tech.missileSize ? 0.6 : 1);
|
const thrust = 0.0066 * bullet[me].mass * (tech.missileSize ? 0.6 : 1);
|
||||||
@@ -1793,7 +1737,6 @@ const b = {
|
|||||||
beforeDmg() {},
|
beforeDmg() {},
|
||||||
onEnd() {},
|
onEnd() {},
|
||||||
do() {
|
do() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
if (this.endCycle < simulation.cycle + 1) this.isWave = false
|
if (this.endCycle < simulation.cycle + 1) this.isWave = false
|
||||||
if (Matter.Query.point(map, this.position).length) { //check if inside map
|
if (Matter.Query.point(map, this.position).length) { //check if inside map
|
||||||
this.isBranch = true;
|
this.isBranch = true;
|
||||||
@@ -1817,7 +1760,6 @@ const b = {
|
|||||||
const velocity = Vector.mult(player.velocity, 0.4) //move with player
|
const velocity = Vector.mult(player.velocity, 0.4) //move with player
|
||||||
Matter.Body.setPosition(this, Vector.add(velocity, Vector.add(this.position, wiggle)))
|
Matter.Body.setPosition(this, Vector.add(velocity, Vector.add(this.position, wiggle)))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
Composite.add(engine.world, bullet[me]); //add bullet to world
|
Composite.add(engine.world, bullet[me]); //add bullet to world
|
||||||
Matter.Body.setVelocity(bullet[me], {
|
Matter.Body.setVelocity(bullet[me], {
|
||||||
@@ -2290,7 +2232,7 @@ const b = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.speed < 1 && this.angularSpeed < 0.01 && !m.isBodiesAsleep) this.stillCount++
|
if (this.speed < 1 && this.angularSpeed < 0.01) this.stillCount++
|
||||||
}
|
}
|
||||||
if (this.stillCount > 25) this.arm();
|
if (this.stillCount > 25) this.arm();
|
||||||
},
|
},
|
||||||
@@ -2326,7 +2268,7 @@ const b = {
|
|||||||
this.endCycle = simulation.cycle + 1020
|
this.endCycle = simulation.cycle + 1020
|
||||||
this.do = function() { //overwrite the do method for this bullet
|
this.do = function() { //overwrite the do method for this bullet
|
||||||
this.force.y += this.mass * 0.002; //extra gravity
|
this.force.y += this.mass * 0.002; //extra gravity
|
||||||
if (!(simulation.cycle % this.lookFrequency) && !m.isBodiesAsleep) { //find mob targets
|
if (!(simulation.cycle % this.lookFrequency)) { //find mob targets
|
||||||
b.targetedNail(this.position, 1, 45 + 5 * Math.random(), 1100, false, 2.3) //targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, isRandomAim = true, damage = 1.4) {
|
b.targetedNail(this.position, 1, 45 + 5 * Math.random(), 1100, false, 2.3) //targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, isRandomAim = true, damage = 1.4) {
|
||||||
if (!(simulation.cycle % (this.lookFrequency * 6))) {
|
if (!(simulation.cycle % (this.lookFrequency * 6))) {
|
||||||
simulation.drawList.push({
|
simulation.drawList.push({
|
||||||
@@ -3136,7 +3078,6 @@ const b = {
|
|||||||
},
|
},
|
||||||
onEnd() {},
|
onEnd() {},
|
||||||
do() {
|
do() {
|
||||||
if (!m.isBodiesAsleep) { //if time dilation isn't active
|
|
||||||
if (this.count < 20) {
|
if (this.count < 20) {
|
||||||
this.count++
|
this.count++
|
||||||
//grow
|
//grow
|
||||||
@@ -3234,7 +3175,6 @@ const b = {
|
|||||||
Matter.Body.setPosition(this, Vector.add(this.position, Vector.rotate({ x: range, y: 0 }, 2 * Math.PI * Math.random())))
|
Matter.Body.setPosition(this, Vector.add(this.position, Vector.rotate({ x: range, y: 0 }, 2 * Math.PI * Math.random())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
if (tech.isBulletTeleport) bullet[me].nextPortCycle = simulation.cycle + bullet[me].portFrequency
|
if (tech.isBulletTeleport) bullet[me].nextPortCycle = simulation.cycle + bullet[me].portFrequency
|
||||||
Composite.add(engine.world, bullet[me]); //add bullet to world
|
Composite.add(engine.world, bullet[me]); //add bullet to world
|
||||||
@@ -3318,7 +3258,6 @@ const b = {
|
|||||||
// bullet[me].turnRate = 0.005 * (Math.random() - 0.5)
|
// bullet[me].turnRate = 0.005 * (Math.random() - 0.5)
|
||||||
bullet[me].isInMap = false
|
bullet[me].isInMap = false
|
||||||
bullet[me].do = function() {
|
bullet[me].do = function() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
const whom = Matter.Query.collides(this, mob)
|
const whom = Matter.Query.collides(this, mob)
|
||||||
if (whom.length && this.speed > 20) { //if touching a mob
|
if (whom.length && this.speed > 20) { //if touching a mob
|
||||||
for (let i = 0, len = whom.length; i < len; i++) {
|
for (let i = 0, len = whom.length; i < len; i++) {
|
||||||
@@ -3369,7 +3308,6 @@ const b = {
|
|||||||
} else if (this.speed < 30) {
|
} else if (this.speed < 30) {
|
||||||
this.force.y += this.mass * 0.001; //no gravity until it slows down to improve aiming
|
this.force.y += this.mass * 0.001; //no gravity until it slows down to improve aiming
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
bullet[me].endCycle = simulation.cycle + 100;
|
bullet[me].endCycle = simulation.cycle + 100;
|
||||||
@@ -3630,7 +3568,6 @@ const b = {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
//check for damage
|
//check for damage
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
if (m.immuneCycle < m.cycle && !((m.cycle + this.phase) % 30)) { //twice a second
|
if (m.immuneCycle < m.cycle && !((m.cycle + this.phase) % 30)) { //twice a second
|
||||||
if (Vector.magnitude(Vector.sub(this.position, player.position)) < 250 && m.immuneCycle < m.cycle) { //give energy
|
if (Vector.magnitude(Vector.sub(this.position, player.position)) < 250 && m.immuneCycle < m.cycle) { //give energy
|
||||||
Matter.Body.setAngularVelocity(this, this.spin)
|
Matter.Body.setAngularVelocity(this, this.spin)
|
||||||
@@ -3692,7 +3629,6 @@ const b = {
|
|||||||
let history = m.history[(m.cycle - this.followDelay) % 600]
|
let history = m.history[(m.cycle - this.followDelay) % 600]
|
||||||
Matter.Body.setPosition(this, { x: history.position.x, y: history.position.y - history.yOff + 24.2859 }) //bullets move with player
|
Matter.Body.setPosition(this, { x: history.position.x, y: history.position.y - history.yOff + 24.2859 }) //bullets move with player
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
Composite.add(engine.world, bullet[me]); //add bullet to world
|
Composite.add(engine.world, bullet[me]); //add bullet to world
|
||||||
b.setDynamoBotDelay()
|
b.setDynamoBotDelay()
|
||||||
@@ -4317,7 +4253,7 @@ const b = {
|
|||||||
orbitalSpeed: 0,
|
orbitalSpeed: 0,
|
||||||
phase: 2 * Math.PI * Math.random(),
|
phase: 2 * Math.PI * Math.random(),
|
||||||
do() {
|
do() {
|
||||||
if (!m.isCloak && !m.isBodiesAsleep) { //if time dilation isn't active
|
if (!m.isCloak) { //if time dilation isn't active
|
||||||
const size = 33
|
const size = 33
|
||||||
q = Matter.Query.region(mob, {
|
q = Matter.Query.region(mob, {
|
||||||
min: { x: this.position.x - size, y: this.position.y - size },
|
min: { x: this.position.x - size, y: this.position.y - size },
|
||||||
@@ -4850,10 +4786,8 @@ const b = {
|
|||||||
// bullet[me].restitution = 0.4
|
// bullet[me].restitution = 0.4
|
||||||
bullet[me].frictionAir = 0.034;
|
bullet[me].frictionAir = 0.034;
|
||||||
bullet[me].do = function() {
|
bullet[me].do = function() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
const scale = 1 - 0.034 / tech.isBulletsLastLonger
|
const scale = 1 - 0.034 / tech.isBulletsLastLonger
|
||||||
Matter.Body.scale(this, scale, scale);
|
Matter.Body.scale(this, scale, scale);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5016,15 +4950,10 @@ const b = {
|
|||||||
ctx.moveTo(this.waves[i].position.x + this.waves[i].radius, this.waves[i].position.y)
|
ctx.moveTo(this.waves[i].position.x + this.waves[i].radius, this.waves[i].position.y)
|
||||||
ctx.arc(this.waves[i].position.x, this.waves[i].position.y, this.waves[i].radius, 0, 2 * Math.PI);
|
ctx.arc(this.waves[i].position.x, this.waves[i].position.y, this.waves[i].radius, 0, 2 * Math.PI);
|
||||||
// collisions
|
// collisions
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
|
|
||||||
|
|
||||||
if (tech.isBulletTeleport && Math.random() < 0.04) {
|
if (tech.isBulletTeleport && Math.random() < 0.04) {
|
||||||
const scale = 400 * Math.random()
|
const scale = 400 * Math.random()
|
||||||
this.waves[i].position = Vector.add(this.waves[i].position, { x: scale * (Math.random() - 0.5), y: scale * (Math.random() - 0.5) })
|
this.waves[i].position = Vector.add(this.waves[i].position, { x: scale * (Math.random() - 0.5), y: scale * (Math.random() - 0.5) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (let j = 0, len = mob.length; j < len; j++) {
|
for (let j = 0, len = mob.length; j < len; j++) {
|
||||||
const dist = Vector.magnitude(Vector.sub(this.waves[i].position, mob[j].position))
|
const dist = Vector.magnitude(Vector.sub(this.waves[i].position, mob[j].position))
|
||||||
const r = mob[j].radius + 30
|
const r = mob[j].radius + 30
|
||||||
@@ -5071,7 +5000,6 @@ const b = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.waves[i].radius += tech.waveBeamSpeed * this.waves[i].expanding //expand / move
|
this.waves[i].radius += tech.waveBeamSpeed * this.waves[i].expanding //expand / move
|
||||||
}
|
|
||||||
// if (this.waves[i].radius > end) this.waves.splice(i, 1) //end
|
// if (this.waves[i].radius > end) this.waves.splice(i, 1) //end
|
||||||
if (this.waves[i].radius > end) {
|
if (this.waves[i].radius > end) {
|
||||||
this.waves[i].expanding = -1
|
this.waves[i].expanding = -1
|
||||||
@@ -5109,7 +5037,6 @@ const b = {
|
|||||||
ctx.arc(this.waves[i].position.x, this.waves[i].position.y, this.waves[i].radius, this.waves[i].angle, this.waves[i].angle + this.waves[i].arc);
|
ctx.arc(this.waves[i].position.x, this.waves[i].position.y, this.waves[i].radius, this.waves[i].angle, this.waves[i].angle + this.waves[i].arc);
|
||||||
// collisions
|
// collisions
|
||||||
//using small angle linear approximation of circle arc, this will not work if the arc gets large // https://stackoverflow.com/questions/13652518/efficiently-find-points-inside-a-circle-sector
|
//using small angle linear approximation of circle arc, this will not work if the arc gets large // https://stackoverflow.com/questions/13652518/efficiently-find-points-inside-a-circle-sector
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
if (tech.isBulletTeleport && Math.random() < 0.05) {
|
if (tech.isBulletTeleport && Math.random() < 0.05) {
|
||||||
if (Math.random() < 0.5) {
|
if (Math.random() < 0.5) {
|
||||||
// const scale = 500 * Math.random()
|
// const scale = 500 * Math.random()
|
||||||
@@ -5166,7 +5093,6 @@ const b = {
|
|||||||
// ctx.stroke(); //draw vibes
|
// ctx.stroke(); //draw vibes
|
||||||
|
|
||||||
this.waves[i].radius += tech.waveBeamSpeed * 2 * this.waves[i].expanding //expand / move
|
this.waves[i].radius += tech.waveBeamSpeed * 2 * this.waves[i].expanding //expand / move
|
||||||
}
|
|
||||||
if (this.waves[i].radius > end) {
|
if (this.waves[i].radius > end) {
|
||||||
this.waves[i].expanding = -1
|
this.waves[i].expanding = -1
|
||||||
this.waves[i].reflection--
|
this.waves[i].reflection--
|
||||||
@@ -5291,7 +5217,6 @@ const b = {
|
|||||||
if (tech.waveReflections) {
|
if (tech.waveReflections) {
|
||||||
bullet[me].reflectCycle = totalCycles / tech.waveReflections //tech.waveLengthRange
|
bullet[me].reflectCycle = totalCycles / tech.waveReflections //tech.waveLengthRange
|
||||||
bullet[me].do = function() {
|
bullet[me].do = function() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
this.query()
|
this.query()
|
||||||
if (this.cycle > this.reflectCycle) {
|
if (this.cycle > this.reflectCycle) {
|
||||||
this.reflectCycle += totalCycles / tech.waveReflections
|
this.reflectCycle += totalCycles / tech.waveReflections
|
||||||
@@ -5300,15 +5225,12 @@ const b = {
|
|||||||
}
|
}
|
||||||
this.wiggle()
|
this.wiggle()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
bullet[me].do = function() {
|
bullet[me].do = function() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
this.query()
|
this.query()
|
||||||
this.wiggle();
|
this.wiggle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Composite.add(engine.world, bullet[me]); //add bullet to world
|
Composite.add(engine.world, bullet[me]); //add bullet to world
|
||||||
Matter.Body.setVelocity(bullet[me], {
|
Matter.Body.setVelocity(bullet[me], {
|
||||||
x: tech.waveBeamSpeed * Math.cos(m.angle),
|
x: tech.waveBeamSpeed * Math.cos(m.angle),
|
||||||
@@ -5502,10 +5424,8 @@ const b = {
|
|||||||
ctx.arc(this.position.x, this.position.y, this.maxRadius, 0, 2 * Math.PI);
|
ctx.arc(this.position.x, this.position.y, this.maxRadius, 0, 2 * Math.PI);
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
bullet[me].grow = function() {
|
bullet[me].grow = function() {
|
||||||
this.stuck(); //runs different code based on what the bullet is stuck to
|
this.stuck(); //runs different code based on what the bullet is stuck to
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
let scale = 1.01
|
let scale = 1.01
|
||||||
if (tech.isSporeGrowth && !(simulation.cycle % 40)) { //release a spore
|
if (tech.isSporeGrowth && !(simulation.cycle % 40)) { //release a spore
|
||||||
if (tech.isSporeWorm) {
|
if (tech.isSporeWorm) {
|
||||||
@@ -5524,8 +5444,6 @@ const b = {
|
|||||||
this.radius *= scale
|
this.radius *= scale
|
||||||
if (this.radius > this.maxRadius) this.endCycle = 0;
|
if (this.radius > this.maxRadius) this.endCycle = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// this.force.y += this.mass * 0.00045;
|
// this.force.y += this.mass * 0.00045;
|
||||||
|
|
||||||
//draw green glow
|
//draw green glow
|
||||||
|
|||||||
12
js/mob.js
12
js/mob.js
@@ -59,7 +59,7 @@ const mobs = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function applySlow(whom) {
|
function applySlow(whom) {
|
||||||
if (!whom.shield && !whom.isShielded && !m.isBodiesAsleep) {
|
if (!whom.shield && !whom.isShielded) {
|
||||||
if (whom.isBoss) cycles = Math.floor(cycles * 0.25)
|
if (whom.isBoss) cycles = Math.floor(cycles * 0.25)
|
||||||
let i = whom.status.length
|
let i = whom.status.length
|
||||||
while (i--) {
|
while (i--) {
|
||||||
@@ -98,7 +98,7 @@ const mobs = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
statusStun(who, cycles = 180) {
|
statusStun(who, cycles = 180) {
|
||||||
if (!who.shield && !who.isShielded && !m.isBodiesAsleep) {
|
if (!who.shield && !who.isShielded) {
|
||||||
Matter.Body.setVelocity(who, {
|
Matter.Body.setVelocity(who, {
|
||||||
x: who.velocity.x * 0.8,
|
x: who.velocity.x * 0.8,
|
||||||
y: who.velocity.y * 0.8
|
y: who.velocity.y * 0.8
|
||||||
@@ -153,7 +153,7 @@ const mobs = {
|
|||||||
if (!who.isShielded && who.alive && who.damageReduction > 0) {
|
if (!who.isShielded && who.alive && who.damageReduction > 0) {
|
||||||
who.status.push({
|
who.status.push({
|
||||||
effect() {
|
effect() {
|
||||||
if ((simulation.cycle - this.startCycle) % 30 === 0 && !m.isBodiesAsleep) {
|
if ((simulation.cycle - this.startCycle) % 30 === 0) {
|
||||||
let dmg = b.dmgScale * this.dmg
|
let dmg = b.dmgScale * this.dmg
|
||||||
who.damage(dmg);
|
who.damage(dmg);
|
||||||
if (who.damageReduction) {
|
if (who.damageReduction) {
|
||||||
@@ -822,7 +822,6 @@ const mobs = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
grow() {
|
grow() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
if (this.seePlayer.recall) {
|
if (this.seePlayer.recall) {
|
||||||
if (this.radius < 80) {
|
if (this.radius < 80) {
|
||||||
const scale = 1.01;
|
const scale = 1.01;
|
||||||
@@ -843,7 +842,6 @@ const mobs = {
|
|||||||
this.fill = `hsl(144, ${this.radius}%, 50%)`;
|
this.fill = `hsl(144, ${this.radius}%, 50%)`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
search() {
|
search() {
|
||||||
//be sure to declare searchTarget in mob spawn
|
//be sure to declare searchTarget in mob spawn
|
||||||
@@ -943,7 +941,6 @@ const mobs = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
fire() {
|
fire() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
const setNoseShape = () => {
|
const setNoseShape = () => {
|
||||||
const mag = this.radius + this.radius * this.noseLength;
|
const mag = this.radius + this.radius * this.noseLength;
|
||||||
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
|
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
|
||||||
@@ -991,7 +988,6 @@ const mobs = {
|
|||||||
// this.noseLength += this.fireFreq / 4;
|
// this.noseLength += this.fireFreq / 4;
|
||||||
// setNoseShape();
|
// setNoseShape();
|
||||||
// }
|
// }
|
||||||
}
|
|
||||||
},
|
},
|
||||||
// launch() {
|
// launch() {
|
||||||
// if (this.seePlayer.recall) {
|
// if (this.seePlayer.recall) {
|
||||||
@@ -1038,13 +1034,11 @@ const mobs = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
timeLimit() {
|
timeLimit() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
this.timeLeft--;
|
this.timeLeft--;
|
||||||
if (this.timeLeft < 0) {
|
if (this.timeLeft < 0) {
|
||||||
this.isDropPowerUp = false;
|
this.isDropPowerUp = false;
|
||||||
this.death(); //death with no power up
|
this.death(); //death with no power up
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
healthBar() { //draw health by mob //most health bars are drawn in mobs.healthbar();
|
healthBar() { //draw health by mob //most health bars are drawn in mobs.healthbar();
|
||||||
if (this.seePlayer.recall) {
|
if (this.seePlayer.recall) {
|
||||||
|
|||||||
@@ -14,14 +14,16 @@ const simulation = {
|
|||||||
}
|
}
|
||||||
m.move();
|
m.move();
|
||||||
m.look();
|
m.look();
|
||||||
simulation.checks();
|
|
||||||
simulation.camera();
|
simulation.camera();
|
||||||
level.custom();
|
level.custom();
|
||||||
powerUps.do();
|
powerUps.do();
|
||||||
mobs.draw();
|
mobs.draw();
|
||||||
simulation.draw.cons();
|
simulation.draw.cons();
|
||||||
simulation.draw.body();
|
simulation.draw.body();
|
||||||
if (!m.isBodiesAsleep) mobs.loop();
|
if (!m.isBodiesAsleep) {
|
||||||
|
simulation.checks();
|
||||||
|
mobs.loop();
|
||||||
|
}
|
||||||
mobs.healthBar();
|
mobs.healthBar();
|
||||||
m.draw();
|
m.draw();
|
||||||
m.hold();
|
m.hold();
|
||||||
@@ -873,7 +875,7 @@ const simulation = {
|
|||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
checks() {
|
checks() {
|
||||||
if (!(simulation.cycle % 60) && !m.isBodiesAsleep) { //once a second
|
if (!(simulation.cycle % 60)) { //once a second
|
||||||
//energy overfill
|
//energy overfill
|
||||||
if (m.energy > m.maxEnergy) m.energy = m.maxEnergy + (m.energy - m.maxEnergy) * tech.overfillDrain //every second energy above max energy loses 25%
|
if (m.energy > m.maxEnergy) m.energy = m.maxEnergy + (m.energy - m.maxEnergy) * tech.overfillDrain //every second energy above max energy loses 25%
|
||||||
if (tech.isFlipFlopEnergy && m.immuneCycle < m.cycle) {
|
if (tech.isFlipFlopEnergy && m.immuneCycle < m.cycle) {
|
||||||
|
|||||||
80
js/spawn.js
80
js/spawn.js
@@ -431,9 +431,8 @@ const spawn = {
|
|||||||
// });
|
// });
|
||||||
this.modeDo(); //this does different things based on the mode
|
this.modeDo(); //this does different things based on the mode
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
if (!m.isBodiesAsleep) this.cycle++; //switch modes÷ if time isn't paused
|
this.cycle++; //switch modes÷ if time isn't paused
|
||||||
this.totalCycles++;
|
this.totalCycles++;
|
||||||
// if (!m.isBodiesAsleep) {
|
|
||||||
if (this.health > 0.25) {
|
if (this.health > 0.25) {
|
||||||
if (this.cycle > this.endCycle) {
|
if (this.cycle > this.endCycle) {
|
||||||
this.cycle = 0;
|
this.cycle = 0;
|
||||||
@@ -491,7 +490,7 @@ const spawn = {
|
|||||||
}
|
}
|
||||||
me.spawnInterval = 395
|
me.spawnInterval = 395
|
||||||
me.modeSpawns = function() {
|
me.modeSpawns = function() {
|
||||||
if (!(this.cycle % this.spawnInterval) && !m.isBodiesAsleep && mob.length < 40) {
|
if (!(this.cycle % this.spawnInterval) && mob.length < 40) {
|
||||||
if (this.mode !== 3) Matter.Body.setAngularVelocity(this, 0.1)
|
if (this.mode !== 3) Matter.Body.setAngularVelocity(this, 0.1)
|
||||||
//fire a bullet from each vertex
|
//fire a bullet from each vertex
|
||||||
const whoSpawn = spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)];
|
const whoSpawn = spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)];
|
||||||
@@ -504,7 +503,7 @@ const spawn = {
|
|||||||
y: this.velocity.y + velocity.y
|
y: this.velocity.y + velocity.y
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!(this.cycle % 2 * this.spawnInterval) && !m.isBodiesAsleep && mob.length < 40) {
|
if (!(this.cycle % 2 * this.spawnInterval) && mob.length < 40) {
|
||||||
const len = (this.totalCycles / 600 + simulation.difficulty / 2 - 30) / 15
|
const len = (this.totalCycles / 600 + simulation.difficulty / 2 - 30) / 15
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
spawn.randomLevelBoss(3000 * (simulation.isHorizontalFlipped ? -1 : 1) + 2000 * (Math.random() - 0.5), -1100 + 200 * (Math.random() - 0.5))
|
spawn.randomLevelBoss(3000 * (simulation.isHorizontalFlipped ? -1 : 1) + 2000 * (Math.random() - 0.5), -1100 + 200 * (Math.random() - 0.5))
|
||||||
@@ -650,7 +649,7 @@ const spawn = {
|
|||||||
ctx.lineTo(best.x, best.y);
|
ctx.lineTo(best.x, best.y);
|
||||||
}
|
}
|
||||||
me.modeLasers = function() {
|
me.modeLasers = function() {
|
||||||
if (!m.isBodiesAsleep && !this.isStunned) {
|
if (!this.isStunned) {
|
||||||
let slowed = false //check if slowed
|
let slowed = false //check if slowed
|
||||||
for (let i = 0; i < this.status.length; i++) {
|
for (let i = 0; i < this.status.length; i++) {
|
||||||
if (this.status[i].type === "slow") {
|
if (this.status[i].type === "slow") {
|
||||||
@@ -795,7 +794,7 @@ const spawn = {
|
|||||||
this.force.y += force.y;
|
this.force.y += force.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(simulation.cycle % 30) && !m.isBodiesAsleep) {
|
if (!(simulation.cycle % 30)) {
|
||||||
//find blocks to turn into mobs
|
//find blocks to turn into mobs
|
||||||
for (let i = 0; i < body.length; i++) {
|
for (let i = 0; i < body.length; i++) {
|
||||||
if (Vector.magnitude(Vector.sub(this.position, body[i].position)) < 700 && !body[i].isNotHoldable) { // check distance for each block
|
if (Vector.magnitude(Vector.sub(this.position, body[i].position)) < 700 && !body[i].isNotHoldable) { // check distance for each block
|
||||||
@@ -899,8 +898,6 @@ const spawn = {
|
|||||||
me.do = function() { //grow phase only occurs for growCycles
|
me.do = function() { //grow phase only occurs for growCycles
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.seePlayerCheck();
|
this.seePlayerCheck();
|
||||||
|
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
this.cycle++
|
this.cycle++
|
||||||
if (this.cycle > growCycles) {
|
if (this.cycle > growCycles) {
|
||||||
this.damageReduction = 1.8 //take extra damage
|
this.damageReduction = 1.8 //take extra damage
|
||||||
@@ -911,7 +908,6 @@ const spawn = {
|
|||||||
this.radius *= scale;
|
this.radius *= scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
me.normalDo = function() {
|
me.normalDo = function() {
|
||||||
this.gravity();
|
this.gravity();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
@@ -957,8 +953,6 @@ const spawn = {
|
|||||||
}
|
}
|
||||||
me.damageReduction = 0.17 / (tech.isScaleMobsWithDuplication ? 1 + tech.duplicationChance() : 1); //me.damageReductionGoal
|
me.damageReduction = 0.17 / (tech.isScaleMobsWithDuplication ? 1 + tech.duplicationChance() : 1); //me.damageReductionGoal
|
||||||
me.do = function() {
|
me.do = function() {
|
||||||
// // this.armor();
|
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
this.seePlayerByDistOrLOS();
|
this.seePlayerByDistOrLOS();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.attraction();
|
this.attraction();
|
||||||
@@ -983,7 +977,6 @@ const spawn = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
me.onDeath = function() {
|
me.onDeath = function() {
|
||||||
this.isCell = false;
|
this.isCell = false;
|
||||||
@@ -1030,8 +1023,6 @@ const spawn = {
|
|||||||
};
|
};
|
||||||
me.damageReduction = 0.2 / (tech.isScaleMobsWithDuplication ? 1 + tech.duplicationChance() : 1);
|
me.damageReduction = 0.2 / (tech.isScaleMobsWithDuplication ? 1 + tech.duplicationChance() : 1);
|
||||||
me.doAwake = function() {
|
me.doAwake = function() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
// this.armor();
|
|
||||||
this.alwaysSeePlayer();
|
this.alwaysSeePlayer();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.attraction();
|
this.attraction();
|
||||||
@@ -1052,7 +1043,6 @@ const spawn = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
me.do = function() {
|
me.do = function() {
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
if (this.seePlayer.recall) {
|
if (this.seePlayer.recall) {
|
||||||
@@ -1153,7 +1143,7 @@ const spawn = {
|
|||||||
me.do = function() {
|
me.do = function() {
|
||||||
if (this.isInvulnerable) {
|
if (this.isInvulnerable) {
|
||||||
if (this.invulnerabilityCountDown > 0) {
|
if (this.invulnerabilityCountDown > 0) {
|
||||||
if (!m.isBodiesAsleep) this.invulnerabilityCountDown--
|
this.invulnerabilityCountDown--
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
let vertices = this.vertices;
|
let vertices = this.vertices;
|
||||||
ctx.moveTo(vertices[0].x, vertices[0].y);
|
ctx.moveTo(vertices[0].x, vertices[0].y);
|
||||||
@@ -1234,7 +1224,7 @@ const spawn = {
|
|||||||
me.do = function() {
|
me.do = function() {
|
||||||
if (this.isInvulnerable) {
|
if (this.isInvulnerable) {
|
||||||
if (this.invulnerabilityCountDown > 0) {
|
if (this.invulnerabilityCountDown > 0) {
|
||||||
if (!m.isBodiesAsleep) this.invulnerabilityCountDown--
|
this.invulnerabilityCountDown--
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
let vertices = this.vertices;
|
let vertices = this.vertices;
|
||||||
ctx.moveTo(vertices[0].x, vertices[0].y);
|
ctx.moveTo(vertices[0].x, vertices[0].y);
|
||||||
@@ -1745,7 +1735,7 @@ const spawn = {
|
|||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
if (this.seePlayer.recall) {
|
if (this.seePlayer.recall) {
|
||||||
//throw large seekers
|
//throw large seekers
|
||||||
if (!(simulation.cycle % 240) && !m.isBodiesAsleep) {
|
if (!(simulation.cycle % 240)) {
|
||||||
spawn.seeker(this.position.x, this.position.y, 15 * (0.7 + 0.5 * Math.random()), 7); //give the bullet a rotational velocity as if they were attached to a vertex
|
spawn.seeker(this.position.x, this.position.y, 15 * (0.7 + 0.5 * Math.random()), 7); //give the bullet a rotational velocity as if they were attached to a vertex
|
||||||
const who = mob[mob.length - 1]
|
const who = mob[mob.length - 1]
|
||||||
Matter.Body.setDensity(who, 0.00001); //normal is 0.001
|
Matter.Body.setDensity(who, 0.00001); //normal is 0.001
|
||||||
@@ -1982,7 +1972,7 @@ const spawn = {
|
|||||||
ctx.strokeStyle = "rgba(255,255,255,0.7)";
|
ctx.strokeStyle = "rgba(255,255,255,0.7)";
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
} else if (this.invulnerabilityCountDown > 0) {
|
} else if (this.invulnerabilityCountDown > 0) {
|
||||||
if (!m.isBodiesAsleep) this.invulnerabilityCountDown--
|
this.invulnerabilityCountDown--
|
||||||
} else {
|
} else {
|
||||||
this.isInvulnerable = true
|
this.isInvulnerable = true
|
||||||
if (this.damageReduction) this.startingDamageReduction = this.damageReduction
|
if (this.damageReduction) this.startingDamageReduction = this.damageReduction
|
||||||
@@ -2369,7 +2359,7 @@ const spawn = {
|
|||||||
// ctx.setLineDash([]);
|
// ctx.setLineDash([]);
|
||||||
// ctx.fillStyle = "rgba(150,0,255,0.03)";
|
// ctx.fillStyle = "rgba(150,0,255,0.03)";
|
||||||
// ctx.fill();
|
// ctx.fill();
|
||||||
if (!m.isBodiesAsleep && !this.isStunned && !this.isSlowed) {
|
if (!this.isStunned && !this.isSlowed) {
|
||||||
if (this.followDelay > this.delayLimit) this.followDelay -= 0.15;
|
if (this.followDelay > this.delayLimit) this.followDelay -= 0.15;
|
||||||
let history = m.history[(m.cycle - Math.floor(this.followDelay)) % 600]
|
let history = m.history[(m.cycle - Math.floor(this.followDelay)) % 600]
|
||||||
Matter.Body.setPosition(this, { x: history.position.x, y: history.position.y - history.yOff + 24.2859 }) //bullets move with player
|
Matter.Body.setPosition(this, { x: history.position.x, y: history.position.y - history.yOff + 24.2859 }) //bullets move with player
|
||||||
@@ -2403,7 +2393,6 @@ const spawn = {
|
|||||||
};
|
};
|
||||||
spawn.shield(me, x, y);
|
spawn.shield(me, x, y);
|
||||||
me.do = function() {
|
me.do = function() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
this.seePlayerByLookingAt();
|
this.seePlayerByLookingAt();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.attraction();
|
this.attraction();
|
||||||
@@ -2449,7 +2438,6 @@ const spawn = {
|
|||||||
} else {
|
} else {
|
||||||
this.laserPos = this.position;
|
this.laserPos = this.position;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
laserTargetingBoss(x, y, radius = 80) {
|
laserTargetingBoss(x, y, radius = 80) {
|
||||||
@@ -2850,7 +2838,6 @@ const spawn = {
|
|||||||
me.fire = function() {
|
me.fire = function() {
|
||||||
// this.armor();
|
// this.armor();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
if (!m.isCloak && !this.isStunned) {
|
if (!m.isCloak && !this.isStunned) {
|
||||||
if (this.isFiring) {
|
if (this.isFiring) {
|
||||||
if (this.fireCycle > this.fireDelay) { //fire
|
if (this.fireCycle > this.fireDelay) { //fire
|
||||||
@@ -2929,7 +2916,6 @@ const spawn = {
|
|||||||
} else {
|
} else {
|
||||||
this.isFiring = false
|
this.isFiring = false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
pulsar(x, y, radius = 40) {
|
pulsar(x, y, radius = 40) {
|
||||||
@@ -2971,7 +2957,6 @@ const spawn = {
|
|||||||
me.do = function() {
|
me.do = function() {
|
||||||
this.seePlayerByLookingAt();
|
this.seePlayerByLookingAt();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
if (this.seePlayer.recall) {
|
if (this.seePlayer.recall) {
|
||||||
if (this.isFiring) {
|
if (this.isFiring) {
|
||||||
if (this.fireCycle > this.fireDelay) { //fire
|
if (this.fireCycle > this.fireDelay) { //fire
|
||||||
@@ -3055,7 +3040,6 @@ const spawn = {
|
|||||||
} else {
|
} else {
|
||||||
this.isFiring = false
|
this.isFiring = false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
laser(x, y, radius = 30) {
|
laser(x, y, radius = 30) {
|
||||||
@@ -3092,12 +3076,6 @@ const spawn = {
|
|||||||
});
|
});
|
||||||
Composite.add(engine.world, me.constraint);
|
Composite.add(engine.world, me.constraint);
|
||||||
}, 2000); //add in a delay in case the level gets flipped left right
|
}, 2000); //add in a delay in case the level gets flipped left right
|
||||||
|
|
||||||
|
|
||||||
// me.startingPosition = {
|
|
||||||
// x: x,
|
|
||||||
// y: y
|
|
||||||
// }
|
|
||||||
me.count = 0;
|
me.count = 0;
|
||||||
me.frictionAir = 0.03;
|
me.frictionAir = 0.03;
|
||||||
// me.torque -= me.inertia * 0.002
|
// me.torque -= me.inertia * 0.002
|
||||||
@@ -3105,12 +3083,10 @@ const spawn = {
|
|||||||
Matter.Body.setDensity(me, 0.03); //extra dense //normal is 0.001 //makes effective life much larger
|
Matter.Body.setDensity(me, 0.03); //extra dense //normal is 0.001 //makes effective life much larger
|
||||||
me.damageReduction = 0.25 / (tech.isScaleMobsWithDuplication ? 1 + tech.duplicationChance() : 1)
|
me.damageReduction = 0.25 / (tech.isScaleMobsWithDuplication ? 1 + tech.duplicationChance() : 1)
|
||||||
me.isBoss = true;
|
me.isBoss = true;
|
||||||
|
|
||||||
// spawn.shield(me, x, y, 1); //not working, not sure why
|
// spawn.shield(me, x, y, 1); //not working, not sure why
|
||||||
me.onDeath = function() {
|
me.onDeath = function() {
|
||||||
powerUps.spawnBossPowerUp(this.position.x, this.position.y)
|
powerUps.spawnBossPowerUp(this.position.x, this.position.y)
|
||||||
};
|
};
|
||||||
|
|
||||||
me.rotateVelocity = Math.min(0.0045, 0.0015 * simulation.accelScale * simulation.accelScale) * (level.levelsCleared > 8 ? 1 : -1) * (simulation.isHorizontalFlipped ? -1 : 1)
|
me.rotateVelocity = Math.min(0.0045, 0.0015 * simulation.accelScale * simulation.accelScale) * (level.levelsCleared > 8 ? 1 : -1) * (simulation.isHorizontalFlipped ? -1 : 1)
|
||||||
me.do = function() {
|
me.do = function() {
|
||||||
// this.armor();
|
// this.armor();
|
||||||
@@ -3118,7 +3094,6 @@ const spawn = {
|
|||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
|
|
||||||
if (!this.isStunned) {
|
if (!this.isStunned) {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
//check if slowed
|
//check if slowed
|
||||||
let slowed = false
|
let slowed = false
|
||||||
for (let i = 0; i < this.status.length; i++) {
|
for (let i = 0; i < this.status.length; i++) {
|
||||||
@@ -3132,7 +3107,7 @@ const spawn = {
|
|||||||
Matter.Body.setAngle(this, this.count * this.rotateVelocity)
|
Matter.Body.setAngle(this, this.count * this.rotateVelocity)
|
||||||
Matter.Body.setAngularVelocity(this, 0)
|
Matter.Body.setAngularVelocity(this, 0)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
this.lasers(this.vertices[0], this.angle + Math.PI / 3);
|
this.lasers(this.vertices[0], this.angle + Math.PI / 3);
|
||||||
this.lasers(this.vertices[1], this.angle + Math.PI);
|
this.lasers(this.vertices[1], this.angle + Math.PI);
|
||||||
@@ -3254,12 +3229,9 @@ const spawn = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
me.do = function() {
|
me.do = function() {
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
// this.gravity();
|
|
||||||
this.seePlayerByLookingAt();
|
this.seePlayerByLookingAt();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.attraction();
|
this.attraction();
|
||||||
|
|
||||||
if (this.isSpikeReset) {
|
if (this.isSpikeReset) {
|
||||||
if (this.seePlayer.recall) {
|
if (this.seePlayer.recall) {
|
||||||
const dist = Vector.sub(this.seePlayer.position, this.position);
|
const dist = Vector.sub(this.seePlayer.position, this.position);
|
||||||
@@ -3304,7 +3276,6 @@ const spawn = {
|
|||||||
this.vertices[this.spikeVertex].x = this.position.x + spike.x
|
this.vertices[this.spikeVertex].x = this.position.x + spike.x
|
||||||
this.vertices[this.spikeVertex].y = this.position.y + spike.y
|
this.vertices[this.spikeVertex].y = this.position.y + spike.y
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -3385,7 +3356,6 @@ const spawn = {
|
|||||||
powerUps.spawnBossPowerUp(this.position.x, this.position.y)
|
powerUps.spawnBossPowerUp(this.position.x, this.position.y)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//invulnerability every 1/4 fraction of life lost
|
//invulnerability every 1/4 fraction of life lost
|
||||||
//required setup for invulnerable
|
//required setup for invulnerable
|
||||||
me.isInvulnerable = false
|
me.isInvulnerable = false
|
||||||
@@ -3401,7 +3371,7 @@ const spawn = {
|
|||||||
}
|
}
|
||||||
if (this.isInvulnerable) {
|
if (this.isInvulnerable) {
|
||||||
if (this.invulnerabilityCountDown > 0) {
|
if (this.invulnerabilityCountDown > 0) {
|
||||||
if (!m.isBodiesAsleep) this.invulnerabilityCountDown--
|
this.invulnerabilityCountDown--
|
||||||
//graphics //draw a super shield?
|
//graphics //draw a super shield?
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
let vertices = this.vertices;
|
let vertices = this.vertices;
|
||||||
@@ -3452,7 +3422,7 @@ const spawn = {
|
|||||||
this.seePlayerByHistory(60);
|
this.seePlayerByHistory(60);
|
||||||
this.attraction();
|
this.attraction();
|
||||||
//traveling laser
|
//traveling laser
|
||||||
if (!m.isBodiesAsleep) this.laserAngle += this.isInvulnerable ? 0.06 : 0.015
|
this.laserAngle += this.isInvulnerable ? 0.06 : 0.015
|
||||||
for (let i = 0, len = this.vertices.length; i < len; i++) {
|
for (let i = 0, len = this.vertices.length; i < len; i++) {
|
||||||
// this.laserSword(this.vertices[1], this.angle + laserAngle);
|
// this.laserSword(this.vertices[1], this.angle + laserAngle);
|
||||||
const bend = bendFactor * Math.cos(this.laserAngle + 2 * Math.PI * i / len)
|
const bend = bendFactor * Math.cos(this.laserAngle + 2 * Math.PI * i / len)
|
||||||
@@ -3551,7 +3521,7 @@ const spawn = {
|
|||||||
this.seePlayerByHistory();
|
this.seePlayerByHistory();
|
||||||
this.attraction();
|
this.attraction();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
if (!m.isBodiesAsleep) this.sword() //does various things depending on what stage of the sword swing
|
this.sword() //does various things depending on what stage of the sword swing
|
||||||
|
|
||||||
// ctx.beginPath(); //hide map
|
// ctx.beginPath(); //hide map
|
||||||
// ctx.arc(this.position.x, this.position.y, 3000, 0, 2 * Math.PI); //* this.fireCycle / this.fireDelay
|
// ctx.arc(this.position.x, this.position.y, 3000, 0, 2 * Math.PI); //* this.fireCycle / this.fireDelay
|
||||||
@@ -3703,7 +3673,7 @@ const spawn = {
|
|||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.seePlayerByHistory(15);
|
this.seePlayerByHistory(15);
|
||||||
this.attraction();
|
this.attraction();
|
||||||
if (!m.isBodiesAsleep) this.sword() //does various things depending on what stage of the sword swing
|
this.sword() //does various things depending on what stage of the sword swing
|
||||||
};
|
};
|
||||||
me.swordWaiting = function() {
|
me.swordWaiting = function() {
|
||||||
if (
|
if (
|
||||||
@@ -3822,13 +3792,11 @@ const spawn = {
|
|||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.attraction();
|
this.attraction();
|
||||||
//draw
|
//draw
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
if (this.seePlayer.recall) {
|
if (this.seePlayer.recall) {
|
||||||
if (this.alpha < 1) this.alpha += 0.003 + 0.003 / simulation.CDScale;
|
if (this.alpha < 1) this.alpha += 0.003 + 0.003 / simulation.CDScale;
|
||||||
} else {
|
} else {
|
||||||
if (this.alpha > 0) this.alpha -= 0.03;
|
if (this.alpha > 0) this.alpha -= 0.03;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (this.alpha > 0) {
|
if (this.alpha > 0) {
|
||||||
if (this.alpha > 0.7) {
|
if (this.alpha > 0.7) {
|
||||||
this.healthBar();
|
this.healthBar();
|
||||||
@@ -3880,13 +3848,11 @@ const spawn = {
|
|||||||
this.attraction();
|
this.attraction();
|
||||||
this.search();
|
this.search();
|
||||||
//draw
|
//draw
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
if (this.distanceToPlayer2() < this.seeAtDistance2) {
|
if (this.distanceToPlayer2() < this.seeAtDistance2) {
|
||||||
if (this.alpha < 1) this.alpha += 0.005 * simulation.CDScale; //near player go solid
|
if (this.alpha < 1) this.alpha += 0.005 * simulation.CDScale; //near player go solid
|
||||||
} else {
|
} else {
|
||||||
if (this.alpha > 0) this.alpha -= 0.05; ///away from player, hide
|
if (this.alpha > 0) this.alpha -= 0.05; ///away from player, hide
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (this.alpha > 0) {
|
if (this.alpha > 0) {
|
||||||
if (this.alpha > 0.8 && this.seePlayer.recall) {
|
if (this.alpha > 0.8 && this.seePlayer.recall) {
|
||||||
this.healthBar();
|
this.healthBar();
|
||||||
@@ -4200,7 +4166,6 @@ const spawn = {
|
|||||||
this.seePlayerCheck();
|
this.seePlayerCheck();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
|
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
const setNoseShape = () => {
|
const setNoseShape = () => {
|
||||||
const mag = this.radius + this.radius * this.noseLength;
|
const mag = this.radius + this.radius * this.noseLength;
|
||||||
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
|
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
|
||||||
@@ -4255,7 +4220,6 @@ const spawn = {
|
|||||||
} else {
|
} else {
|
||||||
if (this.alpha > 0) this.alpha -= 0.03;
|
if (this.alpha > 0) this.alpha -= 0.03;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//draw
|
//draw
|
||||||
if (this.alpha > 0) {
|
if (this.alpha > 0) {
|
||||||
if (this.alpha > 0.95) {
|
if (this.alpha > 0.95) {
|
||||||
@@ -4324,7 +4288,7 @@ const spawn = {
|
|||||||
this.seePlayerCheck();
|
this.seePlayerCheck();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.attraction();
|
this.attraction();
|
||||||
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq) && !m.isBodiesAsleep) {
|
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq)) {
|
||||||
Matter.Body.setAngularVelocity(this, 0.14)
|
Matter.Body.setAngularVelocity(this, 0.14)
|
||||||
spawn.seeker(this.vertices[0].x, this.vertices[0].y, 20, 9); //give the bullet a rotational velocity as if they were attached to a vertex
|
spawn.seeker(this.vertices[0].x, this.vertices[0].y, 20, 9); //give the bullet a rotational velocity as if they were attached to a vertex
|
||||||
const who = mob[mob.length - 1]
|
const who = mob[mob.length - 1]
|
||||||
@@ -4354,7 +4318,7 @@ const spawn = {
|
|||||||
this.seePlayerCheck();
|
this.seePlayerCheck();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.attraction();
|
this.attraction();
|
||||||
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq) && !m.isBodiesAsleep) {
|
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq)) {
|
||||||
Matter.Body.setAngularVelocity(this, 0.14)
|
Matter.Body.setAngularVelocity(this, 0.14)
|
||||||
//fire a bullet from each vertex
|
//fire a bullet from each vertex
|
||||||
for (let i = 0, len = this.vertices.length; i < len; i++) {
|
for (let i = 0, len = this.vertices.length; i < len; i++) {
|
||||||
@@ -4397,7 +4361,7 @@ const spawn = {
|
|||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.attraction();
|
this.attraction();
|
||||||
this.repulsion();
|
this.repulsion();
|
||||||
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq) && !m.isBodiesAsleep) {
|
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq)) {
|
||||||
Matter.Body.setAngularVelocity(this, 0.11)
|
Matter.Body.setAngularVelocity(this, 0.11)
|
||||||
//fire a bullet from each vertex
|
//fire a bullet from each vertex
|
||||||
for (let i = 0, len = this.vertices.length; i < len; i++) {
|
for (let i = 0, len = this.vertices.length; i < len; i++) {
|
||||||
@@ -4494,7 +4458,6 @@ const spawn = {
|
|||||||
this.seePlayerCheck();
|
this.seePlayerCheck();
|
||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
|
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
const setNoseShape = () => {
|
const setNoseShape = () => {
|
||||||
const mag = this.radius + this.radius * this.noseLength;
|
const mag = this.radius + this.radius * this.noseLength;
|
||||||
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
|
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
|
||||||
@@ -4539,7 +4502,6 @@ const spawn = {
|
|||||||
this.noseLength -= this.fireFreq / 2;
|
this.noseLength -= this.fireFreq / 2;
|
||||||
setNoseShape();
|
setNoseShape();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
grenade(x, y, lifeSpan = 90 + Math.ceil(60 / simulation.accelScale), pulseRadius = Math.min(550, 250 + simulation.difficulty * 3), size = 3) {
|
grenade(x, y, lifeSpan = 90 + Math.ceil(60 / simulation.accelScale), pulseRadius = Math.min(550, 250 + simulation.difficulty * 3), size = 3) {
|
||||||
@@ -4637,7 +4599,6 @@ const spawn = {
|
|||||||
ctx.strokeStyle = "rgb(255,255,255)"
|
ctx.strokeStyle = "rgb(255,255,255)"
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
|
|
||||||
if (!m.isBodiesAsleep) {
|
|
||||||
this.cycle++
|
this.cycle++
|
||||||
if (this.cycle > this.maxCycles) {
|
if (this.cycle > this.maxCycles) {
|
||||||
this.cycle = 0
|
this.cycle = 0
|
||||||
@@ -4656,7 +4617,6 @@ const spawn = {
|
|||||||
ctx.strokeStyle = "rgb(200,200,255)"
|
ctx.strokeStyle = "rgb(200,200,255)"
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
streamBoss(x, y, radius = 110) {
|
streamBoss(x, y, radius = 110) {
|
||||||
@@ -4693,7 +4653,7 @@ const spawn = {
|
|||||||
this.repulsion();
|
this.repulsion();
|
||||||
|
|
||||||
this.cycle++
|
this.cycle++
|
||||||
if (this.seePlayer.recall && ((this.cycle % 15) === 0) && !m.isBodiesAsleep) {
|
if (this.seePlayer.recall && ((this.cycle % 15) === 0)) {
|
||||||
if (this.canFire) {
|
if (this.canFire) {
|
||||||
if (this.cycle > 120) {
|
if (this.cycle > 120) {
|
||||||
this.cycle = 0
|
this.cycle = 0
|
||||||
@@ -4910,7 +4870,7 @@ const spawn = {
|
|||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.attraction();
|
this.attraction();
|
||||||
this.cycle++
|
this.cycle++
|
||||||
if (this.seePlayer.recall && ((this.cycle % 10) === 0) && !m.isBodiesAsleep) {
|
if (this.seePlayer.recall && ((this.cycle % 10) === 0)) {
|
||||||
if (this.canFire) {
|
if (this.canFire) {
|
||||||
if (this.cycle > 120) {
|
if (this.cycle > 120) {
|
||||||
this.cycle = 0
|
this.cycle = 0
|
||||||
|
|||||||
13
todo.txt
13
todo.txt
@@ -1,16 +1,7 @@
|
|||||||
******************************************************** NEXT PATCH **************************************************
|
******************************************************** NEXT PATCH **************************************************
|
||||||
|
|
||||||
exit door has a 1 second delay and animation
|
removed about 80 !m.isBodiesAsleep
|
||||||
|
this could cause some bugs for bullets or mobs when time is dilated
|
||||||
reservoir map now has a flipped horizontal chance
|
|
||||||
map ruins renamed -> pavilion
|
|
||||||
|
|
||||||
all the individual !m.isBodiesAsleep are replaced with ones in the main game loop
|
|
||||||
this needs extensive bug testing?
|
|
||||||
should behave similarly to testing mode, which doesn't have issues
|
|
||||||
todo remove the checks from bullets and mobs, do this after update so it can be easy to revert
|
|
||||||
|
|
||||||
bug fixes
|
|
||||||
|
|
||||||
******************************************************** TODO ********************************************************
|
******************************************************** TODO ********************************************************
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user