diagetic field meter indication, curvy field

This commit is contained in:
landgreen
2019-11-04 06:03:49 -08:00
parent ed993eea21
commit 9d15f99503
6 changed files with 49 additions and 21 deletions

View File

@@ -1003,12 +1003,14 @@ const b = {
suck(body)
suck(mob)
suck(powerUp)
suck(bullet)
suck([player])
} else {
mag = 0.1
suck(body)
suck(mob)
suck(powerUp)
suck(bullet)
suck([player])
}
//keep bomb in place

View File

@@ -2,6 +2,8 @@
/* TODO: *******************************************
*****************************************************
add a key that player picks up and needs to set on the exit door to open it
add Boss levels

View File

@@ -663,7 +663,10 @@ const level = {
spawn.bodyRect(4700, -350, 50, 200, 0.9);
spawn.bodyRect(4900, -100, 300, 300, 0.7);
spawn.boost(5350, 275, 2850);
spawn.mapRect(6050, -700, 600, 1200);
// spawn.mapRect(6050, -700, 450, 1200);
spawn.mapRect(6050, -1060, 450, 1560);
spawn.mapVertex(6275, -2100, "0 0 450 0 300 -2500 150 -2500")
//right tall tower
spawn.mapRect(3700, -3200, 100, 800);
spawn.mapRect(4700, -2910, 100, 510);

View File

@@ -374,7 +374,8 @@ const mech = {
}
function randomizeHealth() {
mech.health = 0.5 + 1 * Math.random()
mech.health = 0.5 + Math.random()
if (mech.health > 1) mech.health = 1;
mech.displayHealth();
}
@@ -720,22 +721,37 @@ const mech = {
//draw field
const range = this.grabRange - 20;
ctx.beginPath();
ctx.arc(this.pos.x, this.pos.y, range, this.angle - Math.PI * this.fieldArc, this.angle + Math.PI * this.fieldArc, false);
ctx.arc(mech.pos.x, mech.pos.y, range, mech.angle - Math.PI * mech.fieldArc, mech.angle + Math.PI * mech.fieldArc, false);
ctx.strokeStyle = "#9bd" //"rgba(110, 200, 235, " + (0.5 + 0.1 * Math.random()) + ")"
ctx.lineWidth = 2;
ctx.lineCap = "butt"
ctx.stroke();
let eye = 13;
ctx.lineTo(mech.pos.x + eye * Math.cos(this.angle), mech.pos.y + eye * Math.sin(this.angle));
if (this.holdingTarget) {
ctx.fillStyle = "rgba(110,170,200," + (0.05 + 0.1 * Math.random()) + ")";
let aMag = 0.75 * Math.PI * mech.fieldArc
let a = mech.angle + aMag
let cp1x = mech.pos.x + 0.6 * range * Math.cos(a)
let cp1y = mech.pos.y + 0.6 * range * Math.sin(a)
ctx.quadraticCurveTo(cp1x, cp1y, mech.pos.x + eye * Math.cos(mech.angle), mech.pos.y + eye * Math.sin(mech.angle))
a = mech.angle - aMag
cp1x = mech.pos.x + 0.6 * range * Math.cos(a)
cp1y = mech.pos.y + 0.6 * range * Math.sin(a)
ctx.quadraticCurveTo(cp1x, cp1y, mech.pos.x + 1 * range * Math.cos(mech.angle - Math.PI * mech.fieldArc), mech.pos.y + 1 * range * Math.sin(mech.angle - Math.PI * mech.fieldArc))
// ctx.lineTo(mech.pos.x + eye * Math.cos(mech.angle), mech.pos.y + eye * Math.sin(mech.angle));
if (mech.holdingTarget) {
ctx.fillStyle = "rgba(110,170,200," + (0.02 + mech.fieldMeter * (0.1 + 0.05 * Math.random())) + ")";
} else {
ctx.fillStyle = "rgba(110,170,200," + (0.15 + 0.15 * Math.random()) + ")";
ctx.fillStyle = "rgba(110,170,200," + (0.07 + mech.fieldMeter * (0.2 + 0.15 * Math.random())) + ")";
}
ctx.fill();
//draw random lines in field for cool effect
let offAngle = this.angle + 2 * Math.PI * this.fieldArc * (Math.random() - 0.5);
let offAngle = mech.angle + 1.7 * Math.PI * mech.fieldArc * (Math.random() - 0.5);
ctx.beginPath();
eye = 15;
ctx.moveTo(mech.pos.x + eye * Math.cos(this.angle), mech.pos.y + eye * Math.sin(this.angle));
ctx.lineTo(this.pos.x + range * Math.cos(offAngle), this.pos.y + range * Math.sin(offAngle));
ctx.strokeStyle = "rgba(120,170,255,0.4)";
ctx.moveTo(mech.pos.x + eye * Math.cos(mech.angle), mech.pos.y + eye * Math.sin(mech.angle));
ctx.lineTo(mech.pos.x + range * Math.cos(offAngle), mech.pos.y + range * Math.sin(offAngle));
ctx.strokeStyle = "rgba(120,170,255,0.6)";
ctx.lineWidth = 1;
ctx.stroke();
},
@@ -944,7 +960,7 @@ const mech = {
},
{
name: "time dilation field",
description: "<strong style='letter-spacing: 6px;'>stop time</strong>&nbsp; while field is active<br> <em>can fire while field is active</em>",
description: "<strong style='letter-spacing: 3px;'>stop time</strong> while field is active<br> <em>can fire while field is active</em>",
effect: () => {
mech.fieldMode = 1;
mech.fieldText();
@@ -1059,10 +1075,12 @@ const mech = {
ctx.arc(mech.pos.x, mech.pos.y, range, mech.angle - arc, mech.angle + arc, false);
ctx.lineTo(mech.pos.x + 13 * Math.cos(mech.angle), mech.pos.y + 13 * Math.sin(mech.angle));
if (mech.holdingTarget) {
ctx.fillStyle = "rgba(255,50,150," + (0.05 + 0.1 * Math.random()) + ")";
ctx.fillStyle = "rgba(255,50,150," + (0.01 + mech.fieldMeter * (0.1 + 0.1 * Math.random())) + ")";
} else {
ctx.fillStyle = "rgba(255,50,150," + (0.13 + 0.18 * Math.random()) + ")";
ctx.fillStyle = "rgba(255,50,150," + (0.02 + mech.fieldMeter * (0.18 + 0.18 * Math.random())) + ")";
}
// ctx.fillStyle = "rgba(110,170,200," + (0.02 + mech.fieldMeter * (0.08 + 0.1 * Math.random())) + ")";
// ctx.fillStyle = "rgba(110,170,200," + (0.06 + mech.fieldMeter * (0.1 + 0.18 * Math.random())) + ")";
ctx.fill();
//draw random lines in field for cool effect
@@ -1088,7 +1106,7 @@ const mech = {
},
{
name: "negative mass field",
description: "field nullifies &nbsp;<strong style='letter-spacing: 6px;'>gravity</strong><br> player can hold more massive objects<br><em>can fire while field is active</em>",
description: "field nullifies &nbsp;<strong style='letter-spacing: 15px;'>gravity</strong><br> player can hold more massive objects<br><em>can fire while field is active</em>",
effect: () => {
mech.fieldMode = 3;
mech.fieldText();
@@ -1201,7 +1219,7 @@ const mech = {
const grabRange2 = 85 + 70 * Math.sin(mech.cycle / 37)
const grabRange3 = 80 + 80 * Math.sin(mech.cycle / 47)
const netGrabRange = Math.max(grabRange1, grabRange2, grabRange3)
ctx.fillStyle = "rgba(110,170,200," + (0.15 + 0.15 * Math.random()) + ")";
ctx.fillStyle = "rgba(110,170,200," + (0.04 + mech.fieldMeter * (0.12 + 0.13 * Math.random())) + ")";
ctx.beginPath();
ctx.arc(mech.pos.x, mech.pos.y, grabRange1, 0, 2 * Math.PI);
ctx.fill();
@@ -1272,7 +1290,7 @@ const mech = {
player.collisionFilter.mask = 0x000001 //0x010011 is normals
ctx.beginPath();
ctx.arc(mech.pos.x, mech.pos.y, mech.grabRange, 0, 2 * Math.PI);
ctx.arc(mech.pos.x, mech.pos.y, mech.grabRange / (0.3 + 0.7 * mech.fieldMeter), 0, 2 * Math.PI);
ctx.globalCompositeOperation = "destination-in"; //in or atop
ctx.fillStyle = "rgba(255,255,255,0.25)";
ctx.fill();

View File

@@ -11,7 +11,7 @@ const powerUps = {
let heal = (this.size / 40) ** 2
heal = Math.min(1 - mech.health, heal)
mech.addHealth(heal);
if (!game.lastLogTime && heal > 0) game.makeTextLog("<span style='font-size:150;'> <span class='color-h'>heal</span> " + (heal * 100).toFixed(0) + "%</span>", 300)
if (!game.lastLogTime && heal > 0) game.makeTextLog("<span style='font-size:220;'> <span class='color-h'>heal</span> " + (heal * 100).toFixed(0) + "%</span>", 300)
}
},
ammo: {
@@ -41,13 +41,13 @@ const powerUps = {
}
if (target.ammo === Infinity) {
mech.fieldMeter = 1;
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:150;'><span class='color-f'>+energy</span></span>", 300);
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:200;'><span class='color-f'>+energy</span></span>", 300);
} else {
//ammo given scales as mobs take more hits to kill
const ammo = Math.ceil((target.ammoPack * (0.6 + 0.04 * Math.random())) / b.dmgScale);
target.ammo += ammo;
game.updateGunHUD();
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:150;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:200;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
}
}
},
@@ -129,7 +129,7 @@ const powerUps = {
const ammo = Math.ceil(b.guns[ammoTarget].ammoPack * 2);
b.guns[ammoTarget].ammo += ammo;
game.updateGunHUD();
game.makeTextLog("<span style='font-size:150;'>+" + ammo + " ammo for " + b.guns[ammoTarget].name + "</span>", 300);
game.makeTextLog("<span style='font-size:200;'>+" + ammo + " ammo for " + b.guns[ammoTarget].name + "</span>", 300);
}
}
},