replace slugs with rail gun, rebalanced flechettes, added falling dmg, new mod: fast movement, added mouse icons
This commit is contained in:
401
js/bullets.js
401
js/bullets.js
@@ -11,30 +11,32 @@ const b = {
|
|||||||
modEnergySiphon: null,
|
modEnergySiphon: null,
|
||||||
modHealthDrain: null,
|
modHealthDrain: null,
|
||||||
modNoAmmo: null,
|
modNoAmmo: null,
|
||||||
modBulletsLastLonger: null,
|
isModBulletsLastLonger: null,
|
||||||
modIsImmortal: null,
|
modIsImmortal: null,
|
||||||
modSpores: null,
|
modSpores: null,
|
||||||
AoEImmunity: null,
|
isModAoEImmunity: null,
|
||||||
makeDroneOnDamage: null,
|
isModDroneOnDamage: null,
|
||||||
extraDmg: null,
|
modExtraDmg: null,
|
||||||
annihilation: null,
|
annihilation: null,
|
||||||
fullHeal: null,
|
fullHeal: null,
|
||||||
setModDefaults() {
|
setModDefaults() {
|
||||||
b.modCount = 0;
|
b.modCount = 0;
|
||||||
b.modFireRate = 1;
|
b.modFireRate = 1;
|
||||||
b.modExplosionRadius = 1;
|
b.modExplosionRadius = 1;
|
||||||
b.AoEImmunity = false;
|
b.isModAoEImmunity = false;
|
||||||
b.modBulletSize = 1;
|
b.modBulletSize = 1;
|
||||||
b.makeDroneOnDamage = false;
|
b.isModDroneOnDamage = false;
|
||||||
b.modEnergySiphon = 0;
|
b.modEnergySiphon = 0;
|
||||||
b.modHealthDrain = 0;
|
b.modHealthDrain = 0;
|
||||||
b.modNoAmmo = 0;
|
b.modNoAmmo = 0;
|
||||||
b.modBulletsLastLonger = 1;
|
b.isModBulletsLastLonger = 1;
|
||||||
b.modIsImmortal = false;
|
b.modIsImmortal = false;
|
||||||
b.modSpores = 0;
|
b.modSpores = 0;
|
||||||
b.extraDmg = 0;
|
b.modExtraDmg = 0;
|
||||||
b.annihilation = false;
|
b.modAnnihilation = false;
|
||||||
b.fullHeal = false;
|
b.isModFullHeal = false;
|
||||||
|
mech.Fx = 0.015;
|
||||||
|
mech.jumpForce = 0.38;
|
||||||
mech.throwChargeRate = 2;
|
mech.throwChargeRate = 2;
|
||||||
mech.throwChargeMax = 50;
|
mech.throwChargeMax = 50;
|
||||||
for (let i = 0; i < b.mods.length; i++) {
|
for (let i = 0; i < b.mods.length; i++) {
|
||||||
@@ -72,7 +74,7 @@ const b = {
|
|||||||
description: "your <strong class='color-b'>bullets</strong> last 40% longer",
|
description: "your <strong class='color-b'>bullets</strong> last 40% longer",
|
||||||
have: false, //3
|
have: false, //3
|
||||||
effect: () => { //good with: drones, super balls, spore, missiles, wave beam(range), rapid fire(range), flak(range)
|
effect: () => { //good with: drones, super balls, spore, missiles, wave beam(range), rapid fire(range), flak(range)
|
||||||
b.modBulletsLastLonger = 1.40
|
b.isModBulletsLastLonger = 1.40
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -89,7 +91,7 @@ const b = {
|
|||||||
description: "you take no damage from area effects<br>immune to <strong class='color-e'>explosions</strong> and enemy fields",
|
description: "you take no damage from area effects<br>immune to <strong class='color-e'>explosions</strong> and enemy fields",
|
||||||
have: false, //5
|
have: false, //5
|
||||||
effect: () => {
|
effect: () => {
|
||||||
b.AoEImmunity = true; //good for guns with explosions
|
b.isModAoEImmunity = true; //good for guns with explosions
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -97,7 +99,7 @@ const b = {
|
|||||||
description: "after taking <span class='color-d'>damage</span>, there is a chance that your damaged parts will be rebuilt as <strong class='color-b'>drones</strong>",
|
description: "after taking <span class='color-d'>damage</span>, there is a chance that your damaged parts will be rebuilt as <strong class='color-b'>drones</strong>",
|
||||||
have: false, //6
|
have: false, //6
|
||||||
effect: () => { //makes dangerous situations more survivable
|
effect: () => { //makes dangerous situations more survivable
|
||||||
b.makeDroneOnDamage = true;
|
b.isModDroneOnDamage = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -138,7 +140,7 @@ const b = {
|
|||||||
description: "your bullets do extra chemical <span class='color-d'>damage</span> each time they make contact",
|
description: "your bullets do extra chemical <span class='color-d'>damage</span> each time they make contact",
|
||||||
have: false, //11
|
have: false, //11
|
||||||
effect: () => { //good with guns that fire many bullets at low speeds, minigun, drones, junk-bots, shotgun, superballs, wavebeam
|
effect: () => { //good with guns that fire many bullets at low speeds, minigun, drones, junk-bots, shotgun, superballs, wavebeam
|
||||||
b.extraDmg = 0.1
|
b.modExtraDmg = 0.1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -146,7 +148,7 @@ const b = {
|
|||||||
description: "after you touch any enemy, they are <strong class='color-l'>annihilated</strong><br><em>touching enemies damages you, but destroys them</em>",
|
description: "after you touch any enemy, they are <strong class='color-l'>annihilated</strong><br><em>touching enemies damages you, but destroys them</em>",
|
||||||
have: false, //12
|
have: false, //12
|
||||||
effect: () => { //good with mods that heal: superconductive healing, entropy transfer
|
effect: () => { //good with mods that heal: superconductive healing, entropy transfer
|
||||||
b.annihilation = true
|
b.modAnnihilation = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -154,19 +156,30 @@ const b = {
|
|||||||
description: "<span class='color-h'>heals</span> bring you to full health",
|
description: "<span class='color-h'>heals</span> bring you to full health",
|
||||||
have: false, //13
|
have: false, //13
|
||||||
effect: () => { // good with ablative synthesis, electrostatic field
|
effect: () => { // good with ablative synthesis, electrostatic field
|
||||||
b.fullHeal = true
|
b.isModFullHeal = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "superconductive rail gun",
|
name: "Gauss rifle",
|
||||||
description: "throw blocks at very high speeds<br><em>to charge a throw, hold right click while holding a block<br>release right click to fire</em>",
|
description: "<span style='color:#f0f;'>magnetically</span> <strong>launch blocks</strong> at much higher speeds<br>carry more massive blocks<br><em>hold right click to charge up a throw and release to fire</em>",
|
||||||
have: false, //14
|
have: false, //14
|
||||||
effect: () => { // good with ablative synthesis, electrostatic field
|
effect: () => { // good with ablative synthesis, electrostatic field
|
||||||
b.fullHeal = true
|
b.isModFullHeal = true
|
||||||
mech.throwChargeRate = 4;
|
mech.throwChargeRate = 4;
|
||||||
mech.throwChargeMax = 150;
|
mech.throwChargeMax = 150;
|
||||||
|
mech.holdingMassScale = 0.05; //can hold heavier blocks with lower cost to jumping
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "squirrel-cage rotor",
|
||||||
|
description: "jump higher and move faster",
|
||||||
|
have: false, //15
|
||||||
|
effect: () => { //
|
||||||
|
mech.Fx = 0.015 * 1.2;
|
||||||
|
mech.jumpForce = 0.38 * 1.1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
],
|
],
|
||||||
giveMod(i) {
|
giveMod(i) {
|
||||||
b.mods[i].effect(); //give specific mod
|
b.mods[i].effect(); //give specific mod
|
||||||
@@ -263,7 +276,7 @@ const b = {
|
|||||||
angle: dir,
|
angle: dir,
|
||||||
friction: 0.5,
|
friction: 0.5,
|
||||||
frictionAir: 0,
|
frictionAir: 0,
|
||||||
dmg: b.extraDmg, //damage done in addition to the damage from momentum
|
dmg: b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||||
classType: "bullet",
|
classType: "bullet",
|
||||||
collisionFilter: {
|
collisionFilter: {
|
||||||
category: 0x000100,
|
category: 0x000100,
|
||||||
@@ -351,7 +364,7 @@ const b = {
|
|||||||
sub = Matter.Vector.sub(bullet[me].position, player.position);
|
sub = Matter.Vector.sub(bullet[me].position, player.position);
|
||||||
dist = Matter.Vector.magnitude(sub);
|
dist = Matter.Vector.magnitude(sub);
|
||||||
if (dist < radius) {
|
if (dist < radius) {
|
||||||
if (!b.AoEImmunity) mech.damage(radius * 0.0002);
|
if (!b.isModAoEImmunity) mech.damage(radius * 0.0002);
|
||||||
knock = Matter.Vector.mult(Matter.Vector.normalise(sub), -Math.sqrt(dmg) * player.mass / 30);
|
knock = Matter.Vector.mult(Matter.Vector.normalise(sub), -Math.sqrt(dmg) * player.mass / 30);
|
||||||
player.force.x += knock.x;
|
player.force.x += knock.x;
|
||||||
player.force.y += knock.y;
|
player.force.y += knock.y;
|
||||||
@@ -433,7 +446,7 @@ const b = {
|
|||||||
category: 0x000100,
|
category: 0x000100,
|
||||||
mask: 0x000011 //no collide with body
|
mask: 0x000011 //no collide with body
|
||||||
},
|
},
|
||||||
endCycle: game.cycle + Math.floor((360 + Math.floor(Math.random() * 240)) * b.modBulletsLastLonger),
|
endCycle: game.cycle + Math.floor((360 + Math.floor(Math.random() * 240)) * b.isModBulletsLastLonger),
|
||||||
minDmgSpeed: 0,
|
minDmgSpeed: 0,
|
||||||
onDmg() {
|
onDmg() {
|
||||||
this.endCycle = 0; //bullet ends cycle after doing damage
|
this.endCycle = 0; //bullet ends cycle after doing damage
|
||||||
@@ -640,31 +653,239 @@ const b = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
name: "kinetic slugs", //1
|
name: "rail gun", //15
|
||||||
description: "fire a large <strong>rod</strong> that does excessive physical <span class='color-d'>damage</span><br><em>high recoil</em>",
|
description: "<strong>hold left mouse</strong> to charge and release to fire<br>charging repels enemies and drains <span class='color-f'>field energy</span><br><em><strong>crouching</strong> improves charging and reduces recoil</em>",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
ammoPack: 5,
|
ammoPack: 9,
|
||||||
have: false,
|
have: false,
|
||||||
isStarterGun: true,
|
isStarterGun: false,
|
||||||
fire() {
|
fire() {
|
||||||
b.muzzleFlash(45);
|
|
||||||
// mobs.alert(800);
|
|
||||||
const me = bullet.length;
|
const me = bullet.length;
|
||||||
const dir = mech.angle;
|
bullet[me] = Bodies.rectangle(9, -90, 0.01 * b.modBulletSize, 0.0015 * b.modBulletSize, {
|
||||||
bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), 70 * b.modBulletSize, 30 * b.modBulletSize, b.fireAttributes(dir));
|
// density: 0.0015, //frictionAir: 0.01, //restitution: 0,
|
||||||
b.fireProps(mech.crouch ? 55 : 40, 50, dir, me); //cd , speed
|
angle: 0,
|
||||||
bullet[me].endCycle = game.cycle + Math.floor(180 * b.modBulletsLastLonger);
|
friction: 0.5,
|
||||||
|
frictionAir: 0,
|
||||||
|
dmg: 3 + b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||||
|
classType: "bullet",
|
||||||
|
collisionFilter: {
|
||||||
|
category: 0x000000,
|
||||||
|
mask: 0x010011 //mask: 0x000101, //for self collision
|
||||||
|
},
|
||||||
|
minDmgSpeed: 5,
|
||||||
|
onDmg() {}, //this.endCycle = 0 //triggers despawn
|
||||||
|
onEnd() {}
|
||||||
|
});
|
||||||
|
mech.fireCDcycle = Infinity; // cool down
|
||||||
|
World.add(engine.world, bullet[me]); //add bullet to world
|
||||||
|
bullet[me].endCycle = Infinity
|
||||||
|
bullet[me].isCharging = true;
|
||||||
|
bullet[me].charge = 0;
|
||||||
bullet[me].do = function () {
|
bullet[me].do = function () {
|
||||||
this.force.y += this.mass * 0.0005;
|
if (this.isCharging) {
|
||||||
};
|
const DRAIN = 0.0001 + mech.fieldRegen
|
||||||
|
if ((!game.mouseDown && this.charge > 0.5) || mech.fieldMeter < DRAIN) { //fire on mouse release
|
||||||
|
this.isCharging = false
|
||||||
|
if (mech.fieldMeter < DRAIN) {
|
||||||
|
mech.fireCDcycle = mech.cycle + 120; // long CD if out of mana
|
||||||
|
} else {
|
||||||
|
mech.fireCDcycle = mech.cycle + 2; // set fire cool down
|
||||||
|
}
|
||||||
|
Matter.Body.scale(this, 10000, 10000) // un hide the bullet by scaling it up (don't judge me... I know this is a bad way to do it)
|
||||||
|
this.endCycle = game.cycle + Math.floor(140 * b.isModBulletsLastLonger)
|
||||||
|
this.collisionFilter.category = 0x000100
|
||||||
|
Matter.Body.setPosition(this, {
|
||||||
|
x: mech.pos.x,
|
||||||
|
y: mech.pos.y
|
||||||
|
})
|
||||||
|
Matter.Body.setAngle(this, mech.angle)
|
||||||
|
const speed = 80
|
||||||
|
Matter.Body.setVelocity(this, {
|
||||||
|
x: mech.Vx / 2 + speed * this.charge * Math.cos(mech.angle),
|
||||||
|
y: mech.Vy / 2 + speed * this.charge * Math.sin(mech.angle)
|
||||||
|
});
|
||||||
|
|
||||||
//knock back
|
//knock back
|
||||||
const KNOCK = ((mech.crouch) ? 0.025 : 0.25) * b.modBulletSize * b.modBulletSize
|
const KNOCK = ((mech.crouch) ? 0.1 : 0.7) * b.modBulletSize * b.modBulletSize * this.charge * this.charge
|
||||||
player.force.x -= KNOCK * Math.cos(dir)
|
player.force.x -= KNOCK * Math.cos(mech.angle)
|
||||||
player.force.y -= KNOCK * Math.sin(dir) * 0.4 //reduce knock back in vertical direction to stop super jumps
|
player.force.y -= KNOCK * Math.sin(mech.angle) * 0.3 //reduce knock back in vertical direction to stop super jumps
|
||||||
|
|
||||||
|
//push away blocks on fire
|
||||||
|
const RANGE = 450 * this.charge
|
||||||
|
for (let i = 0, len = body.length; i < len; ++i) {
|
||||||
|
const SUB = Matter.Vector.sub(body[i].position, mech.pos)
|
||||||
|
const DISTANCE = Matter.Vector.magnitude(SUB)
|
||||||
|
if (DISTANCE < RANGE) {
|
||||||
|
const DEPTH = RANGE - DISTANCE
|
||||||
|
const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.005 * Math.sqrt(DEPTH) * Math.sqrt(body[i].mass))
|
||||||
|
body[i].force.x += FORCE.x
|
||||||
|
body[i].force.y += FORCE.y - body[i].mass * (game.g * 25); //kick up a bit to give them some arc
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
} else { // charging on mouse down
|
||||||
|
mech.fieldMeter -= DRAIN;
|
||||||
|
mech.fireCDcycle = Infinity //can't fire until mouse is released
|
||||||
|
if (mech.crouch) {
|
||||||
|
this.charge = this.charge * 0.97 + 0.03 // this.charge converges to 1
|
||||||
|
} else {
|
||||||
|
this.charge = this.charge * 0.99 + 0.01 // this.charge converges to 1
|
||||||
|
}
|
||||||
|
|
||||||
|
//gently push away mobs while charging
|
||||||
|
const RANGE = 300 * this.charge
|
||||||
|
for (let i = 0, len = mob.length; i < len; ++i) {
|
||||||
|
const SUB = Matter.Vector.sub(mob[i].position, mech.pos)
|
||||||
|
const DISTANCE = Matter.Vector.magnitude(SUB)
|
||||||
|
// if (DISTANCE < RANGE) {
|
||||||
|
// Matter.Body.setVelocity(mob[i], Matter.Vector.rotate(mob[i].velocity, 0.1))
|
||||||
|
// }
|
||||||
|
if (DISTANCE < RANGE) {
|
||||||
|
const DEPTH = RANGE - DISTANCE
|
||||||
|
const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.000000001 * DEPTH * DEPTH * DEPTH * Math.sqrt(mob[i].mass))
|
||||||
|
mob[i].force.x += FORCE.x
|
||||||
|
mob[i].force.y += FORCE.y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// //draw laser targeting
|
||||||
|
// let best;
|
||||||
|
// let range = 3000
|
||||||
|
// const dir = mech.angle
|
||||||
|
// const path = [{
|
||||||
|
// x: mech.pos.x + 20 * Math.cos(dir),
|
||||||
|
// y: mech.pos.y + 20 * Math.sin(dir)
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// x: mech.pos.x + range * Math.cos(dir),
|
||||||
|
// y: mech.pos.y + range * Math.sin(dir)
|
||||||
|
// }
|
||||||
|
// ];
|
||||||
|
// const vertexCollision = function (v1, v1End, domain) {
|
||||||
|
// for (let i = 0; i < domain.length; ++i) {
|
||||||
|
// let vertices = domain[i].vertices;
|
||||||
|
// const len = vertices.length - 1;
|
||||||
|
// for (let j = 0; j < len; j++) {
|
||||||
|
// results = game.checkLineIntersection(v1, v1End, vertices[j], vertices[j + 1]);
|
||||||
|
// if (results.onLine1 && results.onLine2) {
|
||||||
|
// const dx = v1.x - results.x;
|
||||||
|
// const dy = v1.y - results.y;
|
||||||
|
// const dist2 = dx * dx + dy * dy;
|
||||||
|
// if (dist2 < best.dist2) {
|
||||||
|
// best = {
|
||||||
|
// x: results.x,
|
||||||
|
// y: results.y,
|
||||||
|
// dist2: dist2,
|
||||||
|
// who: domain[i],
|
||||||
|
// v1: vertices[j],
|
||||||
|
// v2: vertices[j + 1]
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// results = game.checkLineIntersection(v1, v1End, vertices[0], vertices[len]);
|
||||||
|
// if (results.onLine1 && results.onLine2) {
|
||||||
|
// const dx = v1.x - results.x;
|
||||||
|
// const dy = v1.y - results.y;
|
||||||
|
// const dist2 = dx * dx + dy * dy;
|
||||||
|
// if (dist2 < best.dist2) {
|
||||||
|
// best = {
|
||||||
|
// x: results.x,
|
||||||
|
// y: results.y,
|
||||||
|
// dist2: dist2,
|
||||||
|
// who: domain[i],
|
||||||
|
// v1: vertices[0],
|
||||||
|
// v2: vertices[len]
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// //check for collisions
|
||||||
|
// best = {
|
||||||
|
// x: null,
|
||||||
|
// y: null,
|
||||||
|
// dist2: Infinity,
|
||||||
|
// who: null,
|
||||||
|
// v1: null,
|
||||||
|
// v2: null
|
||||||
|
// };
|
||||||
|
// vertexCollision(path[0], path[1], mob);
|
||||||
|
// vertexCollision(path[0], path[1], map);
|
||||||
|
// vertexCollision(path[0], path[1], body);
|
||||||
|
// if (best.dist2 != Infinity) { //if hitting something
|
||||||
|
// path[path.length - 1] = {
|
||||||
|
// x: best.x,
|
||||||
|
// y: best.y
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //draw laser beam
|
||||||
|
// ctx.beginPath();
|
||||||
|
// ctx.moveTo(path[0].x, path[0].y);
|
||||||
|
// ctx.lineTo(path[1].x, path[1].y);
|
||||||
|
// ctx.strokeStyle = `rgba(50,0,100,0.1)`;
|
||||||
|
// ctx.lineWidth = this.charge * 3
|
||||||
|
// ctx.stroke();
|
||||||
|
|
||||||
|
//draw magnetic field
|
||||||
|
const X = mech.pos.x
|
||||||
|
const Y = mech.pos.y
|
||||||
|
const unitVector = Matter.Vector.normalise(Matter.Vector.sub(game.mouseInGame, mech.pos))
|
||||||
|
const unitVectorPerp = Matter.Vector.perp(unitVector)
|
||||||
|
|
||||||
|
function magField(mag, arc) {
|
||||||
|
ctx.moveTo(X, Y);
|
||||||
|
ctx.bezierCurveTo(
|
||||||
|
X + unitVector.x * mag, Y + unitVector.y * mag,
|
||||||
|
X + unitVector.x * mag + unitVectorPerp.x * arc, Y + unitVector.y * mag + unitVectorPerp.y * arc,
|
||||||
|
X + unitVectorPerp.x * arc, Y + unitVectorPerp.y * arc)
|
||||||
|
ctx.bezierCurveTo(
|
||||||
|
X - unitVector.x * mag + unitVectorPerp.x * arc, Y - unitVector.y * mag + unitVectorPerp.y * arc,
|
||||||
|
X - unitVector.x * mag, Y - unitVector.y * mag,
|
||||||
|
X, Y)
|
||||||
|
}
|
||||||
|
ctx.fillStyle = `rgba(50,0,100,0.05)`;
|
||||||
|
for (let i = 3; i < 7; i++) {
|
||||||
|
const MAG = 8 * i * i * this.charge * (0.93 + 0.07 * Math.random())
|
||||||
|
const ARC = 6 * i * i * this.charge * (0.93 + 0.07 * Math.random())
|
||||||
|
ctx.beginPath();
|
||||||
|
magField(MAG, ARC)
|
||||||
|
magField(MAG, -ARC)
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { //normal bullet behavior
|
||||||
|
this.force.y += this.mass * 0.00015 / this.charge; // low gravity that scales with charge
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// }, {
|
||||||
|
// name: "kinetic slugs", //1
|
||||||
|
// description: "fire a large <strong>rod</strong> that does excessive physical <span class='color-d'>damage</span><br><em>high recoil</em>",
|
||||||
|
// ammo: 0,
|
||||||
|
// ammoPack: 5,
|
||||||
|
// have: false,
|
||||||
|
// isStarterGun: true,
|
||||||
|
// fire() {
|
||||||
|
// b.muzzleFlash(45);
|
||||||
|
// // mobs.alert(800);
|
||||||
|
// const me = bullet.length;
|
||||||
|
// const dir = mech.angle;
|
||||||
|
// bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), 70 * b.modBulletSize, 30 * b.modBulletSize, b.fireAttributes(dir));
|
||||||
|
// b.fireProps(mech.crouch ? 55 : 40, 50, dir, me); //cd , speed
|
||||||
|
// bullet[me].endCycle = game.cycle + Math.floor(180 * b.isModBulletsLastLonger);
|
||||||
|
// bullet[me].do = function () {
|
||||||
|
// this.force.y += this.mass * 0.0005;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// //knock back
|
||||||
|
// const KNOCK = ((mech.crouch) ? 0.025 : 0.25) * b.modBulletSize * b.modBulletSize
|
||||||
|
// player.force.x -= KNOCK * Math.cos(dir)
|
||||||
|
// player.force.y -= KNOCK * Math.sin(dir) * 0.3 //reduce knock back in vertical direction to stop super jumps
|
||||||
|
// }
|
||||||
|
}, {
|
||||||
name: "minigun", //2
|
name: "minigun", //2
|
||||||
description: "rapidly fire a stream of small <strong>bullets</strong>",
|
description: "rapidly fire a stream of small <strong>bullets</strong>",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
@@ -678,14 +899,13 @@ const b = {
|
|||||||
const dir = mech.angle + (Math.random() - 0.5) * ((mech.crouch) ? 0.03 : 0.14);
|
const dir = mech.angle + (Math.random() - 0.5) * ((mech.crouch) ? 0.03 : 0.14);
|
||||||
bullet[me] = Bodies.rectangle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 17 * b.modBulletSize, 5 * b.modBulletSize, b.fireAttributes(dir));
|
bullet[me] = Bodies.rectangle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 17 * b.modBulletSize, 5 * b.modBulletSize, b.fireAttributes(dir));
|
||||||
b.fireProps(mech.crouch ? 11 : 5, mech.crouch ? 44 : 36, dir, me); //cd , speed
|
b.fireProps(mech.crouch ? 11 : 5, mech.crouch ? 44 : 36, dir, me); //cd , speed
|
||||||
bullet[me].endCycle = game.cycle + Math.floor(65 * b.modBulletsLastLonger);
|
bullet[me].endCycle = game.cycle + Math.floor(65 * b.isModBulletsLastLonger);
|
||||||
bullet[me].frictionAir = mech.crouch ? 0.007 : 0.01;
|
bullet[me].frictionAir = mech.crouch ? 0.007 : 0.01;
|
||||||
bullet[me].do = function () {
|
bullet[me].do = function () {
|
||||||
this.force.y += this.mass * 0.0005;
|
this.force.y += this.mass * 0.0005;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: "wave beam", //3
|
name: "wave beam", //3
|
||||||
description: "fire a stream of oscillating particles<br><strong style='opacity: 0.4;'>propagates through solids</strong>",
|
description: "fire a stream of oscillating particles<br><strong style='opacity: 0.4;'>propagates through solids</strong>",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
@@ -700,11 +920,11 @@ const b = {
|
|||||||
bullet[me] = Bodies.circle(mech.pos.x + 25 * Math.cos(DIR), mech.pos.y + 25 * Math.sin(DIR), 10 * b.modBulletSize, {
|
bullet[me] = Bodies.circle(mech.pos.x + 25 * Math.cos(DIR), mech.pos.y + 25 * Math.sin(DIR), 10 * b.modBulletSize, {
|
||||||
angle: DIR,
|
angle: DIR,
|
||||||
cycle: -0.43, //adjust this number until the bullets line up with the cross hairs
|
cycle: -0.43, //adjust this number until the bullets line up with the cross hairs
|
||||||
endCycle: game.cycle + Math.floor((mech.crouch ? 155 : 120) * b.modBulletsLastLonger),
|
endCycle: game.cycle + Math.floor((mech.crouch ? 155 : 120) * b.isModBulletsLastLonger),
|
||||||
inertia: Infinity,
|
inertia: Infinity,
|
||||||
frictionAir: 0,
|
frictionAir: 0,
|
||||||
minDmgSpeed: 0,
|
minDmgSpeed: 0,
|
||||||
dmg: 0.13 + b.extraDmg, //damage done in addition to the damage from momentum
|
dmg: 0.13 + b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||||
classType: "bullet",
|
classType: "bullet",
|
||||||
collisionFilter: {
|
collisionFilter: {
|
||||||
category: 0x000100,
|
category: 0x000100,
|
||||||
@@ -738,8 +958,7 @@ const b = {
|
|||||||
|
|
||||||
World.add(engine.world, bullet[me]); //add bullet to world
|
World.add(engine.world, bullet[me]); //add bullet to world
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: "super balls", //4
|
name: "super balls", //4
|
||||||
description: "fire 3 very <strong>bouncy</strong> balls",
|
description: "fire 3 very <strong>bouncy</strong> balls",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
@@ -756,8 +975,8 @@ const b = {
|
|||||||
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 7 * b.modBulletSize, b.fireAttributes(dir, false));
|
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 7 * b.modBulletSize, b.fireAttributes(dir, false));
|
||||||
b.fireProps(mech.crouch ? 40 : 20, mech.crouch ? 34 : 26, dir, me); //cd , speed
|
b.fireProps(mech.crouch ? 40 : 20, mech.crouch ? 34 : 26, dir, me); //cd , speed
|
||||||
Matter.Body.setDensity(bullet[me], 0.0001);
|
Matter.Body.setDensity(bullet[me], 0.0001);
|
||||||
bullet[me].endCycle = game.cycle + Math.floor(360 * b.modBulletsLastLonger);
|
bullet[me].endCycle = game.cycle + Math.floor(360 * b.isModBulletsLastLonger);
|
||||||
bullet[me].dmg = 0.5 + b.extraDmg;
|
bullet[me].dmg = 0.5 + b.modExtraDmg;
|
||||||
bullet[me].minDmgSpeed = 0;
|
bullet[me].minDmgSpeed = 0;
|
||||||
bullet[me].restitution = 0.96;
|
bullet[me].restitution = 0.96;
|
||||||
bullet[me].friction = 0;
|
bullet[me].friction = 0;
|
||||||
@@ -767,10 +986,9 @@ const b = {
|
|||||||
dir += SPREAD;
|
dir += SPREAD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: "shotgun", //5
|
name: "shotgun", //5
|
||||||
description: "fire a <strong>burst</strong> of bullets<br><em>high recoil</em>",
|
description: "fire a <strong>burst</strong> of bullets<br><em>crouch to reduce recoil</em>",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
ammoPack: 8,
|
ammoPack: 8,
|
||||||
have: false,
|
have: false,
|
||||||
@@ -784,7 +1002,7 @@ const b = {
|
|||||||
const dir = mech.angle + (Math.random() - 0.5) * (mech.crouch ? 0.22 : 0.7)
|
const dir = mech.angle + (Math.random() - 0.5) * (mech.crouch ? 0.22 : 0.7)
|
||||||
bullet[me] = Bodies.rectangle(mech.pos.x + 35 * Math.cos(mech.angle) + 15 * (Math.random() - 0.5), mech.pos.y + 35 * Math.sin(mech.angle) + 15 * (Math.random() - 0.5), side, side, b.fireAttributes(dir));
|
bullet[me] = Bodies.rectangle(mech.pos.x + 35 * Math.cos(mech.angle) + 15 * (Math.random() - 0.5), mech.pos.y + 35 * Math.sin(mech.angle) + 15 * (Math.random() - 0.5), side, side, b.fireAttributes(dir));
|
||||||
b.fireProps(mech.crouch ? 60 : 30, 40 + Math.random() * 11, dir, me); //cd , speed
|
b.fireProps(mech.crouch ? 60 : 30, 40 + Math.random() * 11, dir, me); //cd , speed
|
||||||
bullet[me].endCycle = game.cycle + Math.floor(55 * b.modBulletsLastLonger);
|
bullet[me].endCycle = game.cycle + Math.floor(55 * b.isModBulletsLastLonger);
|
||||||
bullet[me].frictionAir = 0.03;
|
bullet[me].frictionAir = 0.03;
|
||||||
bullet[me].do = function () {
|
bullet[me].do = function () {
|
||||||
this.force.y += this.mass * 0.001;
|
this.force.y += this.mass * 0.001;
|
||||||
@@ -794,22 +1012,21 @@ const b = {
|
|||||||
//knock back
|
//knock back
|
||||||
const KNOCK = ((mech.crouch) ? 0.015 : 0.15) * b.modBulletSize * b.modBulletSize
|
const KNOCK = ((mech.crouch) ? 0.015 : 0.15) * b.modBulletSize * b.modBulletSize
|
||||||
player.force.x -= KNOCK * Math.cos(mech.angle)
|
player.force.x -= KNOCK * Math.cos(mech.angle)
|
||||||
player.force.y -= KNOCK * Math.sin(mech.angle) * 0.4 //reduce knock back in vertical direction to stop super jumps
|
player.force.y -= KNOCK * Math.sin(mech.angle) * 0.3 //reduce knock back in vertical direction to stop super jumps
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: "fléchettes", //6
|
name: "fléchettes", //6
|
||||||
description: "fire accurate high speed needles",
|
description: "fire accurate high speed needles",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
ammoPack: 20,
|
ammoPack: 25,
|
||||||
have: false,
|
have: false,
|
||||||
isStarterGun: true,
|
isStarterGun: true,
|
||||||
fire() {
|
fire() {
|
||||||
function spawnFlechette(dir = mech.angle, speed, size = 1) {
|
function spawnFlechette(dir = mech.angle, speed, size = 1) {
|
||||||
const me = bullet.length;
|
const me = bullet.length;
|
||||||
bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(dir), mech.pos.y + 40 * Math.sin(dir), 65 * size * b.modBulletSize, 1.5 * size * b.modBulletSize, b.fireAttributes(dir));
|
bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(dir), mech.pos.y + 40 * Math.sin(dir), 32 * size * b.modBulletSize, 0.8 * size * b.modBulletSize, b.fireAttributes(dir));
|
||||||
bullet[me].endCycle = game.cycle + Math.floor(180 * b.modBulletsLastLonger);
|
bullet[me].endCycle = game.cycle + Math.floor(180 * b.isModBulletsLastLonger);
|
||||||
bullet[me].dmg = 0.25 * size + b.extraDmg;
|
bullet[me].dmg = 0.15 * size + b.modExtraDmg;
|
||||||
b.drawOneBullet(bullet[me].vertices);
|
b.drawOneBullet(bullet[me].vertices);
|
||||||
bullet[me].do = function () {
|
bullet[me].do = function () {
|
||||||
this.force.y += this.mass * 0.0002; //low gravity
|
this.force.y += this.mass * 0.0002; //low gravity
|
||||||
@@ -822,16 +1039,17 @@ const b = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mech.crouch) {
|
if (mech.crouch) {
|
||||||
spawnFlechette(mech.angle, 55, 1.2)
|
for (let i = 0; i < 3; i++) {
|
||||||
|
spawnFlechette(mech.angle + 0.02 * (Math.random() - 0.5), 35 + 4 * i, 1.55)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < 7; i++) {
|
for (let i = 0; i < 9; i++) {
|
||||||
spawnFlechette(mech.angle + 0.14 * (Math.random() - 0.5), 30 + 8 * Math.random(), 0.5)
|
spawnFlechette(mech.angle + 0.12 * (Math.random() - 0.5), 30 + 8 * Math.random())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mech.fireCDcycle = mech.cycle + Math.floor(30 * b.modFireRate); // cool down
|
mech.fireCDcycle = mech.cycle + Math.floor(40 * b.modFireRate); // cool down
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: "missiles", //7
|
name: "missiles", //7
|
||||||
description: "fire a missile that accelerates towards nearby targets<br><span class='color-e'>explodes</span> when near target",
|
description: "fire a missile that accelerates towards nearby targets<br><span class='color-e'>explodes</span> when near target",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
@@ -851,7 +1069,7 @@ const b = {
|
|||||||
// Matter.Body.setDensity(bullet[me], 0.01) //doesn't help with reducing explosion knock backs
|
// Matter.Body.setDensity(bullet[me], 0.01) //doesn't help with reducing explosion knock backs
|
||||||
bullet[me].force.y += 0.00045; //a small push down at first to make it seem like the missile is briefly falling
|
bullet[me].force.y += 0.00045; //a small push down at first to make it seem like the missile is briefly falling
|
||||||
bullet[me].frictionAir = 0
|
bullet[me].frictionAir = 0
|
||||||
bullet[me].endCycle = game.cycle + Math.floor((265 + Math.random() * 20) * b.modBulletsLastLonger);
|
bullet[me].endCycle = game.cycle + Math.floor((265 + Math.random() * 20) * b.isModBulletsLastLonger);
|
||||||
bullet[me].explodeRad = 170 + 60 * Math.random();
|
bullet[me].explodeRad = 170 + 60 * Math.random();
|
||||||
bullet[me].lookFrequency = Math.floor(8 + Math.random() * 7);
|
bullet[me].lookFrequency = Math.floor(8 + Math.random() * 7);
|
||||||
bullet[me].onEnd = b.explode; //makes bullet do explosive damage at end
|
bullet[me].onEnd = b.explode; //makes bullet do explosive damage at end
|
||||||
@@ -936,8 +1154,7 @@ const b = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: "flak", //8
|
name: "flak", //8
|
||||||
description: "fire a cluster of short range projectiles<br><span class='color-e'>explode</span> on contact or after half a second",
|
description: "fire a cluster of short range projectiles<br><span class='color-e'>explode</span> on contact or after half a second",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
@@ -950,7 +1167,7 @@ const b = {
|
|||||||
const angleStep = (mech.crouch ? 0.06 : 0.15) / totalBullets
|
const angleStep = (mech.crouch ? 0.06 : 0.15) / totalBullets
|
||||||
const SPEED = mech.crouch ? 30 : 25
|
const SPEED = mech.crouch ? 30 : 25
|
||||||
const CD = mech.crouch ? 45 : 11
|
const CD = mech.crouch ? 45 : 11
|
||||||
const END = Math.floor((mech.crouch ? 30 : 18) * b.modBulletsLastLonger);
|
const END = Math.floor((mech.crouch ? 30 : 18) * b.isModBulletsLastLonger);
|
||||||
let dir = mech.angle - angleStep * totalBullets / 2;
|
let dir = mech.angle - angleStep * totalBullets / 2;
|
||||||
const side1 = 17 * b.modBulletSize
|
const side1 = 17 * b.modBulletSize
|
||||||
const side2 = 4 * b.modBulletSize
|
const side2 = 4 * b.modBulletSize
|
||||||
@@ -980,8 +1197,7 @@ const b = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: "grenades", //9
|
name: "grenades", //9
|
||||||
description: "fire a projectile that <span class='color-e'>explodes</span> on contact or after one second",
|
description: "fire a projectile that <span class='color-e'>explodes</span> on contact or after one second",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
@@ -996,7 +1212,7 @@ const b = {
|
|||||||
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].totalCycles = 100;
|
bullet[me].totalCycles = 100;
|
||||||
bullet[me].endCycle = game.cycle + Math.floor((mech.crouch ? 120 : 60) * b.modBulletsLastLonger);
|
bullet[me].endCycle = game.cycle + Math.floor((mech.crouch ? 120 : 60) * b.isModBulletsLastLonger);
|
||||||
bullet[me].restitution = 0.5;
|
bullet[me].restitution = 0.5;
|
||||||
bullet[me].explodeRad = 210;
|
bullet[me].explodeRad = 210;
|
||||||
bullet[me].onEnd = b.explode; //makes bullet do explosive damage before despawn
|
bullet[me].onEnd = b.explode; //makes bullet do explosive damage before despawn
|
||||||
@@ -1009,12 +1225,11 @@ const b = {
|
|||||||
this.force.y += this.mass * 0.002;
|
this.force.y += this.mass * 0.002;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: "vacuum bomb", //10
|
name: "vacuum bomb", //10
|
||||||
description: "fire a huge <strong>bomb</strong> that sucks before it <span class='color-e'>explodes</span><br>click left mouse <strong>again</strong> to detonate",
|
description: "fire a huge <strong>bomb</strong> that sucks before it <span class='color-e'>explodes</span><br>click left mouse <strong>again</strong> to detonate",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
ammoPack: 4,
|
ammoPack: 5,
|
||||||
have: false,
|
have: false,
|
||||||
isStarterGun: false,
|
isStarterGun: false,
|
||||||
fire() {
|
fire() {
|
||||||
@@ -1026,7 +1241,6 @@ const b = {
|
|||||||
|
|
||||||
b.drawOneBullet(bullet[me].vertices);
|
b.drawOneBullet(bullet[me].vertices);
|
||||||
bullet[me].endCycle = Infinity
|
bullet[me].endCycle = Infinity
|
||||||
bullet[me].endCycle = Infinity
|
|
||||||
// bullet[me].restitution = 0.3;
|
// bullet[me].restitution = 0.3;
|
||||||
// bullet[me].frictionAir = 0.01;
|
// bullet[me].frictionAir = 0.01;
|
||||||
// bullet[me].friction = 0.15;
|
// bullet[me].friction = 0.15;
|
||||||
@@ -1120,8 +1334,7 @@ const b = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: "ferro frag", //11
|
name: "ferro frag", //11
|
||||||
description: "fire a <strong>grenade</strong> that ejects <strong class='color-m'>magnetized</strong> nails<br>nails are <strong class='color-m'>attracted</strong> to enemy targets",
|
description: "fire a <strong>grenade</strong> that ejects <strong class='color-m'>magnetized</strong> nails<br>nails are <strong class='color-m'>attracted</strong> to enemy targets",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
@@ -1134,7 +1347,7 @@ const b = {
|
|||||||
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 15 * b.modBulletSize, b.fireAttributes(dir, false));
|
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 15 * b.modBulletSize, b.fireAttributes(dir, false));
|
||||||
b.fireProps(mech.crouch ? 40 : 30, mech.crouch ? 34 : 22, dir, me); //cd , speed
|
b.fireProps(mech.crouch ? 40 : 30, mech.crouch ? 34 : 22, dir, me); //cd , speed
|
||||||
b.drawOneBullet(bullet[me].vertices);
|
b.drawOneBullet(bullet[me].vertices);
|
||||||
bullet[me].endCycle = game.cycle + Math.floor(60 * b.modBulletsLastLonger);
|
bullet[me].endCycle = game.cycle + Math.floor(60 * b.isModBulletsLastLonger);
|
||||||
bullet[me].restitution = 0.3;
|
bullet[me].restitution = 0.3;
|
||||||
// bullet[me].frictionAir = 0.01;
|
// bullet[me].frictionAir = 0.01;
|
||||||
// bullet[me].friction = 0.15;
|
// bullet[me].friction = 0.15;
|
||||||
@@ -1180,7 +1393,7 @@ const b = {
|
|||||||
Matter.Body.setVelocity(bullet[me], velocity);
|
Matter.Body.setVelocity(bullet[me], velocity);
|
||||||
World.add(engine.world, bullet[me]); //add bullet to world
|
World.add(engine.world, bullet[me]); //add bullet to world
|
||||||
bullet[me].endCycle = game.cycle + 60 + Math.floor(15 * Math.random());
|
bullet[me].endCycle = game.cycle + 60 + Math.floor(15 * Math.random());
|
||||||
// bullet[me].dmg = 1.1+b.extraDmg;
|
// bullet[me].dmg = 1.1+b.modExtraDmg;
|
||||||
bullet[me].do = function () {};
|
bullet[me].do = function () {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1188,8 +1401,7 @@ const b = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: "spores", //12
|
name: "spores", //12
|
||||||
description: "release an orb that discharges <span class='color-s'>spores</span> after 2 seconds<br>seeks out targets<br>passes through blocks",
|
description: "release an orb that discharges <span class='color-s'>spores</span> after 2 seconds<br>seeks out targets<br>passes through blocks",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
@@ -1238,13 +1450,13 @@ const b = {
|
|||||||
angle: dir,
|
angle: dir,
|
||||||
friction: 0,
|
friction: 0,
|
||||||
frictionAir: 0.011,
|
frictionAir: 0.011,
|
||||||
dmg: 1.8 + b.extraDmg, //damage done in addition to the damage from momentum
|
dmg: 1.8 + b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||||
classType: "bullet",
|
classType: "bullet",
|
||||||
collisionFilter: {
|
collisionFilter: {
|
||||||
category: 0x000100,
|
category: 0x000100,
|
||||||
mask: 0x000011 //no collide with body
|
mask: 0x000011 //no collide with body
|
||||||
},
|
},
|
||||||
endCycle: game.cycle + Math.floor((360 + Math.floor(Math.random() * 240)) * b.modBulletsLastLonger),
|
endCycle: game.cycle + Math.floor((360 + Math.floor(Math.random() * 240)) * b.isModBulletsLastLonger),
|
||||||
minDmgSpeed: 0,
|
minDmgSpeed: 0,
|
||||||
onDmg() {
|
onDmg() {
|
||||||
this.endCycle = 0; //bullet ends cycle after doing damage
|
this.endCycle = 0; //bullet ends cycle after doing damage
|
||||||
@@ -1292,8 +1504,7 @@ const b = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
name: "drones", //13
|
name: "drones", //13
|
||||||
description: "release <strong>drones</strong> that seek out targets for 16 seconds<br>follows mouse if no targets are found",
|
description: "release <strong>drones</strong> that seek out targets for 16 seconds<br>follows mouse if no targets are found",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
@@ -1311,9 +1522,9 @@ const b = {
|
|||||||
friction: 0,
|
friction: 0,
|
||||||
frictionAir: 0.0005,
|
frictionAir: 0.0005,
|
||||||
restitution: 1,
|
restitution: 1,
|
||||||
dmg: 0.14 + b.extraDmg, //damage done in addition to the damage from momentum
|
dmg: 0.14 + b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||||
lookFrequency: 79 + Math.floor(37 * Math.random()),
|
lookFrequency: 79 + Math.floor(37 * Math.random()),
|
||||||
endCycle: game.cycle + Math.floor((780 + 360 * Math.random()) * b.modBulletsLastLonger),
|
endCycle: game.cycle + Math.floor((780 + 360 * Math.random()) * b.isModBulletsLastLonger),
|
||||||
classType: "bullet",
|
classType: "bullet",
|
||||||
collisionFilter: {
|
collisionFilter: {
|
||||||
category: 0x000100,
|
category: 0x000100,
|
||||||
@@ -1387,8 +1598,7 @@ const b = {
|
|||||||
b.fireProps(mech.crouch ? 19 : 15, mech.crouch ? 35 : 1, dir, me); //cd , speed
|
b.fireProps(mech.crouch ? 19 : 15, mech.crouch ? 35 : 1, dir, me); //cd , speed
|
||||||
b.drawOneBullet(bullet[me].vertices);
|
b.drawOneBullet(bullet[me].vertices);
|
||||||
}
|
}
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
//draw a halo, since there will only be 1-3 balls
|
//draw a halo, since there will only be 1-3 balls
|
||||||
name: "junk-bots", //14
|
name: "junk-bots", //14
|
||||||
description: "release large <strong>drones</strong> that defend the space around the player<br>despawn after not doing <span class='color-d'>damage</span> for 3 seconds",
|
description: "release large <strong>drones</strong> that defend the space around the player<br>despawn after not doing <span class='color-d'>damage</span> for 3 seconds",
|
||||||
@@ -1409,21 +1619,21 @@ const b = {
|
|||||||
friction: 0,
|
friction: 0,
|
||||||
frictionAir: 0.06,
|
frictionAir: 0.06,
|
||||||
restitution: 1,
|
restitution: 1,
|
||||||
dmg: b.extraDmg, // 0.14 //damage done in addition to the damage from momentum
|
dmg: b.modExtraDmg, // 0.14 //damage done in addition to the damage from momentum
|
||||||
minDmgSpeed: 2,
|
minDmgSpeed: 2,
|
||||||
lookFrequency: 37 + Math.floor(37 * Math.random()),
|
lookFrequency: 37 + Math.floor(37 * Math.random()),
|
||||||
endCycle: game.cycle + Math.floor((170 + 120 * Math.random()) * b.modBulletsLastLonger),
|
endCycle: game.cycle + Math.floor((170 + 120 * Math.random()) * b.isModBulletsLastLonger),
|
||||||
classType: "bullet",
|
classType: "bullet",
|
||||||
collisionFilter: {
|
collisionFilter: {
|
||||||
category: 0x000100,
|
category: 0x000100,
|
||||||
mask: 0x010111 //self, mob,map,body collide
|
mask: 0x010111 //self, mob,map,body collide
|
||||||
},
|
},
|
||||||
range: 500 + 150 * Math.random(),
|
range: 700,
|
||||||
lockedOn: null,
|
lockedOn: null,
|
||||||
onDmg() {
|
onDmg() {
|
||||||
// this.endCycle = 0;
|
// this.endCycle = 0;
|
||||||
this.lockedOn = null
|
this.lockedOn = null
|
||||||
this.endCycle = game.cycle + Math.floor(180 * b.modBulletsLastLonger)
|
this.endCycle = game.cycle + Math.floor(180 * b.isModBulletsLastLonger)
|
||||||
},
|
},
|
||||||
onEnd() {},
|
onEnd() {},
|
||||||
do() {
|
do() {
|
||||||
@@ -1462,6 +1672,5 @@ const b = {
|
|||||||
b.fireProps(mech.crouch ? 40 : 10, mech.crouch ? 40 : 10, dir, me); //cd , speed
|
b.fireProps(mech.crouch ? 40 : 10, mech.crouch ? 40 : 10, dir, me); //cd , speed
|
||||||
b.drawOneBullet(bullet[me].vertices);
|
b.drawOneBullet(bullet[me].vertices);
|
||||||
}
|
}
|
||||||
},
|
}, ]
|
||||||
]
|
|
||||||
};
|
};
|
||||||
13
js/engine.js
13
js/engine.js
@@ -91,13 +91,10 @@ function mobCollisionChecks(event) {
|
|||||||
const v = Matter.Vector.magnitude(Matter.Vector.sub(player.velocity, obj.velocity));
|
const v = Matter.Vector.magnitude(Matter.Vector.sub(player.velocity, obj.velocity));
|
||||||
if (v > speedThreshold) {
|
if (v > speedThreshold) {
|
||||||
mech.damageImmune = mech.cycle + 30; //player is immune to collision damage for 30 cycles
|
mech.damageImmune = mech.cycle + 30; //player is immune to collision damage for 30 cycles
|
||||||
let dmg = Math.sqrt((v - speedThreshold + 0.1) * (obj.mass - massThreshold)) * 0.02;
|
let dmg = Math.sqrt((v - speedThreshold + 0.1) * (obj.mass - massThreshold)) * 0.01;
|
||||||
dmg = Math.min(Math.max(dmg, 0.02), 0.2);
|
dmg = Math.min(Math.max(dmg, 0.02), 0.15);
|
||||||
// console.log(`mass = ${obj.mass} \n`, `dmg = ${dmg}\n`, `v = ${v}\n`)
|
|
||||||
// console.log(v, dmg)
|
|
||||||
mech.damage(dmg);
|
mech.damage(dmg);
|
||||||
game.drawList.push({
|
game.drawList.push({ //add dmg to draw queue
|
||||||
//add dmg to draw queue
|
|
||||||
x: pairs[i].activeContacts[0].vertex.x,
|
x: pairs[i].activeContacts[0].vertex.x,
|
||||||
y: pairs[i].activeContacts[0].vertex.y,
|
y: pairs[i].activeContacts[0].vertex.y,
|
||||||
radius: dmg * 500,
|
radius: dmg * 500,
|
||||||
@@ -144,7 +141,7 @@ function mobCollisionChecks(event) {
|
|||||||
let dmg = Math.min(Math.max(0.025 * Math.sqrt(mob[k].mass), 0.05), 0.3) * game.dmgScale; //player damage is capped at 0.3*dmgScale of 1.0
|
let dmg = Math.min(Math.max(0.025 * Math.sqrt(mob[k].mass), 0.05), 0.3) * game.dmgScale; //player damage is capped at 0.3*dmgScale of 1.0
|
||||||
mech.damage(dmg);
|
mech.damage(dmg);
|
||||||
if (mob[k].onHit) mob[k].onHit(k);
|
if (mob[k].onHit) mob[k].onHit(k);
|
||||||
if (b.annihilation && mob[k].dropPowerUp) {
|
if (b.modAnnihilation && mob[k].dropPowerUp) {
|
||||||
mob[k].death();
|
mob[k].death();
|
||||||
game.drawList.push({
|
game.drawList.push({
|
||||||
//add dmg to draw queue
|
//add dmg to draw queue
|
||||||
@@ -182,7 +179,7 @@ function mobCollisionChecks(event) {
|
|||||||
if (obj.classType === "bullet" && obj.speed > obj.minDmgSpeed) {
|
if (obj.classType === "bullet" && obj.speed > obj.minDmgSpeed) {
|
||||||
mob[k].foundPlayer();
|
mob[k].foundPlayer();
|
||||||
// const dmg = b.dmgScale * (obj.dmg + 0.15 * obj.mass * Matter.Vector.magnitude(Matter.Vector.sub(mob[k].velocity, obj.velocity)));
|
// const dmg = b.dmgScale * (obj.dmg + 0.15 * obj.mass * Matter.Vector.magnitude(Matter.Vector.sub(mob[k].velocity, obj.velocity)));
|
||||||
const dmg = b.dmgScale * (obj.dmg + b.extraDmg + 0.15 * obj.mass * Matter.Vector.magnitude(Matter.Vector.sub(mob[k].velocity, obj.velocity)))
|
const dmg = b.dmgScale * (obj.dmg + b.modExtraDmg + 0.15 * obj.mass * Matter.Vector.magnitude(Matter.Vector.sub(mob[k].velocity, obj.velocity)))
|
||||||
mob[k].damage(dmg);
|
mob[k].damage(dmg);
|
||||||
obj.onDmg(); //some bullets do actions when they hits things, like despawn
|
obj.onDmg(); //some bullets do actions when they hits things, like despawn
|
||||||
game.drawList.push({
|
game.drawList.push({
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ const game = {
|
|||||||
document.getElementById("mods").innerHTML = text
|
document.getElementById("mods").innerHTML = text
|
||||||
},
|
},
|
||||||
replaceTextLog: true,
|
replaceTextLog: true,
|
||||||
|
// <!-- <path d="M832.41,106.64 V323.55 H651.57 V256.64 c0-82.5,67.5-150,150-150 Z" fill="#789" stroke="none" />
|
||||||
|
// <path d="M827,112 h30 a140,140,0,0,1,140,140 v68 h-167 z" fill="#7ce" stroke="none" /> -->
|
||||||
|
SVGleftMouse: '<svg viewBox="750 0 200 765" class="mouse-icon" width="40px" height = "60px" stroke-linecap="round" stroke-linejoin="round" stroke-width="25px" stroke="#000" fill="none"> <path fill="#fff" stroke="none" d="M827,112 h30 a140,140,0,0,1,140,140 v268 a140,140,0,0,1-140,140 h-60 a140,140,0,0,1-140-140v-268 a140,140,0,0,1,140-140h60" /> <path d="M832.41,106.64 V323.55 H651.57 V256.64 c0-82.5,67.5-150,150-150 Z" fill="#456" stroke="none" /> <path fill="none" d="M827,112 h30 a140,140,0,0,1,140,140 v268 a140,140,0,0,1-140,140 h-60 a140,140,0,0,1-140-140v-268 a140,140,0,0,1,140-140h60" /> <path d="M657 317 h 340 h-170 v-207" /> <ellipse fill="#fff" cx="827.57" cy="218.64" rx="29" ry="68" /> </svg>',
|
||||||
|
SVGrightMouse: '<svg viewBox="750 0 200 765" class="mouse-icon" width="40px" height = "60px" stroke-linecap="round" stroke-linejoin="round" stroke-width="25px" stroke="#000" fill="none"> <path fill="#fff" stroke="none" d="M827,112 h30 a140,140,0,0,1,140,140 v268 a140,140,0,0,1-140,140 h-60 a140,140,0,0,1-140-140v-268 a140,140,0,0,1,140-140h60" /> <path d="M827,112 h30 a140,140,0,0,1,140,140 v68 h-167 z" fill="#0af" stroke="none" /> <path fill="none" d="M827,112 h30 a140,140,0,0,1,140,140 v268 a140,140,0,0,1-140,140 h-60 a140,140,0,0,1-140-140v-268 a140,140,0,0,1,140-140h60" /> <path d="M657 317 h 340 h-170 v-207" /> <ellipse fill="#fff" cx="827.57" cy="218.64" rx="29" ry="68" /> </svg>',
|
||||||
makeTextLog(text, time = 180) {
|
makeTextLog(text, time = 180) {
|
||||||
if (game.replaceTextLog) {
|
if (game.replaceTextLog) {
|
||||||
document.getElementById("text-log").innerHTML = text;
|
document.getElementById("text-log").innerHTML = text;
|
||||||
@@ -508,6 +512,7 @@ const game = {
|
|||||||
if (mech.holdingTarget) {
|
if (mech.holdingTarget) {
|
||||||
holdTarget = mech.holdingTarget;
|
holdTarget = mech.holdingTarget;
|
||||||
}
|
}
|
||||||
|
mech.fireCDcycle = 0
|
||||||
mech.drop();
|
mech.drop();
|
||||||
level.fill = [];
|
level.fill = [];
|
||||||
level.fillBG = [];
|
level.fillBG = [];
|
||||||
|
|||||||
21
js/index.js
21
js/index.js
@@ -2,6 +2,27 @@
|
|||||||
/* TODO: *******************************************
|
/* TODO: *******************************************
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
||||||
|
gun: Spirit Bomb
|
||||||
|
use charge up like rail gun
|
||||||
|
|
||||||
|
left and right click mouse icons for text displays
|
||||||
|
|
||||||
|
mod: auto pick up guns, heals, ammo
|
||||||
|
use the same rule for drones
|
||||||
|
maybe give some other bonus too?
|
||||||
|
|
||||||
|
mod: + move speed and jump height
|
||||||
|
will leg animations look strange?
|
||||||
|
that's OK for a mod
|
||||||
|
this could just slow the mobs down instead?
|
||||||
|
how?
|
||||||
|
|
||||||
|
rework junk bot, or remove it
|
||||||
|
it's behavior is too unpredictable
|
||||||
|
range is unclear
|
||||||
|
having the bullets last long after doing dmg isn't fun
|
||||||
|
we want a fun gun that acts like a melee weapon
|
||||||
|
|
||||||
mouse can get suck as clicked if the user clicks off the window
|
mouse can get suck as clicked if the user clicks off the window
|
||||||
can lead to gun lock up until player pressed mouse again
|
can lead to gun lock up until player pressed mouse again
|
||||||
should I really need to fix this?
|
should I really need to fix this?
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ const level = {
|
|||||||
start() {
|
start() {
|
||||||
if (level.levelsCleared === 0) {
|
if (level.levelsCleared === 0) {
|
||||||
// game.difficulty = 6; //for testing to simulate possible mobs spawns
|
// game.difficulty = 6; //for testing to simulate possible mobs spawns
|
||||||
// b.giveGuns(6)
|
// b.giveGuns(1)
|
||||||
// mech.fieldUpgrades[7].effect();
|
// mech.fieldUpgrades[7].effect();
|
||||||
// b.giveMod(13)
|
b.giveMod(15)
|
||||||
// spawn.pickList = ["ghoster", "ghoster"]
|
// spawn.pickList = ["ghoster", "ghoster"]
|
||||||
|
|
||||||
this.intro(); //starting level
|
this.intro(); //starting level
|
||||||
@@ -1475,7 +1475,7 @@ const level = {
|
|||||||
level.onLevel++;
|
level.onLevel++;
|
||||||
if (level.onLevel > level.levels.length - 1) level.onLevel = 0;
|
if (level.onLevel > level.levels.length - 1) level.onLevel = 0;
|
||||||
|
|
||||||
game.clearNow = true; //triggers in the physics engine to remove all physics bodies
|
game.clearNow = true; //triggers in game.clearMap to remove all physics bodies and setup for new map
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
death() {
|
death() {
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ const mobs = {
|
|||||||
// ctx.lineDashOffset = 6*(game.cycle % 215);
|
// ctx.lineDashOffset = 6*(game.cycle % 215);
|
||||||
if (this.distanceToPlayer() < this.laserRange) {
|
if (this.distanceToPlayer() < this.laserRange) {
|
||||||
//if (Math.random()>0.2 && this.seePlayer.yes && this.distanceToPlayer2()<800000) {
|
//if (Math.random()>0.2 && this.seePlayer.yes && this.distanceToPlayer2()<800000) {
|
||||||
if (!b.AoEImmunity) {
|
if (!b.isModAoEImmunity) {
|
||||||
mech.damage(0.0003 * game.dmgScale);
|
mech.damage(0.0003 * game.dmgScale);
|
||||||
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.005
|
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.005
|
||||||
}
|
}
|
||||||
|
|||||||
117
js/player.js
117
js/player.js
@@ -6,15 +6,15 @@ const mech = {
|
|||||||
spawn() {
|
spawn() {
|
||||||
//load player in matter.js physic engine
|
//load player in matter.js physic engine
|
||||||
// let vector = Vertices.fromPath("0 40 50 40 50 115 0 115 30 130 20 130"); //player as a series of vertices
|
// let vector = Vertices.fromPath("0 40 50 40 50 115 0 115 30 130 20 130"); //player as a series of vertices
|
||||||
let vector = Vertices.fromPath("0,40, 50,40, 50,115, 30,130, 20,130, 0,115, 0,40"); //player as a series of vertices
|
let vertices = Vertices.fromPath("0,40, 50,40, 50,115, 30,130, 20,130, 0,115, 0,40"); //player as a series of vertices
|
||||||
playerBody = Matter.Bodies.fromVertices(0, 0, vector);
|
playerBody = Matter.Bodies.fromVertices(0, 0, vertices);
|
||||||
jumpSensor = Bodies.rectangle(0, 46, 36, 6, {
|
jumpSensor = Bodies.rectangle(0, 46, 36, 6, {
|
||||||
//this sensor check if the player is on the ground to enable jumping
|
//this sensor check if the player is on the ground to enable jumping
|
||||||
sleepThreshold: 99999999999,
|
sleepThreshold: 99999999999,
|
||||||
isSensor: true
|
isSensor: true
|
||||||
});
|
});
|
||||||
vector = Vertices.fromPath("16 -82 2 -66 2 -37 43 -37 43 -66 30 -82");
|
vertices = Vertices.fromPath("16 -82 2 -66 2 -37 43 -37 43 -66 30 -82");
|
||||||
playerHead = Matter.Bodies.fromVertices(0, -55, vector); //this part of the player lowers on crouch
|
playerHead = Matter.Bodies.fromVertices(0, -55, vertices); //this part of the player lowers on crouch
|
||||||
headSensor = Bodies.rectangle(0, -57, 48, 45, {
|
headSensor = Bodies.rectangle(0, -57, 48, 45, {
|
||||||
//senses if the player's head is empty and can return after crouching
|
//senses if the player's head is empty and can return after crouching
|
||||||
sleepThreshold: 99999999999,
|
sleepThreshold: 99999999999,
|
||||||
@@ -65,7 +65,7 @@ const mech = {
|
|||||||
},
|
},
|
||||||
defaultMass: 5,
|
defaultMass: 5,
|
||||||
mass: 5,
|
mass: 5,
|
||||||
Fx: 0.015, //run Force on ground
|
Fx: 0.015, //run Force on ground //this is reset in b.setModDefaults()
|
||||||
FxAir: 0.015, //run Force in Air
|
FxAir: 0.015, //run Force in Air
|
||||||
definePlayerMass(mass = mech.defaultMass) {
|
definePlayerMass(mass = mech.defaultMass) {
|
||||||
Matter.Body.setMass(player, mass);
|
Matter.Body.setMass(player, mass);
|
||||||
@@ -110,7 +110,7 @@ const mech = {
|
|||||||
Sy: 0, //adds a smoothing effect to vertical only
|
Sy: 0, //adds a smoothing effect to vertical only
|
||||||
Vx: 0,
|
Vx: 0,
|
||||||
Vy: 0,
|
Vy: 0,
|
||||||
jumpForce: 0.38,
|
jumpForce: 0.38, //this is reset in b.setModDefaults()
|
||||||
gravity: 0.0019,
|
gravity: 0.0019,
|
||||||
friction: {
|
friction: {
|
||||||
ground: 0.01,
|
ground: 0.01,
|
||||||
@@ -211,6 +211,14 @@ const mech = {
|
|||||||
this.doCrouch();
|
this.doCrouch();
|
||||||
this.yOff = this.yOffWhen.jump;
|
this.yOff = this.yOffWhen.jump;
|
||||||
this.hardLandCD = mech.cycle + Math.min(momentum / 6 - 6, 40)
|
this.hardLandCD = mech.cycle + Math.min(momentum / 6 - 6, 40)
|
||||||
|
|
||||||
|
if (game.isBodyDamage && momentum > 200 && player.velocity.y > 20) { //falling damage
|
||||||
|
mech.damageImmune = mech.cycle + 30; //player is immune to collision damage for 30 cycles
|
||||||
|
let dmg = Math.sqrt(momentum - 200) * 0.01
|
||||||
|
console.log(dmg, momentum, player.velocity.y)
|
||||||
|
dmg = Math.min(Math.max(dmg, 0.02), 0.15);
|
||||||
|
mech.damage(dmg);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.yOffGoal = this.yOffWhen.stand;
|
this.yOffGoal = this.yOffWhen.stand;
|
||||||
}
|
}
|
||||||
@@ -242,11 +250,17 @@ const mech = {
|
|||||||
//horizontal move on ground
|
//horizontal move on ground
|
||||||
//apply a force to move
|
//apply a force to move
|
||||||
if (keys[65] || keys[37]) { //left / a
|
if (keys[65] || keys[37]) { //left / a
|
||||||
|
if (player.velocity.x > -2) {
|
||||||
|
player.force.x -= this.Fx * 1.5
|
||||||
|
} else {
|
||||||
player.force.x -= this.Fx
|
player.force.x -= this.Fx
|
||||||
if (player.velocity.x > -2) player.force.x -= this.Fx * 0.5
|
}
|
||||||
} else if (keys[68] || keys[39]) { //right / d
|
} else if (keys[68] || keys[39]) { //right / d
|
||||||
|
if (player.velocity.x < 2) {
|
||||||
|
player.force.x += this.Fx * 1.5
|
||||||
|
} else {
|
||||||
player.force.x += this.Fx
|
player.force.x += this.Fx
|
||||||
if (player.velocity.x < 2) player.force.x += this.Fx * 0.5
|
}
|
||||||
} else {
|
} else {
|
||||||
const stoppingFriction = 0.92;
|
const stoppingFriction = 0.92;
|
||||||
Matter.Body.setVelocity(player, {
|
Matter.Body.setVelocity(player, {
|
||||||
@@ -287,76 +301,6 @@ const mech = {
|
|||||||
//smoothly move leg height towards height goal
|
//smoothly move leg height towards height goal
|
||||||
this.yOff = this.yOff * 0.85 + this.yOffGoal * 0.15;
|
this.yOff = this.yOff * 0.85 + this.yOffGoal * 0.15;
|
||||||
},
|
},
|
||||||
gamepadMove() {
|
|
||||||
if (this.onGround) { //on ground **********************
|
|
||||||
if (this.crouch) {
|
|
||||||
if (game.gamepad.leftAxis.y !== -1 && this.isHeadClear && this.hardLandCD < mech.cycle) this.undoCrouch();
|
|
||||||
} else if (game.gamepad.leftAxis.y === -1 || this.hardLandCD > mech.cycle) {
|
|
||||||
this.doCrouch(); //on ground && not crouched and pressing s or down
|
|
||||||
} else if (game.gamepad.jump && this.buttonCD_jump + 20 < mech.cycle && this.yOffWhen.stand > 23) {
|
|
||||||
this.buttonCD_jump = mech.cycle; //can't jump again until 20 cycles pass
|
|
||||||
|
|
||||||
//apply a fraction of the jump force to the body the player is jumping off of
|
|
||||||
Matter.Body.applyForce(mech.standingOn, mech.pos, {
|
|
||||||
x: 0,
|
|
||||||
y: this.jumpForce * 0.12 * Math.min(mech.standingOn.mass, 5)
|
|
||||||
});
|
|
||||||
|
|
||||||
player.force.y = -this.jumpForce; //player jump force
|
|
||||||
Matter.Body.setVelocity(player, { //zero player y-velocity for consistent jumps
|
|
||||||
x: player.velocity.x,
|
|
||||||
y: 0
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//horizontal move on ground
|
|
||||||
//apply a force to move
|
|
||||||
if (game.gamepad.leftAxis.x === -1) { //left / a
|
|
||||||
player.force.x -= this.Fx
|
|
||||||
if (player.velocity.x > -2) player.force.x -= this.Fx * 0.5
|
|
||||||
} else if (game.gamepad.leftAxis.x === 1) { //right / d
|
|
||||||
player.force.x += this.Fx
|
|
||||||
if (player.velocity.x < 2) player.force.x += this.Fx * 0.5
|
|
||||||
} else {
|
|
||||||
const stoppingFriction = 0.92;
|
|
||||||
Matter.Body.setVelocity(player, {
|
|
||||||
x: player.velocity.x * stoppingFriction,
|
|
||||||
y: player.velocity.y * stoppingFriction
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//come to a stop if fast or if no move key is pressed
|
|
||||||
if (player.speed > 4) {
|
|
||||||
const stoppingFriction = (this.crouch) ? 0.65 : 0.89;
|
|
||||||
Matter.Body.setVelocity(player, {
|
|
||||||
x: player.velocity.x * stoppingFriction,
|
|
||||||
y: player.velocity.y * stoppingFriction
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} else { // in air **********************************
|
|
||||||
//check for short jumps
|
|
||||||
if (
|
|
||||||
this.buttonCD_jump + 60 > mech.cycle && //just pressed jump
|
|
||||||
!game.gamepad.jump && //but not pressing jump key
|
|
||||||
this.Vy < 0 //moving up
|
|
||||||
) {
|
|
||||||
Matter.Body.setVelocity(player, {
|
|
||||||
//reduce player y-velocity every cycle
|
|
||||||
x: player.velocity.x,
|
|
||||||
y: player.velocity.y * 0.94
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const limit = 125 / player.mass / player.mass
|
|
||||||
if (game.gamepad.leftAxis.x === -1) {
|
|
||||||
if (player.velocity.x > -limit) player.force.x -= this.FxAir; // move player left / a
|
|
||||||
} else if (game.gamepad.leftAxis.x === 1) {
|
|
||||||
if (player.velocity.x < limit) player.force.x += this.FxAir; //move player right / d
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//smoothly move leg height towards height goal
|
|
||||||
this.yOff = this.yOff * 0.85 + this.yOffGoal * 0.15;
|
|
||||||
},
|
|
||||||
alive: true,
|
alive: true,
|
||||||
death() {
|
death() {
|
||||||
if (b.modIsImmortal) { //if player has the immortality buff, spawn on the same level with randomized stats
|
if (b.modIsImmortal) { //if player has the immortality buff, spawn on the same level with randomized stats
|
||||||
@@ -517,7 +461,7 @@ const mech = {
|
|||||||
document.getElementById("dmg").style.opacity = 0.1 + Math.min(0.6, dmg * 4);
|
document.getElementById("dmg").style.opacity = 0.1 + Math.min(0.6, dmg * 4);
|
||||||
|
|
||||||
//chance to build a drone on damage from mod
|
//chance to build a drone on damage from mod
|
||||||
if (b.makeDroneOnDamage) {
|
if (b.isModDroneOnDamage) {
|
||||||
const len = (dmg - 0.08 + 0.05 * Math.random()) / 0.05
|
const len = (dmg - 0.08 + 0.05 * Math.random()) / 0.05
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
if (Math.random() < 0.6) b.guns[13].fire() //spawn drone
|
if (Math.random() < 0.6) b.guns[13].fire() //spawn drone
|
||||||
@@ -730,7 +674,7 @@ const mech = {
|
|||||||
mech.fieldMeter += mech.fieldRegen;
|
mech.fieldMeter += mech.fieldRegen;
|
||||||
ctx.fillStyle = "rgba(0, 0, 0, 0.4)";
|
ctx.fillStyle = "rgba(0, 0, 0, 0.4)";
|
||||||
ctx.fillRect(this.pos.x - this.radius, this.pos.y - 50, range, 10);
|
ctx.fillRect(this.pos.x - this.radius, this.pos.y - 50, range, 10);
|
||||||
ctx.fillStyle = "rgb(50,220,255)";
|
ctx.fillStyle = "#0af";
|
||||||
ctx.fillRect(this.pos.x - this.radius, this.pos.y - 50, range * this.fieldMeter, 10);
|
ctx.fillRect(this.pos.x - this.radius, this.pos.y - 50, range * this.fieldMeter, 10);
|
||||||
} else {
|
} else {
|
||||||
mech.fieldMeter = 1
|
mech.fieldMeter = 1
|
||||||
@@ -1071,7 +1015,7 @@ const mech = {
|
|||||||
hold() {},
|
hold() {},
|
||||||
fieldText() {
|
fieldText() {
|
||||||
game.replaceTextLog = true;
|
game.replaceTextLog = true;
|
||||||
game.makeTextLog(`<div class="circle field "></div> <strong style='font-size:30px;'>${mech.fieldUpgrades[mech.fieldMode].name}</strong><br><span class='faded'>(right click or space bar)</span><br><br>${mech.fieldUpgrades[mech.fieldMode].description}`, 1000);
|
game.makeTextLog(`${game.SVGrightMouse}<strong style='font-size:30px;'> ${mech.fieldUpgrades[mech.fieldMode].name}</strong><br><span class='faded'></span><br>${mech.fieldUpgrades[mech.fieldMode].description}`, 1000);
|
||||||
game.replaceTextLog = false;
|
game.replaceTextLog = false;
|
||||||
document.getElementById("field").innerHTML = mech.fieldUpgrades[mech.fieldMode].name //add field
|
document.getElementById("field").innerHTML = mech.fieldUpgrades[mech.fieldMode].name //add field
|
||||||
},
|
},
|
||||||
@@ -1179,13 +1123,13 @@ const mech = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "plasma torch",
|
name: "plasma torch",
|
||||||
description: "field emits a beam of destructive <span style='color:#f0f;'>ionized gas</span><br><span style='color:#a00;'>decreased</span> <strong style='color: #08f;'>shield</strong> range and efficiency",
|
description: "field emits a beam of destructive <span style='color:#f0f;'>ionized gas</span><br><span style='color:#a00;'>decreased</span> <strong class='color-f'>shield</strong> range and efficiency",
|
||||||
effect: () => {
|
effect: () => {
|
||||||
mech.fieldMode = 2;
|
mech.fieldMode = 2;
|
||||||
mech.fieldText();
|
mech.fieldText();
|
||||||
mech.setHoldDefaults();
|
mech.setHoldDefaults();
|
||||||
// mech.fieldShieldingScale = 2;
|
// mech.fieldShieldingScale = 2;
|
||||||
mech.grabRange = 125;
|
// mech.grabRange = 125;
|
||||||
mech.fieldArc = 0.05 //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
|
mech.fieldArc = 0.05 //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
|
||||||
mech.calculateFieldThreshold(); //run after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
|
mech.calculateFieldThreshold(); //run after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
|
||||||
mech.hold = function () {
|
mech.hold = function () {
|
||||||
@@ -1346,13 +1290,12 @@ const mech = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "negative mass field",
|
name: "negative mass field",
|
||||||
description: "field nullifies <strong style='letter-spacing: 15px;'>gravity</strong><br> player can hold more massive objects<br><em>can fire while field is active</em>",
|
description: "field nullifies <strong style='letter-spacing: 15px;'>gravity</strong><br><em>can fire while field is active</em>",
|
||||||
effect: () => {
|
effect: () => {
|
||||||
mech.fieldMode = 3;
|
mech.fieldMode = 3;
|
||||||
mech.fieldText();
|
mech.fieldText();
|
||||||
mech.setHoldDefaults();
|
mech.setHoldDefaults();
|
||||||
mech.fieldFire = true;
|
mech.fieldFire = true;
|
||||||
mech.holdingMassScale = 0.05; //can hold heavier blocks with lower cost to jumping
|
|
||||||
|
|
||||||
mech.hold = function () {
|
mech.hold = function () {
|
||||||
if (mech.isHolding) {
|
if (mech.isHolding) {
|
||||||
@@ -1434,7 +1377,7 @@ const mech = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "standing wave harmonics",
|
name: "standing wave harmonics",
|
||||||
description: "you are surrounded by oscillating <strong style='color: #08f;'>shields</strong><br> <span style='color:#a00;'>decreased</span> field regeneration",
|
description: "you are surrounded by oscillating <strong class='color-f'>shields</strong><br> <span style='color:#a00;'>decreased</span> field regeneration",
|
||||||
effect: () => {
|
effect: () => {
|
||||||
mech.fieldMode = 4;
|
mech.fieldMode = 4;
|
||||||
mech.fieldText();
|
mech.fieldText();
|
||||||
@@ -1479,7 +1422,7 @@ const mech = {
|
|||||||
name: "nano-scale manufacturing",
|
name: "nano-scale manufacturing",
|
||||||
description: "excess field <span class='color-f'>energy</span> used to build <strong class='color-b'>drones</strong><br> increased <span class='color-f'>energy</span> regeneration",
|
description: "excess field <span class='color-f'>energy</span> used to build <strong class='color-b'>drones</strong><br> increased <span class='color-f'>energy</span> regeneration",
|
||||||
effect: () => {
|
effect: () => {
|
||||||
let gunIndex = Math.random() < 0.5 ? 13 : 14
|
let gunIndex = 13 //Math.random() < 0.5 ? 13 : 14
|
||||||
mech.fieldMode = 5;
|
mech.fieldMode = 5;
|
||||||
mech.fieldText();
|
mech.fieldText();
|
||||||
mech.setHoldDefaults();
|
mech.setHoldDefaults();
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ const powerUps = {
|
|||||||
},
|
},
|
||||||
effect() {
|
effect() {
|
||||||
let heal = (this.size / 40) ** 2
|
let heal = (this.size / 40) ** 2
|
||||||
if (b.fullHeal) heal = Infinity
|
if (b.isModFullHeal) heal = Infinity
|
||||||
heal = Math.min(1 - mech.health, heal)
|
heal = Math.min(1 - mech.health, heal)
|
||||||
mech.addHealth(heal);
|
mech.addHealth(heal);
|
||||||
if (heal > 0) game.makeTextLog("<span style='font-size:115%;'> <strong class='color-h' style = 'letter-spacing: 2px;'>heal</strong> " + (heal * 100).toFixed(0) + "%</span>", 300)
|
if (heal > 0) game.makeTextLog("<div class='circle heal'></div> <span style='font-size:115%;'> <strong style = 'letter-spacing: 2px;'>heal</strong> " + (heal * 100).toFixed(0) + "%</span>", 300)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ammo: {
|
ammo: {
|
||||||
@@ -48,13 +48,13 @@ const powerUps = {
|
|||||||
const ammo = Math.ceil((target.ammoPack * (0.45 + 0.08 * Math.random())) / b.dmgScale);
|
const ammo = Math.ceil((target.ammoPack * (0.45 + 0.08 * Math.random())) / b.dmgScale);
|
||||||
target.ammo += ammo;
|
target.ammo += ammo;
|
||||||
game.updateGunHUD();
|
game.updateGunHUD();
|
||||||
game.makeTextLog("<span style='font-size:110%;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
|
game.makeTextLog("<div class='circle gun'></div> <span style='font-size:110%;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
field: {
|
field: {
|
||||||
name: "field",
|
name: "field",
|
||||||
color: "#0bf",
|
color: "#0af",
|
||||||
size() {
|
size() {
|
||||||
return 45;
|
return 45;
|
||||||
},
|
},
|
||||||
@@ -124,7 +124,7 @@ const powerUps = {
|
|||||||
if (options.length > 0) {
|
if (options.length > 0) {
|
||||||
let newGun = options[Math.floor(Math.random() * options.length)];
|
let newGun = options[Math.floor(Math.random() * options.length)];
|
||||||
if (b.activeGun === null) b.activeGun = newGun //if no active gun switch to new gun
|
if (b.activeGun === null) b.activeGun = newGun //if no active gun switch to new gun
|
||||||
game.makeTextLog(`<div class="circle gun "></div> <strong style='font-size:30px;'>${b.guns[newGun].name}</strong><br><span class='faded'>(left click)</span><br><br>${b.guns[newGun].description}`, 900);
|
game.makeTextLog(`${game.SVGleftMouse} <strong style='font-size:30px;'>${b.guns[newGun].name}</strong><br><br>${b.guns[newGun].description}`, 900);
|
||||||
b.guns[newGun].have = true;
|
b.guns[newGun].have = true;
|
||||||
b.inventory.push(newGun);
|
b.inventory.push(newGun);
|
||||||
b.guns[newGun].ammo += b.guns[newGun].ammoPack * 2;
|
b.guns[newGun].ammo += b.guns[newGun].ammoPack * 2;
|
||||||
|
|||||||
10
js/spawn.js
10
js/spawn.js
@@ -457,7 +457,7 @@ const spawn = {
|
|||||||
this.healthBar();
|
this.healthBar();
|
||||||
//when player is inside event horizon
|
//when player is inside event horizon
|
||||||
if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon) {
|
if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon) {
|
||||||
if (!b.AoEImmunity) {
|
if (!b.isModAoEImmunity) {
|
||||||
mech.damage(0.00015 * game.dmgScale);
|
mech.damage(0.00015 * game.dmgScale);
|
||||||
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01
|
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01
|
||||||
}
|
}
|
||||||
@@ -548,7 +548,7 @@ const spawn = {
|
|||||||
ctx.fill();
|
ctx.fill();
|
||||||
//when player is inside event horizon
|
//when player is inside event horizon
|
||||||
if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon) {
|
if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon) {
|
||||||
if (!b.AoEImmunity) {
|
if (!b.isModAoEImmunity) {
|
||||||
mech.damage(0.00015 * game.dmgScale);
|
mech.damage(0.00015 * game.dmgScale);
|
||||||
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01
|
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01
|
||||||
}
|
}
|
||||||
@@ -680,14 +680,14 @@ const spawn = {
|
|||||||
this.laser();
|
this.laser();
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
striker(x, y, radius = 15 + Math.ceil(Math.random() * 25)) {
|
striker(x, y, radius = 14 + Math.ceil(Math.random() * 25)) {
|
||||||
mobs.spawn(x, y, 5, radius, "rgb(221,102,119)");
|
mobs.spawn(x, y, 5, radius, "rgb(221,102,119)");
|
||||||
let me = mob[mob.length - 1];
|
let me = mob[mob.length - 1];
|
||||||
me.accelMag = 0.0004 * game.accelScale;
|
me.accelMag = 0.0003 * game.accelScale;
|
||||||
me.g = 0.0002; //required if using 'gravity'
|
me.g = 0.0002; //required if using 'gravity'
|
||||||
me.frictionStatic = 0;
|
me.frictionStatic = 0;
|
||||||
me.friction = 0;
|
me.friction = 0;
|
||||||
me.delay = 90;
|
me.delay = 100;
|
||||||
Matter.Body.rotate(me, Math.PI * 0.1);
|
Matter.Body.rotate(me, Math.PI * 0.1);
|
||||||
me.onDamage = function () {
|
me.onDamage = function () {
|
||||||
this.cd = game.cycle + this.delay;
|
this.cd = game.cycle + this.delay;
|
||||||
|
|||||||
56
style.css
56
style.css
@@ -208,8 +208,12 @@ em {
|
|||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mouse-icon {
|
||||||
|
margin-bottom: -20px;
|
||||||
|
}
|
||||||
|
|
||||||
.color-f {
|
.color-f {
|
||||||
color: #0bf;
|
color: #0af;
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-b {
|
.color-b {
|
||||||
@@ -255,7 +259,7 @@ em {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.field {
|
.field {
|
||||||
background: #0bf;
|
background: #0af;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mod {
|
.mod {
|
||||||
@@ -264,6 +268,12 @@ em {
|
|||||||
|
|
||||||
.gun {
|
.gun {
|
||||||
background: #149;
|
background: #149;
|
||||||
|
margin-bottom: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heal {
|
||||||
|
background: #0d9;
|
||||||
|
margin-bottom: -2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.box {
|
.box {
|
||||||
@@ -285,48 +295,6 @@ em {
|
|||||||
justify-self: center;
|
justify-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mouse {
|
|
||||||
color: #ccc;
|
|
||||||
position: relative;
|
|
||||||
padding: 37px 30px 37px 30px;
|
|
||||||
border-radius: 25px;
|
|
||||||
border: 2px solid #444;
|
|
||||||
background-color: rgba(255, 255, 255, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.mouse:after {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
z-index: 1;
|
|
||||||
top: 4px;
|
|
||||||
left: 26px;
|
|
||||||
border-radius: 25px;
|
|
||||||
/* background: #444; */
|
|
||||||
border: 2px solid #444;
|
|
||||||
|
|
||||||
width: 4px;
|
|
||||||
height: 20px;
|
|
||||||
border-radius: 10px / 25px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mouse-line {
|
|
||||||
position: relative;
|
|
||||||
top: 30px;
|
|
||||||
left: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mouse-line:after {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
z-index: 1;
|
|
||||||
top: -35px;
|
|
||||||
left: -30px;
|
|
||||||
width: 60px;
|
|
||||||
height: 2px;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #444;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right {
|
.right {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user