defensive drones
This commit is contained in:
@@ -746,7 +746,7 @@ const b = {
|
|||||||
name: "fléchettes",
|
name: "fléchettes",
|
||||||
description: "fire an accurate high speed needle<br>",
|
description: "fire an accurate high speed needle<br>",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
ammoPack: 14,
|
ammoPack: 16,
|
||||||
have: false,
|
have: false,
|
||||||
fire() {
|
fire() {
|
||||||
const me = bullet.length;
|
const me = bullet.length;
|
||||||
@@ -1157,7 +1157,7 @@ const b = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "drones",
|
name: "hunter drones",
|
||||||
description: "release <span class='color-b'>drones</span> that seek out targets<br>if no targets are found, <span class='color-b'>drones</span> move towards mouse<br>",
|
description: "release <span class='color-b'>drones</span> that seek out targets<br>if no targets are found, <span class='color-b'>drones</span> move towards mouse<br>",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
ammoPack: 20,
|
ammoPack: 20,
|
||||||
@@ -1250,5 +1250,72 @@ const b = {
|
|||||||
b.drawOneBullet(bullet[me].vertices);
|
b.drawOneBullet(bullet[me].vertices);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "defense drones",
|
||||||
|
description: "release <span class='color-b'>drones</span> that defend the space around the player",
|
||||||
|
ammo: 0,
|
||||||
|
ammoPack: 3,
|
||||||
|
have: false,
|
||||||
|
fire() {
|
||||||
|
const THRUST = 0.0015
|
||||||
|
const dir = mech.angle + 0.2 * (Math.random() - 0.5);
|
||||||
|
const me = bullet.length;
|
||||||
|
const RADIUS = (10 + 6 * Math.random()) * b.modBulletSize
|
||||||
|
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS, {
|
||||||
|
angle: dir,
|
||||||
|
inertia: Infinity,
|
||||||
|
friction: 0,
|
||||||
|
frictionAir: 0.001,
|
||||||
|
restitution: 1,
|
||||||
|
dmg: 0.14, //damage done in addition to the damage from momentum
|
||||||
|
lookFrequency: 27 + Math.floor(37 * Math.random()),
|
||||||
|
endCycle: game.cycle + Math.floor((2400 + 1800 * Math.random()) * b.modBulletsLastLonger),
|
||||||
|
classType: "bullet",
|
||||||
|
collisionFilter: {
|
||||||
|
category: 0x000100,
|
||||||
|
mask: 0x000110 //self collide
|
||||||
|
},
|
||||||
|
minDmgSpeed: 0,
|
||||||
|
range: 450 + 150 * Math.random(),
|
||||||
|
lockedOn: null,
|
||||||
|
isFollowMouse: true,
|
||||||
|
onDmg() {
|
||||||
|
this.lockedOn = null
|
||||||
|
},
|
||||||
|
onEnd() {},
|
||||||
|
do() {
|
||||||
|
if (!(game.cycle % this.lookFrequency)) {
|
||||||
|
this.lockedOn = null;
|
||||||
|
let closeDist = Infinity;
|
||||||
|
for (let i = 0, len = mob.length; i < len; ++i) {
|
||||||
|
const TARGET_VECTOR = Matter.Vector.sub(mech.pos, mob[i].position)
|
||||||
|
const DIST = Matter.Vector.magnitude(TARGET_VECTOR);
|
||||||
|
if (DIST < this.range && DIST < closeDist) {
|
||||||
|
closeDist = DIST;
|
||||||
|
this.lockedOn = mob[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const distanceToPlayer = Matter.Vector.magnitude(Matter.Vector.sub(this.position, mech.pos))
|
||||||
|
if (this.lockedOn) { //accelerate towards mobs
|
||||||
|
this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, this.lockedOn.position)), -this.mass * THRUST)
|
||||||
|
} else if (distanceToPlayer > 0.2 * this.range) {
|
||||||
|
this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, mech.pos)), -this.mass * THRUST * 0.5)
|
||||||
|
}
|
||||||
|
|
||||||
|
// speed cap instead of friction to give more agility
|
||||||
|
if (this.speed > 12) {
|
||||||
|
Matter.Body.setVelocity(this, {
|
||||||
|
x: this.velocity.x * 0.97,
|
||||||
|
y: this.velocity.y * 0.97
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
b.fireProps(mech.crouch ? 80 : 60, mech.crouch ? 35 : 10, dir, me); //cd , speed
|
||||||
|
b.drawOneBullet(bullet[me].vertices);
|
||||||
|
}
|
||||||
|
},
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
11
js/level.js
11
js/level.js
@@ -14,12 +14,12 @@ const level = {
|
|||||||
if (game.levelsCleared === 0) {
|
if (game.levelsCleared === 0) {
|
||||||
// game.levelsCleared = 16; //for testing to simulate possible mobs spawns
|
// game.levelsCleared = 16; //for testing to simulate possible mobs spawns
|
||||||
// b.giveGuns("all", 1000)
|
// b.giveGuns("all", 1000)
|
||||||
b.giveGuns(6) // set a starting gun for testing
|
b.giveGuns(13) // set a starting gun for testing
|
||||||
// mech.fieldUpgrades[2].effect(); //give a field power up for testing
|
// mech.fieldUpgrades[2].effect(); //give a field power up for testing
|
||||||
// b.giveMod(7)
|
// b.giveMod(7)
|
||||||
|
|
||||||
this.intro(); //starting level
|
// this.intro(); //starting level
|
||||||
// this.testingMap();
|
this.testingMap();
|
||||||
// this.bosses();
|
// this.bosses();
|
||||||
// this.aerie();
|
// this.aerie();
|
||||||
// this.rooftops();
|
// this.rooftops();
|
||||||
@@ -46,7 +46,6 @@ const level = {
|
|||||||
//******************************************************************************************************************
|
//******************************************************************************************************************
|
||||||
testingMap() {
|
testingMap() {
|
||||||
//start with all guns
|
//start with all guns
|
||||||
b.giveGuns("all", 1000)
|
|
||||||
game.zoomScale = 1400 //1400 is normal
|
game.zoomScale = 1400 //1400 is normal
|
||||||
spawn.setSpawnList();
|
spawn.setSpawnList();
|
||||||
game.levelsCleared = 3; //for testing to simulate all possible mobs spawns
|
game.levelsCleared = 3; //for testing to simulate all possible mobs spawns
|
||||||
@@ -121,8 +120,8 @@ const level = {
|
|||||||
// powerUps.spawn(450, -400, "mod", false);
|
// powerUps.spawn(450, -400, "mod", false);
|
||||||
// spawn.bodyRect(-45, -100, 40, 50);
|
// spawn.bodyRect(-45, -100, 40, 50);
|
||||||
// spawn.focuser(800, -1150);
|
// spawn.focuser(800, -1150);
|
||||||
// spawn.groupBoss(-600, -550);
|
spawn.groupBoss(-600, -550);
|
||||||
spawn.striker(800, -150);
|
// spawn.hopper(800, -150);
|
||||||
// spawn.beamer(800, -150);
|
// spawn.beamer(800, -150);
|
||||||
// spawn.grower(800, -250);
|
// spawn.grower(800, -250);
|
||||||
// spawn.blinker(800, -250, 40);
|
// spawn.blinker(800, -250, 40);
|
||||||
|
|||||||
@@ -750,6 +750,7 @@ const mech = {
|
|||||||
ctx.fillStyle = "rgba(110,170,200," + (0.02 + mech.fieldMeter * (0.15 + 0.15 * Math.random())) + ")";
|
ctx.fillStyle = "rgba(110,170,200," + (0.02 + mech.fieldMeter * (0.15 + 0.15 * Math.random())) + ")";
|
||||||
ctx.strokeStyle = "rgba(110, 200, 235, " + (0.6 + 0.2 * Math.random()) + ")" //"#9bd" //"rgba(110, 200, 235, " + (0.5 + 0.1 * Math.random()) + ")"
|
ctx.strokeStyle = "rgba(110, 200, 235, " + (0.6 + 0.2 * Math.random()) + ")" //"#9bd" //"rgba(110, 200, 235, " + (0.5 + 0.1 * Math.random()) + ")"
|
||||||
}
|
}
|
||||||
|
// const off = 2 * Math.cos(game.cycle * 0.1)
|
||||||
const range = this.grabRange - 20;
|
const range = this.grabRange - 20;
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(mech.pos.x, mech.pos.y, range, mech.angle - Math.PI * mech.fieldArc, mech.angle + Math.PI * mech.fieldArc, false);
|
ctx.arc(mech.pos.x, mech.pos.y, range, mech.angle - Math.PI * mech.fieldArc, mech.angle + Math.PI * mech.fieldArc, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user