moving files to different computer

reworked focuser mobs to fire blue energy draining laser instead of charging player
This commit is contained in:
landgreen
2024-11-29 18:47:49 -08:00
parent 97c5509278
commit 1966173f88
3 changed files with 142 additions and 129 deletions

View File

@@ -60,12 +60,12 @@ const level = {
// for (let i = 0; i < 1; i++) powerUps.directSpawn(450, -50, "warp");
// for (let i = 0; i < 7; i++) powerUps.directSpawn(m.pos.x + 200, m.pos.y - 250, "research", false);
// spawn.bodyRect(575, -700, 150, 150); //block mob line of site on testing
// level.substructure();
// level.cocoon();
level[simulation.isTraining ? "walk" : "initial"]() //normal starting level **************************************************
// for (let i = 0; i < 5; ++i) spawn.sneaker(1900, -500)
// for (let i = 0; i < 1; ++i) spawn.shieldingBoss(1900, -500)
// for (let i = 0; i < 1; i++) spawn.mantisBoss(1900, -500)
// for (let i = 0; i < 1; ++i) powerUps.directSpawn(m.pos.x + 50 * Math.random(), m.pos.y + 50 * Math.random(), "entanglement");
@@ -3093,8 +3093,9 @@ const level = {
// ctx.font = "50px Arial";
// ctx.fillStyle = "rgba(0,0,0,0.3)"
// for (let i = 0; i < 5; i++) {
// const wiggle = 10
// const wiggle = 2
// ctx.fillText("move", 500 + wiggle * Math.random(), -500 + wiggle * Math.random());
// ctx.fillText("move", 500, -400);
// }
//push around power ups stuck in the tube wall
@@ -8154,6 +8155,46 @@ const level = {
powerUps.directSpawn(2100, 925, "heal");
powerUps.directSpawn(625, -100, "heal");
},
cocoon() {
// simulation.fallHeight = 4000
level.announceMobTypes()
level.setPosToSpawn(-3800, 950);
level.exit.x = 3750
level.exit.y = -625
level.defaultZoom = 2000
simulation.zoomTransition(level.defaultZoom)
document.body.style.backgroundColor = "#d0d5d5";
color.map = "#444"
level.custom = () => {
level.exit.drawAndCheck();
level.enter.draw();
};
level.customTopLayer = () => {
ctx.fillStyle = "rgba(0,255,255,0.1)" //"#d4f4f4" //exit
ctx.fillRect(3535, -1050, 500, 475);
//shadows
ctx.fillStyle = "rgba(0,20,60,0.09)"
// ctx.fillRect(-4025, -1050, 1750, 2275);
};
//boxes center on zero,zero with deep walls to hide background
spawn.mapRect(4000, -2000, 2000, 4000); //right map wall
spawn.mapRect(-6000, -2000, 2000, 4000); //left map wall
spawn.mapRect(-6000, -4000, 12000, 3000); //map ceiling
spawn.mapRect(-6000, 1000, 12000, 3000); //floor
// spawn.randomMob(2825, 75, 0.9);
// spawn.randomLevelBoss(2400, 600);
// spawn.secondaryBossChance(800, -300)
// powerUps.spawnStartingPowerUps(600, 375);
// powerUps.addResearchToLevel() //needs to run after mobs are spawned
},
lock() {
level.announceMobTypes()
level.setPosToSpawn(0, -65); //lower start

View File

@@ -3089,28 +3089,32 @@ const spawn = {
if (this.seePlayer.yes && dist2 < 4000000) {
const rangeWidth = 2000; //this is sqrt of 4000000 from above if()
//targeting laser will slowly move from the mob to the player's position
this.laserPos = Vector.add(this.laserPos, Vector.mult(Vector.sub(player.position, this.laserPos), 0.1));
this.laserPos = Vector.add(this.laserPos, Vector.mult(Vector.sub(player.position, this.laserPos), 0.03));
let targetDist = Vector.magnitude(Vector.sub(this.laserPos, m.pos));
const r = 12;
ctx.beginPath();
ctx.moveTo(this.position.x, this.position.y);
if (targetDist < r + 16) {
targetDist = r + 10;
//charge at player
const forceMag = this.accelMag * 40 * this.mass;
const angle = Math.atan2(this.seePlayer.position.y - this.position.y, this.seePlayer.position.x - this.position.x);
this.force.x += forceMag * Math.cos(angle);
this.force.y += forceMag * Math.sin(angle);
}
// else {
//high friction if can't lock onto player
// Matter.Body.setVelocity(this, {
// x: this.velocity.x * 0.98,
// y: this.velocity.y * 0.98
// });
// }
if (dist2 > 80000) {
const laserWidth = 0.002;
if (m.immuneCycle < m.cycle) {
m.damage(0.0003 * simulation.dmgScale);
if (m.energy > 0.1) m.energy -= 0.003
}
ctx.beginPath();
ctx.moveTo(this.position.x, this.position.y);
ctx.lineTo(m.pos.x, m.pos.y);
ctx.lineTo(m.pos.x + (Math.random() - 0.5) * 3000, m.pos.y + (Math.random() - 0.5) * 3000);
ctx.lineWidth = 2;
ctx.strokeStyle = "rgb(0,0,255)";
ctx.setLineDash([125 * Math.random(), 125 * Math.random()]);
ctx.stroke();
ctx.setLineDash([]);
ctx.beginPath();
ctx.arc(m.pos.x, m.pos.y, 40, 0, 2 * Math.PI);
ctx.fillStyle = "rgba(0,0,255,0.1)";
ctx.fill();
} else {
const laserWidth = 0.0005;
let laserOffR = Vector.rotateAbout(this.laserPos, (targetDist - r) * laserWidth, this.position);
let sub = Vector.normalise(Vector.sub(laserOffR, this.position));
laserOffR = Vector.add(laserOffR, Vector.mult(sub, rangeWidth));
@@ -3120,7 +3124,7 @@ const spawn = {
sub = Vector.normalise(Vector.sub(laserOffL, this.position));
laserOffL = Vector.add(laserOffL, Vector.mult(sub, rangeWidth));
ctx.lineTo(laserOffL.x, laserOffL.y);
ctx.fillStyle = `rgba(0,0,255,${Math.max(0, 0.3 * r / targetDist)})`
ctx.fillStyle = `rgba(0,0,255,${Math.max(0, 0.6 * r / targetDist)})`
ctx.fill();
}
} else {
@@ -3128,6 +3132,69 @@ const spawn = {
}
}
},
// focuser(x, y, radius = 30 + Math.ceil(Math.random() * 10)) {
// radius = Math.ceil(radius * 0.7);
// mobs.spawn(x, y, 4, radius, "rgb(0,0,255)");
// let me = mob[mob.length - 1];
// Matter.Body.setDensity(me, 0.003); //extra dense //normal is 0.001
// me.restitution = 0;
// me.laserPos = me.position; //required for laserTracking
// me.repulsionRange = 1200000; //squared
// me.accelMag = 0.00009 * simulation.accelScale;
// me.frictionStatic = 0;
// me.friction = 0;
// me.onDamage = function () {
// this.laserPos = this.position;
// };
// spawn.shield(me, x, y);
// me.do = function () {
// this.seePlayerByLookingAt();
// this.checkStatus();
// this.attraction();
// const dist2 = this.distanceToPlayer2();
// //laser Tracking
// if (this.seePlayer.yes && dist2 < 4000000) {
// const rangeWidth = 2000; //this is sqrt of 4000000 from above if()
// //targeting laser will slowly move from the mob to the player's position
// this.laserPos = Vector.add(this.laserPos, Vector.mult(Vector.sub(player.position, this.laserPos), 0.1));
// let targetDist = Vector.magnitude(Vector.sub(this.laserPos, m.pos));
// const r = 12;
// ctx.beginPath();
// ctx.moveTo(this.position.x, this.position.y);
// if (targetDist < r + 16) {
// targetDist = r + 10;
// //charge at player
// const forceMag = this.accelMag * 40 * this.mass;
// const angle = Math.atan2(this.seePlayer.position.y - this.position.y, this.seePlayer.position.x - this.position.x);
// this.force.x += forceMag * Math.cos(angle);
// this.force.y += forceMag * Math.sin(angle);
// }
// // else {
// //high friction if can't lock onto player
// // Matter.Body.setVelocity(this, {
// // x: this.velocity.x * 0.98,
// // y: this.velocity.y * 0.98
// // });
// // }
// if (dist2 > 80000) {
// const laserWidth = 0.002;
// let laserOffR = Vector.rotateAbout(this.laserPos, (targetDist - r) * laserWidth, this.position);
// let sub = Vector.normalise(Vector.sub(laserOffR, this.position));
// laserOffR = Vector.add(laserOffR, Vector.mult(sub, rangeWidth));
// ctx.lineTo(laserOffR.x, laserOffR.y);
// let laserOffL = Vector.rotateAbout(this.laserPos, (targetDist - r) * -laserWidth, this.position);
// sub = Vector.normalise(Vector.sub(laserOffL, this.position));
// laserOffL = Vector.add(laserOffL, Vector.mult(sub, rangeWidth));
// ctx.lineTo(laserOffL.x, laserOffL.y);
// ctx.fillStyle = `rgba(0,0,255,${Math.max(0, 0.3 * r / targetDist)})`
// ctx.fill();
// }
// } else {
// this.laserPos = this.position;
// }
// }
// },
flutter(x, y, radius = 20 + 6 * Math.random()) {
mobs.spawn(x, y, 7, radius, '#16576b');
let me = mob[mob.length - 1];