field damamge graphics

This commit is contained in:
landgreen
2020-01-14 05:50:52 -08:00
parent 63304bcac4
commit bdbae2a224
3 changed files with 21 additions and 4 deletions

View File

@@ -218,7 +218,7 @@ const b = {
maxCount: 4,
count: 0,
effect() {
b.modBlockDmg += 0.7
b.modBlockDmg += 0.7 //if you change this value also update the for loop in the electricity graphics in mech.pushMass
}
},
{
@@ -722,6 +722,7 @@ const b = {
bullet[bIndex] = Bodies.rectangle(where.x, where.y, 45 * b.modBulletSize, 16 * b.modBulletSize, {
angle: angle,
friction: 1,
frictionStatic: 1,
frictionAir: 0,
restitution: 0,
dmg: 0, //damage done in addition to the damage from momentum

View File

@@ -14,9 +14,9 @@ const level = {
start() {
if (level.levelsCleared === 0) {
// game.difficulty = 6; //for testing to simulate possible mobs spawns
// b.giveGuns(9)
// b.giveGuns(10)
// mech.setField(3)
// b.giveMod(3);
// b.giveMod(13);
level.intro(); //starting level
// level.testingMap();

View File

@@ -901,11 +901,27 @@ const mech = {
mech.drawHold(who);
mech.fieldCDcycle = mech.cycle + 10;
mech.holdingTarget = null
const unit = Vector.normalise(Vector.sub(player.position, who.position))
if (b.modBlockDmg) {
who.damage(b.modBlockDmg)
//draw electricity
const step = mech.grabRange / 5
ctx.beginPath();
for (let i = 0, len = 2 * b.modBlockDmg / 0.7; i < len; i++) {
let x = mech.pos.x - 20 * unit.x;
let y = mech.pos.y - 20 * unit.y;
ctx.moveTo(x, y);
for (let i = 0; i < 8; i++) {
x += step * (-unit.x + 1.5 * (Math.random() - 0.5))
y += step * (-unit.y + 1.5 * (Math.random() - 0.5))
ctx.lineTo(x, y);
}
}
ctx.lineWidth = 2.5;
ctx.strokeStyle = "#f0f";
ctx.stroke();
}
//knock backs
const unit = Vector.normalise(Vector.sub(player.position, who.position))
const massRoot = Math.sqrt(Math.min(12, Math.max(0.15, who.mass))); // masses above 12 can start to overcome the push back
Matter.Body.setVelocity(who, {
x: player.velocity.x - (15 * unit.x) / massRoot,