adding mobs to aerie level
This commit is contained in:
77
js/spawn.js
77
js/spawn.js
@@ -477,6 +477,73 @@ const spawn = {
|
||||
}
|
||||
}
|
||||
},
|
||||
suckerBoss(x, y, radius = 120 + Math.ceil(Math.random() * 70)) {
|
||||
radius = 9 + radius / 8; //extra small
|
||||
mobs.spawn(x, y, 12, radius, "#000");
|
||||
let me = mob[mob.length - 1];
|
||||
me.stroke = "transparent"; //used for drawSneaker
|
||||
me.eventHorizon = radius * 33; //required for blackhole
|
||||
me.seeAtDistance2 = (me.eventHorizon + 500) * (me.eventHorizon + 500); //vision limit is event horizon
|
||||
me.accelMag = 0.00013 * game.accelScale;
|
||||
// me.frictionAir = 0.005;
|
||||
me.memory = 1000;
|
||||
Matter.Body.setDensity(me, 0.005); //extra dense //normal is 0.001 //makes effective life much larger
|
||||
me.do = function () {
|
||||
//keep it slow, to stop issues from explosion knock backs
|
||||
if (this.speed > 7) {
|
||||
Matter.Body.setVelocity(this, {
|
||||
x: this.velocity.x * 0.99,
|
||||
y: this.velocity.y * 0.99
|
||||
});
|
||||
}
|
||||
this.seePlayerByDistOrLOS();
|
||||
if (this.seePlayer.recall) {
|
||||
//eventHorizon waves in and out
|
||||
eventHorizon = this.eventHorizon * (0.93 + 0.25 * Math.sin(game.cycle * 0.017))
|
||||
|
||||
//accelerate towards the player
|
||||
const forceMag = this.accelMag * this.mass;
|
||||
const angle = Math.atan2(this.seePlayer.position.y - this.position.y, this.seePlayer.position.x - this.position.x);
|
||||
this.force.x += forceMag * Math.cos(angle);
|
||||
this.force.y += forceMag * Math.sin(angle);
|
||||
|
||||
//draw darkness
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.position.x, this.position.y, eventHorizon * 0.25, 0, 2 * Math.PI);
|
||||
ctx.fillStyle = "rgba(0,0,0,0.9)";
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.position.x, this.position.y, eventHorizon * 0.55, 0, 2 * Math.PI);
|
||||
ctx.fillStyle = "rgba(0,0,0,0.5)";
|
||||
ctx.fill();
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.position.x, this.position.y, eventHorizon, 0, 2 * Math.PI);
|
||||
ctx.fillStyle = "rgba(0,0,0,0.1)";
|
||||
ctx.fill();
|
||||
|
||||
this.healthBar();
|
||||
//when player is inside event horizon
|
||||
if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon) {
|
||||
mech.damage(0.0003 * game.dmgScale);
|
||||
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01
|
||||
const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x);
|
||||
player.force.x -= 1.25 * Math.cos(angle) * player.mass * game.g * (mech.onGround ? 1.8 : 1);
|
||||
player.force.y -= 0.97 * player.mass * game.g * Math.sin(angle);
|
||||
//draw line to player
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.position.x, this.position.y);
|
||||
ctx.lineTo(mech.pos.x, mech.pos.y);
|
||||
ctx.lineWidth = Math.min(60, this.radius * 2);
|
||||
ctx.strokeStyle = "rgba(0,0,0,0.5)";
|
||||
ctx.stroke();
|
||||
ctx.beginPath();
|
||||
ctx.arc(mech.pos.x, mech.pos.y, 40, 0, 2 * Math.PI);
|
||||
ctx.fillStyle = "rgba(0,0,0,0.3)";
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beamer(x, y, radius = 15 + Math.ceil(Math.random() * 15)) {
|
||||
mobs.spawn(x, y, 4, radius, "rgb(255,0,190)");
|
||||
let me = mob[mob.length - 1];
|
||||
@@ -1194,7 +1261,7 @@ const spawn = {
|
||||
let me = mob[mob.length - 1];
|
||||
//touch nothing
|
||||
me.collisionFilter.category = 0x010000; //act like a body
|
||||
me.collisionFilter.mask = 0x000001; //only collide with map
|
||||
me.collisionFilter.mask = 0x000101; //only collide with map
|
||||
me.inertia = Infinity;
|
||||
me.g = 0.0004; //required for gravity
|
||||
me.restitution = 0;
|
||||
@@ -1258,7 +1325,7 @@ const spawn = {
|
||||
let me = mob[mob.length - 1];
|
||||
//touch nothing
|
||||
me.collisionFilter.category = 0x010000; //act like a body
|
||||
me.collisionFilter.mask = 0x000001; //only collide with map
|
||||
me.collisionFilter.mask = 0x000101; //only collide with map
|
||||
me.g = 0.0003; //required for gravity
|
||||
// me.restitution = 0;
|
||||
me.stroke = "transparent"
|
||||
@@ -1306,7 +1373,7 @@ const spawn = {
|
||||
let me = mob[mob.length - 1];
|
||||
//touch nothing
|
||||
me.collisionFilter.category = 0x010000; //act like a body
|
||||
me.collisionFilter.mask = 0x000001; //only collide with map
|
||||
me.collisionFilter.mask = 0x000101; //only collide with map
|
||||
me.g = 0.0003; //required for gravity
|
||||
// me.restitution = 0;
|
||||
me.stroke = "transparent"
|
||||
@@ -1354,7 +1421,7 @@ const spawn = {
|
||||
let me = mob[mob.length - 1];
|
||||
//touch nothing
|
||||
me.collisionFilter.category = 0x010000; //act like a body
|
||||
me.collisionFilter.mask = 0x000001; //only collide with map
|
||||
me.collisionFilter.mask = 0x000101; //only collide with map
|
||||
me.g = 0.0003; //required for gravity
|
||||
me.restitution = 0;
|
||||
me.stroke = "transparent"
|
||||
@@ -1401,7 +1468,7 @@ const spawn = {
|
||||
let me = mob[mob.length - 1];
|
||||
//touch nothing
|
||||
me.collisionFilter.category = 0x010000; //act like a body
|
||||
me.collisionFilter.mask = 0x000001; //only collide with map
|
||||
me.collisionFilter.mask = 0x000101; //only collide with map
|
||||
me.g = 0.0003; //required for gravity
|
||||
me.restitution = 0;
|
||||
me.stroke = "transparent"
|
||||
|
||||
Reference in New Issue
Block a user