pilot wave damage fix, block colliison rewrite
This commit is contained in:
@@ -296,7 +296,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "scrap bots",
|
||||
description: "<strong>+15%</strong> chance to build a <strong>bot</strong> after killing a mob<br>the bot will follow you until you <strong>exit</strong> the map",
|
||||
description: "<strong>+13%</strong> chance to build a <strong>bot</strong> after killing a mob<br>the bot will follow you until you <strong>exit</strong> the map",
|
||||
maxCount: 6,
|
||||
count: 0,
|
||||
allowed() {
|
||||
@@ -304,7 +304,7 @@ const b = {
|
||||
},
|
||||
requires: "",
|
||||
effect() {
|
||||
b.isModBotSpawner += 0.15;
|
||||
b.isModBotSpawner += 0.13;
|
||||
},
|
||||
remove() {
|
||||
b.isModBotSpawner = 0;
|
||||
|
||||
46
js/engine.js
46
js/engine.js
@@ -95,19 +95,21 @@ function collisionChecks(event) {
|
||||
}
|
||||
}
|
||||
|
||||
function collidePlayer(obj, speedThreshold = 12, massThreshold = 2) {
|
||||
function collidePlayer(obj) {
|
||||
//player dmg from hitting a body
|
||||
if (
|
||||
obj.classType === "body" &&
|
||||
obj.speed > speedThreshold &&
|
||||
obj.mass > massThreshold &&
|
||||
(obj.velocity.y > 0 || player.velocity.y > 0)
|
||||
) {
|
||||
const v = Vector.magnitude(Vector.sub(player.velocity, obj.velocity));
|
||||
if (v > speedThreshold && mech.collisionImmuneCycle < mech.cycle) {
|
||||
if (obj.classType === "body" && mech.collisionImmuneCycle < mech.cycle) {
|
||||
const velocityThreshold = 13
|
||||
if (player.position.y > obj.position.y) { //block is above the player look at total momentum difference
|
||||
const velocityDiffMag = Vector.magnitude(Vector.sub(player.velocity, obj.velocity))
|
||||
if (velocityDiffMag > velocityThreshold) hit(velocityDiffMag - velocityThreshold)
|
||||
} else { //block is below player only look at horizontal momentum difference
|
||||
const velocityDiffMagX = Math.abs(obj.velocity.x - player.velocity.x)
|
||||
if (velocityDiffMagX > velocityThreshold) hit(velocityDiffMagX - velocityThreshold)
|
||||
}
|
||||
|
||||
function hit(dmg) {
|
||||
mech.collisionImmuneCycle = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles
|
||||
let dmg = Math.sqrt((v - speedThreshold + 0.1) * (obj.mass - massThreshold)) * 0.01;
|
||||
dmg = Math.min(Math.max(dmg, 0.02), 0.15);
|
||||
dmg = Math.min(Math.max(Math.sqrt(dmg) * obj.mass * 0.01, 0.02), 0.15);
|
||||
mech.damage(dmg);
|
||||
game.drawList.push({ //add dmg to draw queue
|
||||
x: pairs[i].activeContacts[0].vertex.x,
|
||||
@@ -116,11 +118,31 @@ function collisionChecks(event) {
|
||||
color: game.mobDmgColor,
|
||||
time: game.drawTime
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// function collidePlayer(obj, speedThreshold = 12, massThreshold = 2) {
|
||||
// //player dmg from hitting a body
|
||||
// if (obj.classType === "body" && mech.collisionImmuneCycle < mech.cycle && obj.speed > speedThreshold && obj.mass > massThreshold) {
|
||||
// const v = Vector.magnitude(Vector.sub(player.velocity, obj.velocity));
|
||||
// if ((Math.abs(obj.velocity.x - player.velocity.x) > speedThreshold) || (player.position.y > obj.position.y && v > speedThreshold)) {
|
||||
// mech.collisionImmuneCycle = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles
|
||||
// let dmg = Math.sqrt((v - speedThreshold + 0.1) * (obj.mass - massThreshold)) * 0.01;
|
||||
// dmg = Math.min(Math.max(dmg, 0.02), 0.15);
|
||||
// mech.damage(dmg);
|
||||
// game.drawList.push({ //add dmg to draw queue
|
||||
// x: pairs[i].activeContacts[0].vertex.x,
|
||||
// y: pairs[i].activeContacts[0].vertex.y,
|
||||
// radius: dmg * 500,
|
||||
// color: game.mobDmgColor,
|
||||
// time: game.drawTime
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//mob + (player,bullet,body) collisions
|
||||
for (let k = 0; k < mob.length; k++) {
|
||||
if (mob[k].alive && mech.alive) {
|
||||
|
||||
32
js/index.js
32
js/index.js
@@ -369,8 +369,8 @@ document.getElementById("build-button").addEventListener("click", () => { //setu
|
||||
let localSettings = JSON.parse(localStorage.getItem("localSettings"));
|
||||
// console.log(localSettings)
|
||||
if (localSettings) {
|
||||
game.isBodyDamage = localSettings.isBodyDamage
|
||||
document.getElementById("body-damage").checked = localSettings.isBodyDamage
|
||||
// game.isBodyDamage = localSettings.isBodyDamage
|
||||
// document.getElementById("body-damage").checked = localSettings.isBodyDamage
|
||||
|
||||
game.isEasyToAimMode = localSettings.isEasyToAimMode
|
||||
document.getElementById("track-pad-mode").checked = localSettings.isEasyToAimMode
|
||||
@@ -389,14 +389,14 @@ if (localSettings) {
|
||||
document.getElementById("fps-select").value = localSettings.fpsCapDefault
|
||||
} else {
|
||||
localSettings = {
|
||||
isBodyDamage: true,
|
||||
// isBodyDamage: true,
|
||||
isEasyToAimMode: false,
|
||||
isCommunityMaps: false,
|
||||
difficultyMode: '1',
|
||||
fpsCapDefault: 'max',
|
||||
};
|
||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||
document.getElementById("body-damage").checked = localSettings.isBodyDamage
|
||||
// document.getElementById("body-damage").checked = localSettings.isBodyDamage
|
||||
document.getElementById("track-pad-mode").checked = localSettings.isEasyToAimMode
|
||||
game.isEasyToAimMode = localSettings.isEasyToAimMode
|
||||
document.getElementById("community-maps").checked = localSettings.isEasyToAimMode
|
||||
@@ -459,28 +459,32 @@ document.body.addEventListener("mousedown", (e) => {
|
||||
});
|
||||
|
||||
document.body.addEventListener("mouseenter", (e) => { //prevents mouse getting stuck when leaving the window
|
||||
// console.log(e)
|
||||
if (e.which === 1) {
|
||||
// game.mouseDown = false;
|
||||
// game.mouseDownRight = false;
|
||||
|
||||
if (e.button === 1) {
|
||||
game.mouseDown = true;
|
||||
} else {
|
||||
game.mouseDown = false;
|
||||
}
|
||||
|
||||
if (e.which === 3) {
|
||||
if (e.button === 3) {
|
||||
game.mouseDownRight = true;
|
||||
} else {
|
||||
game.mouseDownRight = false;
|
||||
}
|
||||
});
|
||||
document.body.addEventListener("mouseleave", (e) => { //prevents mouse getting stuck when leaving the window
|
||||
// game.mouseDown = false;
|
||||
// game.mouseDownRight = false;
|
||||
// console.log(e)
|
||||
if (e.which === 1) {
|
||||
if (e.button === 1) {
|
||||
game.mouseDown = true;
|
||||
} else {
|
||||
game.mouseDown = false;
|
||||
}
|
||||
|
||||
if (e.which === 3) {
|
||||
if (e.button === 3) {
|
||||
game.mouseDownRight = true;
|
||||
} else {
|
||||
game.mouseDownRight = false;
|
||||
@@ -521,11 +525,11 @@ document.getElementById("fps-select").addEventListener("input", () => {
|
||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||
});
|
||||
|
||||
document.getElementById("body-damage").addEventListener("input", () => {
|
||||
game.isBodyDamage = document.getElementById("body-damage").checked
|
||||
localSettings.isBodyDamage = game.isBodyDamage
|
||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||
});
|
||||
// document.getElementById("body-damage").addEventListener("input", () => {
|
||||
// game.isBodyDamage = document.getElementById("body-damage").checked
|
||||
// localSettings.isBodyDamage = game.isBodyDamage
|
||||
// localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||
// });
|
||||
|
||||
document.getElementById("track-pad-mode").addEventListener("input", () => {
|
||||
game.isEasyToAimMode = document.getElementById("track-pad-mode").checked
|
||||
|
||||
@@ -20,6 +20,8 @@ const level = {
|
||||
// b.giveMod("renormalization");
|
||||
// b.giveMod("pocket universe");
|
||||
// b.giveMod("wave packet");
|
||||
// b.giveGuns("laser")
|
||||
// mech.setField("pilot wave")
|
||||
|
||||
level.intro(); //starting level
|
||||
// level.testing();
|
||||
|
||||
@@ -216,7 +216,7 @@ const mech = {
|
||||
for (let i = 0; i < len; i++) {
|
||||
b.spore(player) //spawn drone
|
||||
}
|
||||
} else if (game.isBodyDamage && player.velocity.y > 27 && momentum > 180 * b.modSquirrelFx) { //falling damage
|
||||
} else if (player.velocity.y > 27 && momentum > 180 * b.modSquirrelFx) { //falling damage
|
||||
let dmg = Math.sqrt(momentum - 180) * 0.01
|
||||
dmg = Math.min(Math.max(dmg, 0.02), 0.20);
|
||||
mech.damage(dmg);
|
||||
@@ -776,6 +776,7 @@ const mech = {
|
||||
mech.fieldRegen = b.modEnergyRegen; //0.001
|
||||
mech.fieldMeterColor = "#0cf"
|
||||
mech.fieldShieldingScale = 1;
|
||||
game.isBodyDamage = true;
|
||||
mech.fieldDamageResistance = 1;
|
||||
mech.fieldRange = 155;
|
||||
mech.fieldFire = false;
|
||||
@@ -1937,10 +1938,11 @@ const mech = {
|
||||
},
|
||||
{
|
||||
name: "pilot wave",
|
||||
description: "use <strong class='color-f'>energy</strong> to push <strong>blocks</strong> with your mouse<br>field <strong>radius</strong> decreases out of <strong>line of sight</strong>",
|
||||
description: "use <strong class='color-f'>energy</strong> to push <strong>blocks</strong> with your mouse<br><strong>immune</strong> to <strong class='color-d'>damage</strong> from block <strong>collisions</strong>",
|
||||
isEasyToAim: false,
|
||||
effect: () => {
|
||||
game.replaceTextLog = true; //allow text over write
|
||||
game.isBodyDamage = false;
|
||||
mech.fieldPhase = 0;
|
||||
mech.fieldPosition = {
|
||||
x: game.mouseInGame.x,
|
||||
@@ -2008,7 +2010,7 @@ const mech = {
|
||||
|
||||
for (let i = 0, len = body.length; i < len; ++i) {
|
||||
if (Vector.magnitude(Vector.sub(body[i].position, mech.fieldPosition)) < mech.fieldRadius) {
|
||||
const DRAIN = speed * body[i].mass * 0.00002
|
||||
const DRAIN = speed * body[i].mass * 0.000022
|
||||
if (mech.energy > DRAIN) {
|
||||
mech.energy -= DRAIN;
|
||||
Matter.Body.setVelocity(body[i], velocity); //give block mouse velocity
|
||||
|
||||
25
js/spawn.js
25
js/spawn.js
@@ -8,7 +8,7 @@ const spawn = {
|
||||
"striker", "striker",
|
||||
"laser", "laser",
|
||||
"exploder", "exploder",
|
||||
"spiker", "spiker",
|
||||
"stabber", "stabber",
|
||||
"spinner",
|
||||
"grower",
|
||||
"springer",
|
||||
@@ -19,7 +19,7 @@ const spawn = {
|
||||
"ghoster",
|
||||
"sneaker",
|
||||
],
|
||||
allowedBossList: ["chaser", "spinner", "striker", "springer", "laser", "focuser", "beamer", "exploder", "spawner", "shooter", "spiker"],
|
||||
allowedBossList: ["chaser", "spinner", "striker", "springer", "laser", "focuser", "beamer", "exploder", "spawner", "shooter", "stabber"],
|
||||
setSpawnList() { //this is run at the start of each new level to determine the possible mobs for the level
|
||||
//each level has 2 mobs: one new mob and one from the last level
|
||||
spawn.pickList.splice(0, 1);
|
||||
@@ -936,15 +936,12 @@ const spawn = {
|
||||
ctx.lineTo(best.x, best.y);
|
||||
}
|
||||
},
|
||||
spiker(x, y, radius = 25 + Math.ceil(Math.random() * 15)) {
|
||||
mobs.spawn(x, y, 10, radius, "rgb(220,50,205)");
|
||||
stabber(x, y, radius = 25 + Math.ceil(Math.random() * 15)) {
|
||||
mobs.spawn(x, y, 4, radius, "rgb(220,50,205)"); //can't have sides above 6 or collision events don't work (probably because of a convex problem)
|
||||
let me = mob[mob.length - 1];
|
||||
me.accelMag = 0.0005 * game.accelScale;
|
||||
me.accelMag = 0.0006 * game.accelScale;
|
||||
// me.g = 0.0002; //required if using 'gravity'
|
||||
me.frictionStatic = 0;
|
||||
me.friction = 0;
|
||||
me.delay = 360 * game.CDScale;
|
||||
me.cd = Infinity;
|
||||
me.spikeVertex = 0;
|
||||
me.spikeLength = 0;
|
||||
me.isSpikeGrowing = false;
|
||||
@@ -958,14 +955,6 @@ const spawn = {
|
||||
this.checkStatus();
|
||||
this.attraction();
|
||||
|
||||
const setNoseShape = () => {
|
||||
const sub = Vector.sub(this.vertices[this.spikeVertex], this.position)
|
||||
const spike = Vector.mult(Vector.normalise(sub), this.radius * this.spikeLength)
|
||||
this.vertices[this.spikeVertex].x = this.position.x + spike.x
|
||||
this.vertices[this.spikeVertex].y = this.position.y + spike.y
|
||||
};
|
||||
|
||||
|
||||
if (this.isSpikeReset) {
|
||||
if (this.seePlayer.recall) {
|
||||
const dist = Vector.sub(this.seePlayer.position, this.position);
|
||||
@@ -1002,7 +991,9 @@ const spawn = {
|
||||
this.isSpikeReset = true
|
||||
}
|
||||
}
|
||||
setNoseShape();
|
||||
const spike = Vector.mult(Vector.normalise(Vector.sub(this.vertices[this.spikeVertex], this.position)), this.radius * this.spikeLength)
|
||||
this.vertices[this.spikeVertex].x = this.position.x + spike.x
|
||||
this.vertices[this.spikeVertex].y = this.position.y + spike.y
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user