drone and spores bullet adjustments

This commit is contained in:
landgreen
2019-09-08 08:23:50 -07:00
parent 1d480d8243
commit 946484f9a1
3 changed files with 110 additions and 48 deletions

View File

@@ -111,7 +111,7 @@
</tr> --> </tr> -->
</table> </table>
<br> <br>
<a href="https://github.com/landgreen/landgreen.github.io/tree/master/sidescroller"> <a href="https://github.com/landgreen/n-gon">
<svg viewBox="0 0 100 16" xmlns="http://www.w3.org/2000/svg" fill="#1B1F23"> <svg viewBox="0 0 100 16" xmlns="http://www.w3.org/2000/svg" fill="#1B1F23">
<path d="M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z" /> <path d="M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z" />
<g stroke='none' font-size="8px" font-family="Arial Black, sans-serif"> <g stroke='none' font-size="8px" font-family="Arial Black, sans-serif">

View File

@@ -719,35 +719,29 @@ const b = {
} }
}, },
{ {
name: "swarm", name: "spores",
ammo: 0, ammo: 0,
ammoPack: 7, ammoPack: 6,
have: false, have: false,
fire() { fire() {
const me = bullet.length; const me = bullet.length;
const dir = mech.angle; const dir = mech.angle;
bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 20, 4.5, b.fireAttributes(dir)); bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 20, 4.5, b.fireAttributes(dir));
b.fireProps(40, 15, dir, me); //cd , speed b.fireProps(25, 20, dir, me); //cd , speed
b.drawOneBullet(bullet[me].vertices); b.drawOneBullet(bullet[me].vertices);
Matter.Body.setDensity(bullet[me], 0.000001); Matter.Body.setDensity(bullet[me], 0.000001);
bullet[me].endCycle = game.cycle + 250; bullet[me].endCycle = game.cycle + 100;
bullet[me].frictionAir = 0.001; bullet[me].frictionAir = 0;
bullet[me].friction = 0.5; bullet[me].friction = 0.5;
bullet[me].restitution = 0.3; bullet[me].restitution = 0.3;
// Matter.Body.setDensity(bullet[me], 0.000001);
// bullet[me].friction = 0.15;
// bullet[me].restitution = 0;
// bullet[me].explodeRad = 350 + Math.floor(Math.random() * 60);
bullet[me].minDmgSpeed = 0; bullet[me].minDmgSpeed = 0;
bullet[me].onDmg = function () { bullet[me].onDmg = function () {};
// this.endCycle = 0; //bullet ends cycle after doing damage //this triggers explosion
};
bullet[me].do = function () { bullet[me].do = function () {
const SCALE = 1.007 const SCALE = 1.017
Matter.Body.scale(this, SCALE, SCALE); Matter.Body.scale(this, SCALE, SCALE);
this.frictionAir += 0.00021;
this.force.y += this.mass * 0.0005; this.force.y += this.mass * 0.00045;
}; };
//spawn bullets on end //spawn bullets on end
@@ -755,26 +749,26 @@ const b = {
const NUM = 11; const NUM = 11;
for (let i = 0; i < NUM; i++) { for (let i = 0; i < NUM; i++) {
const bIndex = bullet.length; const bIndex = bullet.length;
const RADIUS = 5 + 2 * (Math.random() - 0.5) const RADIUS = 4 + 2 * Math.random();
bullet[bIndex] = Bodies.circle(this.position.x, this.position.y, RADIUS, { bullet[bIndex] = Bodies.circle(this.position.x, this.position.y, RADIUS, {
// density: 0.0015, //frictionAir: 0.01, // density: 0.0015, //frictionAir: 0.01,
restitution: 1, restitution: 0.9,
angle: dir, angle: dir,
friction: 0, friction: 0,
frictionAir: 0.01, frictionAir: 0.01,
dmg: 1.25, //damage done in addition to the damage from momentum dmg: 1.3, //damage done in addition to the damage from momentum
classType: "bullet", classType: "bullet",
collisionFilter: { collisionFilter: {
category: 0x000100, category: 0x000100,
mask: 0x000011 //mask: 0x000101, //for self collision mask: 0x000011 //mask: 0x000101, //for self collision
}, },
endCycle: game.cycle + 300 + Math.floor(Math.random() * 120), endCycle: game.cycle + 300 + Math.floor(Math.random() * 240),
minDmgSpeed: 0, minDmgSpeed: 0,
onDmg() { onDmg() {
this.endCycle = 0; //bullet ends cycle after doing damage this.endCycle = 0; //bullet ends cycle after doing damage
}, },
onEnd() {}, onEnd() {},
lookFrequency: 27 + Math.floor(17 * Math.random()), lookFrequency: 57 + Math.floor(37 * Math.random()),
do() { do() {
this.force.y += this.mass * 0.00025; // high gravity because of the high friction this.force.y += this.mass * 0.00025; // high gravity because of the high friction
@@ -809,9 +803,6 @@ const b = {
} }
}, },
}); });
// bullet[bIndex].explodeRad = 100 + Math.floor(Math.random() * 30);
// bullet[bIndex].onEnd = b.explode; //makes bullet do explosive damage before despawn
const SPEED = 9; const SPEED = 9;
const ANGLE = 2 * Math.PI * Math.random() const ANGLE = 2 * Math.PI * Math.random()
Matter.Body.setVelocity(bullet[bIndex], { Matter.Body.setVelocity(bullet[bIndex], {
@@ -827,22 +818,22 @@ const b = {
{ {
name: "drones", name: "drones",
ammo: 0, ammo: 0,
ammoPack: 27, ammoPack: 23,
have: false, have: false,
fire() { fire() {
const MAX_SPEED = 6 //+ 2 * (Math.random() - 0.5) const MAX_SPEED = 6
const THRUST = 0.0015 //+ 0.0004 * (Math.random() - 0.5) const THRUST = 0.0015
const dir = mech.angle + 0.7 * (Math.random() - 0.5); const dir = mech.angle + 0.7 * (Math.random() - 0.5);
const me = bullet.length; const me = bullet.length;
const RADIUS = 6 + 2.5 * (Math.random() - 0.5) const RADIUS = 4 + 4 * Math.random()
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS, { bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS, {
angle: dir, angle: dir,
friction: 0, friction: 0,
frictionAir: 0.0005, frictionAir: 0.0005,
restitution: 1, restitution: 1,
dmg: 0.15, //damage done in addition to the damage from momentum dmg: 0.18, //damage done in addition to the damage from momentum
lookFrequency: 67 + Math.floor(23 * Math.random()), lookFrequency: 79 + Math.floor(32 * Math.random()),
endCycle: game.cycle + 540 + 120 * Math.random(), endCycle: game.cycle + 720 + 300 * Math.random(),
classType: "bullet", classType: "bullet",
collisionFilter: { collisionFilter: {
category: 0x000100, category: 0x000100,
@@ -850,6 +841,7 @@ const b = {
}, },
minDmgSpeed: 0, minDmgSpeed: 0,
lockedOn: null, lockedOn: null,
isFollowMouse: true,
onDmg() { onDmg() {
this.lockedOn = null this.lockedOn = null
}, //this.endCycle = 0 //triggers despawn }, //this.endCycle = 0 //triggers despawn
@@ -861,6 +853,7 @@ const b = {
if (!(game.cycle % this.lookFrequency)) { if (!(game.cycle % this.lookFrequency)) {
this.close = null; this.close = null;
this.lockedOn = null; this.lockedOn = null;
this.isFollowMouse = true; //if no target is found default to follow mouse
let closeDist = Infinity; let closeDist = Infinity;
for (let i = 0, len = mob.length; i < len; ++i) { for (let i = 0, len = mob.length; i < len; ++i) {
if ( if (
@@ -875,14 +868,16 @@ const b = {
this.close = mob[i].position; this.close = mob[i].position;
closeDist = DIST; closeDist = DIST;
this.lockedOn = mob[i] this.lockedOn = mob[i]
this.isFollowMouse = false;
} }
} }
} }
} }
//accelerate towards mobs if (this.lockedOn) { //accelerate towards mobs
if (this.lockedOn) { this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, this.lockedOn.position)), -this.mass * THRUST)
const UNIT_VECTOR = Matter.Vector.normalise(Matter.Vector.sub(this.position, this.lockedOn.position)) } else if (this.isFollowMouse) { //accelerate towards mouse
this.force = Matter.Vector.mult(UNIT_VECTOR, -this.mass * THRUST) this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, game.mouseInGame)), -this.mass * THRUST)
}
// speed cap instead of friction to give more agility // speed cap instead of friction to give more agility
if (this.speed > MAX_SPEED) { if (this.speed > MAX_SPEED) {
@@ -892,10 +887,9 @@ const b = {
}); });
} }
} }
}
}) })
// b.fireAttributes(dir)); // b.fireAttributes(dir));
b.fireProps(4, MAX_SPEED, dir, me); //cd , speed b.fireProps(10, MAX_SPEED, dir, me); //cd , speed
b.drawOneBullet(bullet[me].vertices); b.drawOneBullet(bullet[me].vertices);
// Matter.Body.setDensity(bullet[me], 0.000001); // Matter.Body.setDensity(bullet[me], 0.000001);
// bullet[me].onDmg = function () { // bullet[me].onDmg = function () {
@@ -903,6 +897,74 @@ const b = {
// }; // };
} }
}, },
// {
// name: "flock", // shards
// ammo: 0,
// ammoPack: 1027,
// have: false,
// fire() {
// const me = bullet.length;
// const dir = mech.angle + 0.7 * (Math.random() - 0.5);
// const RADIUS = 6 + 2.5 * (Math.random() - 0.5)
// // bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(mech.angle), mech.pos.y + 40 * Math.sin(mech.angle), 31, 2, b.fireAttributes(dir));
// // bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS, {
// bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(mech.angle), mech.pos.y + 40 * Math.sin(mech.angle), 31, 2, {
// angle: dir,
// friction: 0,
// frictionAir: 0.02,
// restitution: 0.2,
// dmg: 0.15, //damage done in addition to the damage from momentum
// lookFrequency: 67 + Math.floor(23 * Math.random()),
// endCycle: game.cycle + 540 + 120 * Math.random(),
// classType: "bullet",
// collisionFilter: {
// category: 0x000100,
// mask: 0x000111
// },
// minDmgSpeed: 0,
// onDmg() {
// this.endCycle = 0 //triggers despawn
// // this.explodeRad = this.speed * 10
// },
// // explodeRad: 10,
// // onEnd: b.explode,
// onEnd() {},
// do() {
// // drain ammo
// // if (!(game.cycle % this.lookFrequency)) {
// // if (b.guns[b.activeGun].ammo > 0) {
// // b.guns[b.activeGun].ammo--;
// // game.updateGunHUD();
// // }
// // }
// this.force.y += this.mass * 0.0002; //gravity
// //accelerate towards mouse
// const THRUST = 0.0015
// const UNIT_VECTOR = Matter.Vector.normalise(Matter.Vector.sub(this.position, game.mouseInGame))
// this.force = Matter.Vector.mult(UNIT_VECTOR, -this.mass * THRUST)
// // speed cap
// if (this.speed > 16) {
// Matter.Body.setVelocity(this, {
// x: this.velocity.x * 0.97,
// y: this.velocity.y * 0.97
// });
// }
// }
// })
// // bullet[me].onEnd = b.explode; //makes bullet do explosive damage before despawn
// // b.fireAttributes(dir));
// b.fireProps(4, 4, dir, me); //cd , speed
// b.drawOneBullet(bullet[me].vertices);
// // Matter.Body.setDensity(bullet[me], 0.000001);
// // bullet[me].onDmg = function () {
// // this.endCycle = 0; //bullet ends cycle after doing damage
// // };
// }
// },
{ {
name: "wave beam", name: "wave beam",
ammo: 0, ammo: 0,

View File

@@ -13,7 +13,7 @@ const level = {
// game.zoomScale = 1400 //1400 // game.zoomScale = 1400 //1400
if (game.levelsCleared === 0) { if (game.levelsCleared === 0) {
this.intro(); //starting level this.intro(); //starting level
// b.giveGuns(11) // set a starting gun for testing // b.giveGuns(10) // set a starting gun for testing
// game.levelsCleared = 3; //for testing to simulate all possible mobs spawns // game.levelsCleared = 3; //for testing to simulate all possible mobs spawns
// this.bosses(); // this.bosses();
// this.testingMap(); // this.testingMap();
@@ -1385,11 +1385,11 @@ const level = {
} }
}, },
levelAnnounce() { levelAnnounce() {
let text = "L" + (game.levelsCleared) + " " + level.levels[level.onLevel]; let text = (game.levelsCleared) + " " + level.levels[level.onLevel];
if (game.levelsCleared === 0) text = ""; document.title = "n-gon: L" + text;
game.makeTextLog("level " + text, 300);
// if (game.levelsCleared === 0) text = "";
// text = "Level " + (game.levelsCleared + 1) + ": " + spawn.pickList[0] + "s + " + spawn.pickList[1] + "s"; // text = "Level " + (game.levelsCleared + 1) + ": " + spawn.pickList[0] + "s + " + spawn.pickList[1] + "s";
game.makeTextLog(text, 300);
document.title = "n-gon: " + text;
// text = text + " with population: "; // text = text + " with population: ";
// for (let i = 0, len = spawn.pickList.length; i < len; ++i) { // for (let i = 0, len = spawn.pickList.length; i < len; ++i) {