setting up status effecs on mobs
This commit is contained in:
@@ -2062,6 +2062,19 @@ const b = {
|
||||
bullet[me].endCycle = game.cycle + 70;
|
||||
bullet[me].dmg = 0.07;
|
||||
bullet[me].frictionAir = mech.crouch ? 0.007 : 0.01;
|
||||
bullet[me].onDmg = function (who) {
|
||||
|
||||
who.status.push({ //slow
|
||||
endCycle: game.cycle + 60,
|
||||
effect() {
|
||||
|
||||
Matter.Body.setVelocity(who, {
|
||||
x: who.velocity.x * 0.8,
|
||||
y: who.velocity.y * 0.8
|
||||
});
|
||||
},
|
||||
})
|
||||
};
|
||||
bullet[me].do = function () {
|
||||
this.force.y += this.mass * 0.0005;
|
||||
};
|
||||
|
||||
10
js/level.js
10
js/level.js
@@ -14,13 +14,13 @@ const level = {
|
||||
start() {
|
||||
if (level.levelsCleared === 0) {
|
||||
// level.difficultyIncrease(9)
|
||||
// b.giveGuns("wave beam")
|
||||
b.giveGuns("minigun")
|
||||
// mech.setField("phase decoherence field")
|
||||
// b.giveMod("quantum dissipation");
|
||||
// b.giveMod("reflective cavity");
|
||||
|
||||
level.intro(); //starting level
|
||||
// level.testingMap();
|
||||
// level.intro(); //starting level
|
||||
level.testingMap();
|
||||
// level.bosses();
|
||||
// level.satellite();
|
||||
// level.skyscrapers();
|
||||
@@ -140,8 +140,8 @@ const level = {
|
||||
// powerUps.spawn(450, -400, "mod", false, 6);
|
||||
// powerUps.spawn(450, -400, "mod", false);
|
||||
// spawn.bodyRect(-45, -100, 40, 50);
|
||||
spawn.springer(800, -450);
|
||||
spawn.cellBoss(400, -750);
|
||||
spawn.starter(800, -450);
|
||||
// spawn.cellBoss(400, -750);
|
||||
|
||||
// spawn.randomLevelBoss(400, -750)
|
||||
|
||||
|
||||
13
js/mobs.js
13
js/mobs.js
@@ -7,6 +7,11 @@ const mobs = {
|
||||
while (i--) {
|
||||
if (mob[i].alive) {
|
||||
mob[i].do();
|
||||
// let j = mob[i].status.length;
|
||||
// while (j--) {
|
||||
// mob[i].status[j].effect();
|
||||
// if (mob[i].status[j].endCycle > game.cycle) mob[i].status.splice(j, 0);
|
||||
// }
|
||||
} else {
|
||||
mob[i].replace(i); //removing mob and replace with body, this is done here to avoid an array index bug with drawing I think
|
||||
}
|
||||
@@ -97,6 +102,14 @@ const mobs = {
|
||||
x: xPos,
|
||||
y: yPos
|
||||
},
|
||||
status: [], // [ { effect(), endCycle } ]
|
||||
checkStatus() {
|
||||
let j = this.status.length;
|
||||
while (j--) {
|
||||
this.status[j].effect();
|
||||
if (this.status[j].endCycle < game.cycle) this.status.splice(j, 1);
|
||||
}
|
||||
},
|
||||
seeAtDistance2: 4000000, //sqrt(4000000) = 2000 = max seeing range
|
||||
distanceToPlayer() {
|
||||
const dx = this.position.x - player.position.x;
|
||||
|
||||
@@ -142,6 +142,7 @@ const spawn = {
|
||||
Matter.Body.setDensity(me, 0.0005) // normal density is 0.001 // this reduces life by half and decreases knockback
|
||||
|
||||
me.do = function () {
|
||||
this.checkStatus()
|
||||
this.seePlayerByLookingAt();
|
||||
this.attraction();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user