n-gon phase graphics

n-gon phase graphics
timeskipBoss written
build sharing with URL variables
This commit is contained in:
landgreen
2020-04-02 12:54:28 -07:00
parent b52f5f7748
commit 26fbb7bad6
7 changed files with 231 additions and 99 deletions

View File

@@ -1584,7 +1584,7 @@ const mech = {
zeroG(powerUp, this.fieldDrawRadius);
zeroG(body, this.fieldDrawRadius);
}
if (mech.energy < 0) {
if (mech.energy < 0.001) {
mech.fieldCDcycle = mech.cycle + 120;
mech.energy = 0;
}
@@ -1761,57 +1761,66 @@ const mech = {
mech.grabPowerUp();
mech.lookForPickUp();
const DRAIN = 0.0001 + 0.00017 * player.speed
const DRAIN = 0.00004 + 0.00009 * player.speed
if (mech.energy > DRAIN) {
mech.energy -= DRAIN;
if (mech.energy < 0) {
if (mech.energy < 0.001) {
mech.fieldCDcycle = mech.cycle + 120;
mech.energy = 0;
}
mech.isStealth = true //isStealth disables most uses of foundPlayer()
player.collisionFilter.mask = cat.map
ctx.beginPath();
ctx.arc(mech.pos.x, mech.pos.y, mech.fieldRange, 0, 2 * Math.PI);
ctx.globalCompositeOperation = "destination-in"; //in or atop
ctx.fillStyle = `rgba(255,255,255,${mech.energy*0.5})`;
ctx.fill();
ctx.globalCompositeOperation = "source-over";
ctx.strokeStyle = "#000"
ctx.lineWidth = 2;
ctx.stroke();
if (!game.isTimeSkipping) {
// game.timeSkip(1)
const drawRadius = 125
ctx.beginPath();
ctx.arc(mech.pos.x, mech.pos.y, drawRadius, 0, 2 * Math.PI);
ctx.fillStyle = `rgba(255,255,255,${mech.energy*0.5})`;
ctx.globalCompositeOperation = "destination-in"; //in or atop
ctx.fill();
ctx.globalCompositeOperation = "source-over";
ctx.strokeStyle = "#000"
ctx.lineWidth = 2;
ctx.stroke();
ctx.beginPath();
ctx.arc(mech.pos.x, mech.pos.y, drawRadius, 0, 2 * Math.PI);
ctx.clip();
let inPlayer = Matter.Query.region(mob, player.bounds)
if (inPlayer.length > 0) {
for (let i = 0; i < inPlayer.length; i++) {
if (inPlayer[i].shield) {
mech.energy -= 0.005; //shields drain player energy
//draw outline of shield
ctx.fillStyle = `rgba(0, 204, 255,0.6)`
ctx.fill()
} else if (b.isModPhaseFieldDamage && mech.energy > 0.006 && inPlayer[i].dropPowerUp && !inPlayer[i].isShielded) {
inPlayer[i].damage(0.4 * b.dmgScale); //damage mobs inside the player
mech.energy -= 0.002;
//draw outline of mob in a few random locations to show blurriness
const vertices = inPlayer[i].vertices;
const off = 30
for (let k = 0; k < 3; k++) {
const xOff = off * (Math.random() - 0.5)
const yOff = off * (Math.random() - 0.5)
ctx.beginPath();
ctx.moveTo(xOff + vertices[0].x, yOff + vertices[0].y);
for (let j = 1, len = vertices.length; j < len; ++j) {
ctx.lineTo(xOff + vertices[j].x, yOff + vertices[j].y);
}
ctx.lineTo(xOff + vertices[0].x, yOff + vertices[0].y);
// ctx.strokeStyle = "#000"
// ctx.lineWidth = 1
// ctx.stroke()
ctx.fillStyle = "rgba(0,0,0,0.3)"
let inPlayer = Matter.Query.region(mob, player.bounds)
if (inPlayer.length > 0) {
for (let i = 0; i < inPlayer.length; i++) {
if (inPlayer[i].shield) {
mech.energy -= 0.005; //shields drain player energy
//draw outline of shield
ctx.fillStyle = `rgba(0, 204, 255,0.6)`
ctx.fill()
} else if (b.isModPhaseFieldDamage && mech.energy > 0.006 && inPlayer[i].dropPowerUp && !inPlayer[i].isShielded) {
inPlayer[i].damage(0.4 * b.dmgScale); //damage mobs inside the player
mech.energy -= 0.002;
//draw outline of mob in a few random locations to show blurriness
const vertices = inPlayer[i].vertices;
const off = 30
for (let k = 0; k < 3; k++) {
const xOff = off * (Math.random() - 0.5)
const yOff = off * (Math.random() - 0.5)
ctx.beginPath();
ctx.moveTo(xOff + vertices[0].x, yOff + vertices[0].y);
for (let j = 1, len = vertices.length; j < len; ++j) {
ctx.lineTo(xOff + vertices[j].x, yOff + vertices[j].y);
}
ctx.lineTo(xOff + vertices[0].x, yOff + vertices[0].y);
// ctx.strokeStyle = "#000"
// ctx.lineWidth = 1
// ctx.stroke()
ctx.fillStyle = "rgba(0,0,0,0.3)"
ctx.fill()
}
break;
}
break;
}
}
}