cell boss testing
This commit is contained in:
@@ -148,19 +148,19 @@ const b = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "high explosives",
|
name: "high explosives",
|
||||||
description: "the radius of <strong class='color-e'>explosions</strong> are +25% <strong>larger</strong>",
|
description: "<strong class='color-e'>explosions</strong> do +20% more <strong class='color-d'>damage</strong><br><strong class='color-e'>explosive</strong> area is +44% <strong>larger</strong>",
|
||||||
maxCount: 3,
|
maxCount: 3,
|
||||||
count: 0,
|
count: 0,
|
||||||
allowed() {
|
allowed() {
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
effect: () => {
|
effect: () => {
|
||||||
b.modExplosionRadius += 0.25;
|
b.modExplosionRadius += 0.2;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "electric reactive armour",
|
name: "electric reactive armour",
|
||||||
description: "<strong class='color-e'>explosions</strong> drain <strong class='color-f'>energy</strong> instead of doing <strong>harm</strong>",
|
description: "<strong class='color-e'>explosions</strong> do no <strong>harm</strong>, but drain <strong class='color-f'>energy</strong>",
|
||||||
maxCount: 1,
|
maxCount: 1,
|
||||||
count: 0,
|
count: 0,
|
||||||
allowed() {
|
allowed() {
|
||||||
@@ -276,7 +276,7 @@ const b = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "entanglement",
|
name: "entanglement",
|
||||||
description: "using your first gun reduces <strong>harm</strong><br>scales by <strong>10%</strong> for each gun in your inventory",
|
description: "when your first gun is equipped<br>reduce <strong>harm</strong> by <strong>10%</strong> for each gun you have",
|
||||||
maxCount: 1,
|
maxCount: 1,
|
||||||
count: 0,
|
count: 0,
|
||||||
allowed() {
|
allowed() {
|
||||||
@@ -377,28 +377,28 @@ const b = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "overcharge",
|
name: "overcharge",
|
||||||
description: "charge <strong class='color-f'>energy</strong> <strong>+33%</strong> beyond your <strong>maximum</strong>",
|
description: "charge <strong class='color-f'>energy</strong> <strong>+50%</strong> beyond your <strong>maximum</strong>",
|
||||||
maxCount: 9,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
allowed() {
|
allowed() {
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
effect() {
|
effect() {
|
||||||
mech.fieldEnergyMax += 0.33
|
mech.fieldEnergyMax += 0.5
|
||||||
mech.fieldMeter += 0.33
|
mech.fieldMeter += 0.5
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "supersaturation",
|
name: "supersaturation",
|
||||||
description: "<strong class='color-h'>heal</strong> <strong>+33%</strong> beyond your <strong>max health</strong>",
|
description: "<strong class='color-h'>heal</strong> <strong>+50%</strong> beyond your <strong>max health</strong>",
|
||||||
maxCount: 9,
|
maxCount: 9,
|
||||||
count: 0,
|
count: 0,
|
||||||
allowed() {
|
allowed() {
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
effect() {
|
effect() {
|
||||||
mech.maxHealth += 0.33
|
mech.maxHealth += 0.50
|
||||||
mech.addHealth(0.33)
|
mech.addHealth(0.50)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
20
js/level.js
20
js/level.js
@@ -19,14 +19,14 @@ const level = {
|
|||||||
// b.giveMod("ground stomp");
|
// b.giveMod("ground stomp");
|
||||||
|
|
||||||
// level.intro(); //starting level
|
// level.intro(); //starting level
|
||||||
level.testingMap();
|
// level.testingMap();
|
||||||
// level.bosses();
|
// level.bosses();
|
||||||
// level.satellite();
|
// level.satellite();
|
||||||
// level.skyscrapers();
|
// level.skyscrapers();
|
||||||
// level.aerie();
|
// level.aerie();
|
||||||
// level.rooftops();
|
// level.rooftops();
|
||||||
// level.warehouse();
|
// level.warehouse();
|
||||||
// level.highrise();
|
level.highrise();
|
||||||
// level.office();
|
// level.office();
|
||||||
} else {
|
} else {
|
||||||
spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
|
spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
|
||||||
@@ -50,7 +50,7 @@ const level = {
|
|||||||
// if (level.isBuildRun) num++
|
// if (level.isBuildRun) num++
|
||||||
for (let i = 0; i < num; i++) {
|
for (let i = 0; i < num; i++) {
|
||||||
game.difficulty++
|
game.difficulty++
|
||||||
game.dmgScale += 0.13; //damage done by mobs increases each level
|
game.dmgScale += 0.135; //damage done by mobs increases each level
|
||||||
b.dmgScale *= 0.93; //damage done by player decreases each level
|
b.dmgScale *= 0.93; //damage done by player decreases each level
|
||||||
game.accelScale *= 1.02 //mob acceleration increases each level
|
game.accelScale *= 1.02 //mob acceleration increases each level
|
||||||
game.lookFreqScale *= 0.98 //mob cycles between looks decreases each level
|
game.lookFreqScale *= 0.98 //mob cycles between looks decreases each level
|
||||||
@@ -61,7 +61,7 @@ const level = {
|
|||||||
difficultyDecrease(num = 1) { //used in easy mode for game.reset()
|
difficultyDecrease(num = 1) { //used in easy mode for game.reset()
|
||||||
for (let i = 0; i < num; i++) {
|
for (let i = 0; i < num; i++) {
|
||||||
game.difficulty--
|
game.difficulty--
|
||||||
game.dmgScale -= 0.13; //damage done by mobs increases each level
|
game.dmgScale -= 0.135; //damage done by mobs increases each level
|
||||||
if (game.dmgScale < 0.1) game.dmgScale = 0.1;
|
if (game.dmgScale < 0.1) game.dmgScale = 0.1;
|
||||||
b.dmgScale /= 0.93; //damage done by player decreases each level
|
b.dmgScale /= 0.93; //damage done by player decreases each level
|
||||||
game.accelScale /= 1.02 //mob acceleration increases each level
|
game.accelScale /= 1.02 //mob acceleration increases each level
|
||||||
@@ -128,6 +128,8 @@ const level = {
|
|||||||
// spawn.bodyRect(-45, -100, 40, 50);
|
// spawn.bodyRect(-45, -100, 40, 50);
|
||||||
// spawn.bomber(800, -450);
|
// spawn.bomber(800, -450);
|
||||||
spawn.cellBoss(400, -750);
|
spawn.cellBoss(400, -750);
|
||||||
|
spawn.cellBoss(400, -750);
|
||||||
|
spawn.cellBoss(400, -750);
|
||||||
|
|
||||||
// spawn.laser(400, -550);
|
// spawn.laser(400, -550);
|
||||||
// spawn.starter(1200, -1050);
|
// spawn.starter(1200, -1050);
|
||||||
@@ -1207,6 +1209,7 @@ const level = {
|
|||||||
spawn.mapRect(-4450, -3075, 450, 25);
|
spawn.mapRect(-4450, -3075, 450, 25);
|
||||||
spawn.mapRect(-4025, -3075, 25, 100);
|
spawn.mapRect(-4025, -3075, 25, 100);
|
||||||
spawn.mapRect(-4275, -2785, 100, 25);
|
spawn.mapRect(-4275, -2785, 100, 25);
|
||||||
|
if (game.difficulty < 4) spawn.bodyRect(-3760, -2400, 50, 50);
|
||||||
|
|
||||||
//mobs
|
//mobs
|
||||||
spawn.randomMob(-2500, -2700, 1);
|
spawn.randomMob(-2500, -2700, 1);
|
||||||
@@ -1233,7 +1236,14 @@ const level = {
|
|||||||
spawn.randomMob(-550, -100, -0.1);
|
spawn.randomMob(-550, -100, -0.1);
|
||||||
spawn.randomBoss(-3250, -2700, 0.2);
|
spawn.randomBoss(-3250, -2700, 0.2);
|
||||||
spawn.randomBoss(-2450, -1100, 0);
|
spawn.randomBoss(-2450, -1100, 0);
|
||||||
if (game.difficulty < 4) spawn.bodyRect(-3760, -2400, 50, 50);
|
if (game.difficulty > 3) {
|
||||||
|
const x = -2000 - Math.floor(1600 * Math.random());
|
||||||
|
const y = -2700 - Math.floor(600 * Math.random());
|
||||||
|
const d = 800;
|
||||||
|
for (let i = 0; i < 5; i++) {
|
||||||
|
spawn.cellBoss(x + Math.floor(d * (Math.random() - 0.5)), y + Math.floor(d * (Math.random() - 0.5)));
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
warehouse() {
|
warehouse() {
|
||||||
level.defaultZoom = 1300
|
level.defaultZoom = 1300
|
||||||
|
|||||||
@@ -727,7 +727,7 @@ const mobs = {
|
|||||||
//accelerate towards the searchTarget
|
//accelerate towards the searchTarget
|
||||||
if (!this.seePlayer.recall) {
|
if (!this.seePlayer.recall) {
|
||||||
const newTarget = function (that) {
|
const newTarget = function (that) {
|
||||||
if (Math.random() < 0.025) {
|
if (Math.random() < 0.0005) {
|
||||||
that.searchTarget = player.position; //chance to target player
|
that.searchTarget = player.position; //chance to target player
|
||||||
} else {
|
} else {
|
||||||
//target random body
|
//target random body
|
||||||
@@ -945,7 +945,7 @@ const mobs = {
|
|||||||
if (b.modHealthDrain && dmg !== Infinity) mech.addHealth(Math.min(this.health, dmg) * b.modHealthDrain)
|
if (b.modHealthDrain && dmg !== Infinity) mech.addHealth(Math.min(this.health, dmg) * b.modHealthDrain)
|
||||||
this.health -= dmg
|
this.health -= dmg
|
||||||
//this.fill = this.color + this.health + ')';
|
//this.fill = this.color + this.health + ')';
|
||||||
this.onDamage(this); //custom damage effects
|
this.onDamage(dmg); //custom damage effects
|
||||||
if (this.health < 0.05) this.death();
|
if (this.health < 0.05) this.death();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -966,7 +966,8 @@ const mobs = {
|
|||||||
if (this.dropPowerUp) {
|
if (this.dropPowerUp) {
|
||||||
powerUps.spawnRandomPowerUp(this.position.x, this.position.y, this.mass, radius);
|
powerUps.spawnRandomPowerUp(this.position.x, this.position.y, this.mass, radius);
|
||||||
if (Math.random() < b.modSpores) {
|
if (Math.random() < b.modSpores) {
|
||||||
for (let i = 0, len = Math.floor(4 + this.mass * Math.random()); i < len; i++) {
|
const len = Math.min(30, Math.floor(4 + this.mass * Math.random()))
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
b.spore(this) //spawn drone
|
b.spore(this) //spawn drone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ const powerUps = {
|
|||||||
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "gun");
|
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "gun");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Math.random() < 0.003 * (11 - b.modCount)) { //a new mod has a low chance for each not acquired mod up to 7
|
if (Math.random() < 0.003 * (12 - b.modCount)) { //a new mod has a low chance for each not acquired mod up to 7
|
||||||
powerUps.spawn(x, y, "mod");
|
powerUps.spawn(x, y, "mod");
|
||||||
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod");
|
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod");
|
||||||
return;
|
return;
|
||||||
@@ -247,25 +247,34 @@ const powerUps = {
|
|||||||
if (mech.fieldMode === 0) {
|
if (mech.fieldMode === 0) {
|
||||||
powerUps.spawn(x, y, "field")
|
powerUps.spawn(x, y, "field")
|
||||||
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field")
|
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field")
|
||||||
} else if (Math.random() < 0.65) {
|
} else if (Math.random() < 0.75) {
|
||||||
powerUps.spawn(x, y, "mod")
|
powerUps.spawn(x, y, "mod")
|
||||||
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod")
|
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod")
|
||||||
} else if (Math.random() < 0.06) {
|
} else if (Math.random() < 0.2) {
|
||||||
powerUps.spawn(x, y, "gun")
|
powerUps.spawn(x, y, "gun")
|
||||||
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "gun")
|
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "gun")
|
||||||
} else if (Math.random() < 0.15) {
|
} else if (Math.random() < 0.6) {
|
||||||
powerUps.spawn(x, y, "field");
|
powerUps.spawn(x, y, "field");
|
||||||
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field");
|
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field");
|
||||||
} else if (mech.health < 0.65) {
|
} else if (mech.health < 0.7) {
|
||||||
powerUps.spawn(x, y, "heal");
|
powerUps.spawn(x, y, "heal");
|
||||||
powerUps.spawn(x, y, "heal");
|
powerUps.spawn(x, y, "heal");
|
||||||
powerUps.spawn(x, y, "heal");
|
powerUps.spawn(x, y, "heal");
|
||||||
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "heal");
|
powerUps.spawn(x, y, "heal");
|
||||||
|
if (Math.random() < b.isModBayesian) {
|
||||||
|
powerUps.spawn(x, y, "heal");
|
||||||
|
powerUps.spawn(x, y, "heal");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
powerUps.spawn(x, y, "ammo");
|
powerUps.spawn(x, y, "ammo");
|
||||||
powerUps.spawn(x, y, "ammo");
|
powerUps.spawn(x, y, "ammo");
|
||||||
powerUps.spawn(x, y, "ammo");
|
powerUps.spawn(x, y, "ammo");
|
||||||
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "ammo");
|
powerUps.spawn(x, y, "ammo");
|
||||||
|
if (Math.random() < b.isModBayesian) {
|
||||||
|
powerUps.spawn(x, y, "ammo");
|
||||||
|
powerUps.spawn(x, y, "ammo");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
chooseRandomPowerUp(x, y) { //100% chance to drop a random power up //used in spawn.debris
|
chooseRandomPowerUp(x, y) { //100% chance to drop a random power up //used in spawn.debris
|
||||||
|
|||||||
213
js/spawn.js
213
js/spawn.js
@@ -127,10 +127,11 @@ const spawn = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
starter(x, y, radius = 30) {
|
starter(x, y, radius = Math.floor(20 + 20 * Math.random())) {
|
||||||
//easy mob for on level 1
|
//easy mob for on level 1
|
||||||
mobs.spawn(x, y, 8, radius, "#9ccdc6");
|
mobs.spawn(x, y, 8, radius, "#9ccdc6");
|
||||||
let me = mob[mob.length - 1];
|
let me = mob[mob.length - 1];
|
||||||
|
// console.log(`mass=${me.mass}, radius = ${radius}`)
|
||||||
me.accelMag = 0.0005 * game.accelScale;
|
me.accelMag = 0.0005 * game.accelScale;
|
||||||
me.memory = 60;
|
me.memory = 60;
|
||||||
me.seeAtDistance2 = 1400000 //1200 vision range
|
me.seeAtDistance2 = 1400000 //1200 vision range
|
||||||
@@ -141,70 +142,146 @@ const spawn = {
|
|||||||
this.attraction();
|
this.attraction();
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
cellBoss(x, y, radius = 30, dropPowerUp = true) {
|
cellBoss(x, y, radius = 20 + 60 * Math.random()) {
|
||||||
//easy mob for on level 1
|
mobs.spawn(x, y, 0, radius, "rgba(0,150,155,0.7)");
|
||||||
|
|
||||||
mobs.spawn(x, y, 8, radius, "rgb(70,170,140)");
|
|
||||||
let me = mob[mob.length - 1];
|
let me = mob[mob.length - 1];
|
||||||
me.isCell = true;
|
me.isCell = true;
|
||||||
me.accelMag = 0.0005 * game.accelScale;
|
me.accelMag = 0.00025 * game.accelScale;
|
||||||
me.memory = 60;
|
me.memory = 60;
|
||||||
me.spawnFrequency = Math.floor(15 + Math.random() * 8)
|
me.frictionAir = 0.012
|
||||||
me.cellRadiusMax = 1000
|
me.seePlayerFreq = Math.floor(5 + 5 * Math.random())
|
||||||
me.cellRadius = 100
|
me.seeAtDistance2 = 9000000;
|
||||||
me.seeAtDistance2 = me.cellRadius * me.cellRadius // vision range
|
me.cellMassMax = 100
|
||||||
// Matter.Body.setDensity(me, 0.0005) // normal density is 0.001 // this reduces life by half and decreases knockback
|
|
||||||
|
|
||||||
//count other cells
|
me.collisionFilter.mask = cat.player | cat.bullet
|
||||||
let count = 0
|
// Matter.Body.setDensity(me, 0.0005) // normal density is 0.001 // this reduces life by half and decreases knockback
|
||||||
|
me.split = function () {
|
||||||
|
Matter.Body.scale(this, 0.5, 0.5);
|
||||||
|
this.radius = Math.sqrt(this.mass * 1100 / Math.PI)
|
||||||
|
spawn.cellBoss(this.position.x, this.position.y, this.radius);
|
||||||
|
}
|
||||||
|
me.onHit = function () { //run this function on hitting player
|
||||||
|
this.split();
|
||||||
|
};
|
||||||
|
me.onDamage = function (dmg) {
|
||||||
|
if (Math.random() * 1.8 < dmg && this.health > dmg) this.split();
|
||||||
|
}
|
||||||
|
me.do = function () {
|
||||||
|
if (!mech.isBodiesAsleep) {
|
||||||
|
this.seePlayerByDistAndLOS();
|
||||||
|
this.attraction();
|
||||||
|
|
||||||
|
if (this.mass < this.cellMassMax) { //grow cell radius
|
||||||
|
const scale = 1 + 0.00015 * this.cellMassMax / this.mass;
|
||||||
|
Matter.Body.scale(this, scale, scale);
|
||||||
|
this.radius = Math.sqrt(this.mass * 1100 / Math.PI)
|
||||||
|
}
|
||||||
|
if (!(game.cycle % this.seePlayerFreq)) { //move away from other mobs
|
||||||
|
const repelRange = 70
|
||||||
|
const attractRange = 600
|
||||||
|
for (let i = 0, len = mob.length; i < len; i++) {
|
||||||
|
if (mob[i].isCell && mob[i].id !== this.id) {
|
||||||
|
const sub = Vector.sub(this.position, mob[i].position)
|
||||||
|
const dist = Vector.magnitude(sub)
|
||||||
|
if (dist < repelRange) {
|
||||||
|
this.force = Vector.mult(Vector.normalise(sub), this.mass * 0.002)
|
||||||
|
} else if (dist > attractRange) {
|
||||||
|
this.force = Vector.mult(Vector.normalise(sub), -this.mass * 0.0015)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if (!(game.cycle % this.seePlayerFreq)) { //move away from other mobs
|
||||||
|
// let q = Matter.Query.point(mob, this.position)
|
||||||
|
// for (let i = 0; i < q.length; i++) {
|
||||||
|
// if (q[i].id !== this.id) {
|
||||||
|
// THRUST = 0.005
|
||||||
|
// this.force = Vector.mult(Vector.normalise(Vector.sub(this.position, q[i].position)), this.mass * THRUST)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
me.onDeath = function () {
|
||||||
|
let count = 0 //count other cells
|
||||||
for (let i = 0, len = mob.length; i < len; i++) {
|
for (let i = 0, len = mob.length; i < len; i++) {
|
||||||
if (mob[i].isCell) count++
|
if (mob[i].isCell) count++
|
||||||
}
|
}
|
||||||
me.growRate = 4 / count //grow proportional to the number of cells alive when born
|
if (count === 1) { //only drop a power up if this is the last cell
|
||||||
|
|
||||||
me.do = function () {
|
|
||||||
//grow cell radius
|
|
||||||
if (this.cellRadius < 700) {
|
|
||||||
this.cellRadius += this.growRate
|
|
||||||
this.seeAtDistance2 = this.cellRadius * this.cellRadius
|
|
||||||
} else {
|
|
||||||
this.seePlayerByDistOrLOS();
|
|
||||||
this.attraction();
|
|
||||||
if (!(game.cycle % this.spawnFrequency) && this.distanceToPlayer() < this.cellRadius) {
|
|
||||||
spawn.cellBoss(this.position.x, this.position.y, 30, false);
|
|
||||||
this.cellRadius = 100
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//draw range
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(this.position.x, this.position.y, this.cellRadius, 0, 2 * Math.PI);
|
|
||||||
ctx.fillStyle = "rgba(70,170,140,0.3)";
|
|
||||||
ctx.fill();
|
|
||||||
|
|
||||||
//spread out away from other cells
|
|
||||||
// for (let i = 0, len = mob.length; i < len; i++) {
|
|
||||||
|
|
||||||
// }
|
|
||||||
};
|
|
||||||
me.onDeath = function () {
|
|
||||||
if (dropPowerUp) {
|
|
||||||
powerUps.spawnBossPowerUp(this.position.x, this.position.y)
|
powerUps.spawnBossPowerUp(this.position.x, this.position.y)
|
||||||
} else {
|
} else {
|
||||||
this.dropPowerUp = false;
|
this.dropPowerUp = false;
|
||||||
}
|
}
|
||||||
//find other cells and have them reset their growth rate
|
|
||||||
let count = 0
|
|
||||||
for (let i = 0, len = mob.length; i < len; i++) {
|
|
||||||
if (mob[i].isCell) count++
|
|
||||||
}
|
|
||||||
const growRate = 4 / count //grow proportional to the number of cells alive when born
|
|
||||||
for (let i = 0, len = mob.length; i < len; i++) {
|
|
||||||
if (mob[i].isCell) mob[i].growRate = growRate
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// cellBoss(x, y, radius = 30) {
|
||||||
|
// mobs.spawn(x, y, 8, radius, "rgb(70,170,140)");
|
||||||
|
// let me = mob[mob.length - 1];
|
||||||
|
// me.isCell = true;
|
||||||
|
// me.accelMag = 0.0003 * game.accelScale;
|
||||||
|
// me.memory = 60;
|
||||||
|
// me.spawnFrequency = Math.floor(15 + Math.random() * 8)
|
||||||
|
// me.cellRadiusMax = 600
|
||||||
|
// me.cellRadius = 100
|
||||||
|
// me.seeAtDistance2 = me.cellRadius * me.cellRadius // vision range
|
||||||
|
// // Matter.Body.setDensity(me, 0.0005) // normal density is 0.001 // this reduces life by half and decreases knockback
|
||||||
|
|
||||||
|
// //count other cells
|
||||||
|
// let count = 0
|
||||||
|
// for (let i = 0, len = mob.length; i < len; i++) {
|
||||||
|
// if (mob[i].isCell) count++
|
||||||
|
// }
|
||||||
|
// me.growRate = 4 / count //grow proportional to the number of cells alive when born
|
||||||
|
|
||||||
|
// me.do = function () {
|
||||||
|
// //grow cell radius
|
||||||
|
// if (this.cellRadius < this.cellRadiusMax) {
|
||||||
|
// this.cellRadius += this.growRate
|
||||||
|
// this.seeAtDistance2 = this.cellRadius * this.cellRadius
|
||||||
|
// }
|
||||||
|
// if (this.cellRadius > this.cellRadiusMax / 2) {
|
||||||
|
// this.seePlayerByDistOrLOS();
|
||||||
|
// this.attraction();
|
||||||
|
// //when near player split and hurt player
|
||||||
|
// if (!(game.cycle % this.spawnFrequency) && this.distanceToPlayer() < this.cellRadius) {
|
||||||
|
// spawn.cellBoss(this.position.x, this.position.y, 30);
|
||||||
|
// this.cellRadius = 100
|
||||||
|
// // let dmg = 0.1 * game.dmgScale; //player damage is capped at 0.3*dmgScale of 1.0
|
||||||
|
// // mech.damage(dmg);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //eat blocks and power ups, gain an increases in radius, and split
|
||||||
|
// //remember what was eaten and release it out on death
|
||||||
|
// }
|
||||||
|
|
||||||
|
// ctx.beginPath(); //draw range
|
||||||
|
// ctx.arc(this.position.x, this.position.y, this.cellRadius, 0, 2 * Math.PI);
|
||||||
|
// ctx.fillStyle = `rgba(70,170,140,${0.7*this.cellRadius/this.cellRadiusMax})`
|
||||||
|
// ctx.fill();
|
||||||
|
|
||||||
|
// //flocking behavior?
|
||||||
|
// // for (let i = 0, len = mob.length; i < len; i++) {
|
||||||
|
|
||||||
|
// // }
|
||||||
|
// };
|
||||||
|
// me.onDeath = function () {
|
||||||
|
// //find other cells and have them reset their growth rate
|
||||||
|
// let count = 0
|
||||||
|
// for (let i = 0, len = mob.length; i < len; i++) {
|
||||||
|
// if (mob[i].isCell) count++
|
||||||
|
// }
|
||||||
|
// const growRate = 4 / count //grow proportional to the number of cells alive when born
|
||||||
|
// for (let i = 0, len = mob.length; i < len; i++) {
|
||||||
|
// if (mob[i].isCell) mob[i].growRate = growRate
|
||||||
|
// }
|
||||||
|
// //only drop a power up if this is the last cell
|
||||||
|
// if (count === 1) {
|
||||||
|
// powerUps.spawnBossPowerUp(this.position.x, this.position.y)
|
||||||
|
// } else {
|
||||||
|
// this.dropPowerUp = false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
|
||||||
// healer(x, y, radius = 20) {
|
// healer(x, y, radius = 20) {
|
||||||
// mobs.spawn(x, y, 3, radius, "rgba(50,255,200,0.4)");
|
// mobs.spawn(x, y, 3, radius, "rgba(50,255,200,0.4)");
|
||||||
@@ -541,31 +618,6 @@ const spawn = {
|
|||||||
toMe(body, this.position, this.eventHorizon)
|
toMe(body, this.position, this.eventHorizon)
|
||||||
toMe(mob, this.position, this.eventHorizon)
|
toMe(mob, this.position, this.eventHorizon)
|
||||||
toMe(bullet, this.position, this.eventHorizon)
|
toMe(bullet, this.position, this.eventHorizon)
|
||||||
|
|
||||||
//push everything away
|
|
||||||
// function push(who, pos, range) {
|
|
||||||
// for (let i = 0, len = who.length; i < len; ++i) {
|
|
||||||
// const SUB = Vector.sub(who[i].position, pos)
|
|
||||||
// const DISTANCE = Vector.magnitude(SUB)
|
|
||||||
// if (DISTANCE < range) {
|
|
||||||
// const depth = range - DISTANCE
|
|
||||||
// const force = Vector.mult(Vector.normalise(SUB), 30 * who[i].mass / depth)
|
|
||||||
// who[i].force.x += force.x;
|
|
||||||
// who[i].force.y += force.y;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// push(body, this.position, this.eventHorizon)
|
|
||||||
// push(mob, this.position, this.eventHorizon)
|
|
||||||
// push(bullet, this.position, this.eventHorizon)
|
|
||||||
// push([player], this.position, this.eventHorizon)
|
|
||||||
// for (let i = 0; i < (game.difficulty - 3); ++i) {
|
|
||||||
// spawn.sucker(this.position.x + (Math.random() - 0.5) * radius * 2, this.position.y + (Math.random() - 0.5) * radius * 2, 70 * Math.random());
|
|
||||||
// Matter.Body.setVelocity(mob[mob.length - 1], {
|
|
||||||
// x: (Math.random() - 0.5) * 70,
|
|
||||||
// y: (Math.random() - 0.5) * 70
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
me.do = function () {
|
me.do = function () {
|
||||||
@@ -613,8 +665,11 @@ const spawn = {
|
|||||||
ctx.fill();
|
ctx.fill();
|
||||||
//when player is inside event horizon
|
//when player is inside event horizon
|
||||||
if (Vector.magnitude(Vector.sub(this.position, player.position)) < eventHorizon && !mech.isStealth) {
|
if (Vector.magnitude(Vector.sub(this.position, player.position)) < eventHorizon && !mech.isStealth) {
|
||||||
mech.damage(0.00015 * game.dmgScale);
|
if (mech.fieldMeter > 0.1) {
|
||||||
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.0045
|
mech.fieldMeter -= 0.0055
|
||||||
|
} else {
|
||||||
|
mech.damage(0.0003 * game.dmgScale);
|
||||||
|
}
|
||||||
const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x);
|
const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x);
|
||||||
player.force.x -= 1.3 * Math.cos(angle) * player.mass * game.g * (mech.onGround ? 1.7 : 1);
|
player.force.x -= 1.3 * Math.cos(angle) * player.mass * game.g * (mech.onGround ? 1.7 : 1);
|
||||||
player.force.y -= 1.2 * Math.sin(angle) * player.mass * game.g;
|
player.force.y -= 1.2 * Math.sin(angle) * player.mass * game.g;
|
||||||
|
|||||||
Reference in New Issue
Block a user