pilot wave damage fix, block colliison rewrite
This commit is contained in:
@@ -105,9 +105,9 @@
|
|||||||
<br>
|
<br>
|
||||||
<label for="community-maps" title="adds in new maps made by other playrs">include community maps:</label>
|
<label for="community-maps" title="adds in new maps made by other playrs">include community maps:</label>
|
||||||
<input type="checkbox" id="community-maps" name="community-maps" style="width:17px; height:17px;">
|
<input type="checkbox" id="community-maps" name="community-maps" style="width:17px; height:17px;">
|
||||||
<br>
|
<!-- <br>
|
||||||
<label for="body-damage" title="allow damage from the ground and large fast moving blocks">collision damage from blocks:</label>
|
<label for="body-damage" title="allow damage from the ground and large fast moving blocks">collision damage from blocks:</label>
|
||||||
<input type="checkbox" id="body-damage" name="body-damage" checked style="width:17px; height:17px;">
|
<input type="checkbox" id="body-damage" name="body-damage" checked style="width:17px; height:17px;"> -->
|
||||||
<br>
|
<br>
|
||||||
<label for="track-pad-mode" title="remove random power ups that don't work well with a track pad">remove power ups that require aiming:</label>
|
<label for="track-pad-mode" title="remove random power ups that don't work well with a track pad">remove power ups that require aiming:</label>
|
||||||
<input type="checkbox" id="track-pad-mode" name="track-pad-mode" style="width:17px; height:17px;">
|
<input type="checkbox" id="track-pad-mode" name="track-pad-mode" style="width:17px; height:17px;">
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ const b = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "scrap bots",
|
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,
|
maxCount: 6,
|
||||||
count: 0,
|
count: 0,
|
||||||
allowed() {
|
allowed() {
|
||||||
@@ -304,7 +304,7 @@ const b = {
|
|||||||
},
|
},
|
||||||
requires: "",
|
requires: "",
|
||||||
effect() {
|
effect() {
|
||||||
b.isModBotSpawner += 0.15;
|
b.isModBotSpawner += 0.13;
|
||||||
},
|
},
|
||||||
remove() {
|
remove() {
|
||||||
b.isModBotSpawner = 0;
|
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
|
//player dmg from hitting a body
|
||||||
if (
|
if (obj.classType === "body" && mech.collisionImmuneCycle < mech.cycle) {
|
||||||
obj.classType === "body" &&
|
const velocityThreshold = 13
|
||||||
obj.speed > speedThreshold &&
|
if (player.position.y > obj.position.y) { //block is above the player look at total momentum difference
|
||||||
obj.mass > massThreshold &&
|
const velocityDiffMag = Vector.magnitude(Vector.sub(player.velocity, obj.velocity))
|
||||||
(obj.velocity.y > 0 || player.velocity.y > 0)
|
if (velocityDiffMag > velocityThreshold) hit(velocityDiffMag - velocityThreshold)
|
||||||
) {
|
} else { //block is below player only look at horizontal momentum difference
|
||||||
const v = Vector.magnitude(Vector.sub(player.velocity, obj.velocity));
|
const velocityDiffMagX = Math.abs(obj.velocity.x - player.velocity.x)
|
||||||
if (v > speedThreshold && mech.collisionImmuneCycle < mech.cycle) {
|
if (velocityDiffMagX > velocityThreshold) hit(velocityDiffMagX - velocityThreshold)
|
||||||
|
}
|
||||||
|
|
||||||
|
function hit(dmg) {
|
||||||
mech.collisionImmuneCycle = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles
|
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(Math.sqrt(dmg) * obj.mass * 0.01, 0.02), 0.15);
|
||||||
dmg = Math.min(Math.max(dmg, 0.02), 0.15);
|
|
||||||
mech.damage(dmg);
|
mech.damage(dmg);
|
||||||
game.drawList.push({ //add dmg to draw queue
|
game.drawList.push({ //add dmg to draw queue
|
||||||
x: pairs[i].activeContacts[0].vertex.x,
|
x: pairs[i].activeContacts[0].vertex.x,
|
||||||
@@ -116,11 +118,31 @@ function collisionChecks(event) {
|
|||||||
color: game.mobDmgColor,
|
color: game.mobDmgColor,
|
||||||
time: game.drawTime
|
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
|
//mob + (player,bullet,body) collisions
|
||||||
for (let k = 0; k < mob.length; k++) {
|
for (let k = 0; k < mob.length; k++) {
|
||||||
if (mob[k].alive && mech.alive) {
|
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"));
|
let localSettings = JSON.parse(localStorage.getItem("localSettings"));
|
||||||
// console.log(localSettings)
|
// console.log(localSettings)
|
||||||
if (localSettings) {
|
if (localSettings) {
|
||||||
game.isBodyDamage = localSettings.isBodyDamage
|
// game.isBodyDamage = localSettings.isBodyDamage
|
||||||
document.getElementById("body-damage").checked = localSettings.isBodyDamage
|
// document.getElementById("body-damage").checked = localSettings.isBodyDamage
|
||||||
|
|
||||||
game.isEasyToAimMode = localSettings.isEasyToAimMode
|
game.isEasyToAimMode = localSettings.isEasyToAimMode
|
||||||
document.getElementById("track-pad-mode").checked = localSettings.isEasyToAimMode
|
document.getElementById("track-pad-mode").checked = localSettings.isEasyToAimMode
|
||||||
@@ -389,14 +389,14 @@ if (localSettings) {
|
|||||||
document.getElementById("fps-select").value = localSettings.fpsCapDefault
|
document.getElementById("fps-select").value = localSettings.fpsCapDefault
|
||||||
} else {
|
} else {
|
||||||
localSettings = {
|
localSettings = {
|
||||||
isBodyDamage: true,
|
// isBodyDamage: true,
|
||||||
isEasyToAimMode: false,
|
isEasyToAimMode: false,
|
||||||
isCommunityMaps: false,
|
isCommunityMaps: false,
|
||||||
difficultyMode: '1',
|
difficultyMode: '1',
|
||||||
fpsCapDefault: 'max',
|
fpsCapDefault: 'max',
|
||||||
};
|
};
|
||||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
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
|
document.getElementById("track-pad-mode").checked = localSettings.isEasyToAimMode
|
||||||
game.isEasyToAimMode = localSettings.isEasyToAimMode
|
game.isEasyToAimMode = localSettings.isEasyToAimMode
|
||||||
document.getElementById("community-maps").checked = 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
|
document.body.addEventListener("mouseenter", (e) => { //prevents mouse getting stuck when leaving the window
|
||||||
// console.log(e)
|
// game.mouseDown = false;
|
||||||
if (e.which === 1) {
|
// game.mouseDownRight = false;
|
||||||
|
|
||||||
|
if (e.button === 1) {
|
||||||
game.mouseDown = true;
|
game.mouseDown = true;
|
||||||
} else {
|
} else {
|
||||||
game.mouseDown = false;
|
game.mouseDown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.which === 3) {
|
if (e.button === 3) {
|
||||||
game.mouseDownRight = true;
|
game.mouseDownRight = true;
|
||||||
} else {
|
} else {
|
||||||
game.mouseDownRight = false;
|
game.mouseDownRight = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.body.addEventListener("mouseleave", (e) => { //prevents mouse getting stuck when leaving the window
|
document.body.addEventListener("mouseleave", (e) => { //prevents mouse getting stuck when leaving the window
|
||||||
|
// game.mouseDown = false;
|
||||||
|
// game.mouseDownRight = false;
|
||||||
// console.log(e)
|
// console.log(e)
|
||||||
if (e.which === 1) {
|
if (e.button === 1) {
|
||||||
game.mouseDown = true;
|
game.mouseDown = true;
|
||||||
} else {
|
} else {
|
||||||
game.mouseDown = false;
|
game.mouseDown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.which === 3) {
|
if (e.button === 3) {
|
||||||
game.mouseDownRight = true;
|
game.mouseDownRight = true;
|
||||||
} else {
|
} else {
|
||||||
game.mouseDownRight = false;
|
game.mouseDownRight = false;
|
||||||
@@ -521,11 +525,11 @@ document.getElementById("fps-select").addEventListener("input", () => {
|
|||||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("body-damage").addEventListener("input", () => {
|
// document.getElementById("body-damage").addEventListener("input", () => {
|
||||||
game.isBodyDamage = document.getElementById("body-damage").checked
|
// game.isBodyDamage = document.getElementById("body-damage").checked
|
||||||
localSettings.isBodyDamage = game.isBodyDamage
|
// localSettings.isBodyDamage = game.isBodyDamage
|
||||||
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
// localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
|
||||||
});
|
// });
|
||||||
|
|
||||||
document.getElementById("track-pad-mode").addEventListener("input", () => {
|
document.getElementById("track-pad-mode").addEventListener("input", () => {
|
||||||
game.isEasyToAimMode = document.getElementById("track-pad-mode").checked
|
game.isEasyToAimMode = document.getElementById("track-pad-mode").checked
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ const level = {
|
|||||||
// b.giveMod("renormalization");
|
// b.giveMod("renormalization");
|
||||||
// b.giveMod("pocket universe");
|
// b.giveMod("pocket universe");
|
||||||
// b.giveMod("wave packet");
|
// b.giveMod("wave packet");
|
||||||
|
// b.giveGuns("laser")
|
||||||
|
// mech.setField("pilot wave")
|
||||||
|
|
||||||
level.intro(); //starting level
|
level.intro(); //starting level
|
||||||
// level.testing();
|
// level.testing();
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ const mech = {
|
|||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
b.spore(player) //spawn drone
|
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
|
let dmg = Math.sqrt(momentum - 180) * 0.01
|
||||||
dmg = Math.min(Math.max(dmg, 0.02), 0.20);
|
dmg = Math.min(Math.max(dmg, 0.02), 0.20);
|
||||||
mech.damage(dmg);
|
mech.damage(dmg);
|
||||||
@@ -776,6 +776,7 @@ const mech = {
|
|||||||
mech.fieldRegen = b.modEnergyRegen; //0.001
|
mech.fieldRegen = b.modEnergyRegen; //0.001
|
||||||
mech.fieldMeterColor = "#0cf"
|
mech.fieldMeterColor = "#0cf"
|
||||||
mech.fieldShieldingScale = 1;
|
mech.fieldShieldingScale = 1;
|
||||||
|
game.isBodyDamage = true;
|
||||||
mech.fieldDamageResistance = 1;
|
mech.fieldDamageResistance = 1;
|
||||||
mech.fieldRange = 155;
|
mech.fieldRange = 155;
|
||||||
mech.fieldFire = false;
|
mech.fieldFire = false;
|
||||||
@@ -1937,10 +1938,11 @@ const mech = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "pilot wave",
|
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,
|
isEasyToAim: false,
|
||||||
effect: () => {
|
effect: () => {
|
||||||
game.replaceTextLog = true; //allow text over write
|
game.replaceTextLog = true; //allow text over write
|
||||||
|
game.isBodyDamage = false;
|
||||||
mech.fieldPhase = 0;
|
mech.fieldPhase = 0;
|
||||||
mech.fieldPosition = {
|
mech.fieldPosition = {
|
||||||
x: game.mouseInGame.x,
|
x: game.mouseInGame.x,
|
||||||
@@ -2008,7 +2010,7 @@ const mech = {
|
|||||||
|
|
||||||
for (let i = 0, len = body.length; i < len; ++i) {
|
for (let i = 0, len = body.length; i < len; ++i) {
|
||||||
if (Vector.magnitude(Vector.sub(body[i].position, mech.fieldPosition)) < mech.fieldRadius) {
|
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) {
|
if (mech.energy > DRAIN) {
|
||||||
mech.energy -= DRAIN;
|
mech.energy -= DRAIN;
|
||||||
Matter.Body.setVelocity(body[i], velocity); //give block mouse velocity
|
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",
|
"striker", "striker",
|
||||||
"laser", "laser",
|
"laser", "laser",
|
||||||
"exploder", "exploder",
|
"exploder", "exploder",
|
||||||
"spiker", "spiker",
|
"stabber", "stabber",
|
||||||
"spinner",
|
"spinner",
|
||||||
"grower",
|
"grower",
|
||||||
"springer",
|
"springer",
|
||||||
@@ -19,7 +19,7 @@ const spawn = {
|
|||||||
"ghoster",
|
"ghoster",
|
||||||
"sneaker",
|
"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
|
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
|
//each level has 2 mobs: one new mob and one from the last level
|
||||||
spawn.pickList.splice(0, 1);
|
spawn.pickList.splice(0, 1);
|
||||||
@@ -936,15 +936,12 @@ const spawn = {
|
|||||||
ctx.lineTo(best.x, best.y);
|
ctx.lineTo(best.x, best.y);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
spiker(x, y, radius = 25 + Math.ceil(Math.random() * 15)) {
|
stabber(x, y, radius = 25 + Math.ceil(Math.random() * 15)) {
|
||||||
mobs.spawn(x, y, 10, radius, "rgb(220,50,205)");
|
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];
|
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.g = 0.0002; //required if using 'gravity'
|
||||||
me.frictionStatic = 0;
|
|
||||||
me.friction = 0;
|
|
||||||
me.delay = 360 * game.CDScale;
|
me.delay = 360 * game.CDScale;
|
||||||
me.cd = Infinity;
|
|
||||||
me.spikeVertex = 0;
|
me.spikeVertex = 0;
|
||||||
me.spikeLength = 0;
|
me.spikeLength = 0;
|
||||||
me.isSpikeGrowing = false;
|
me.isSpikeGrowing = false;
|
||||||
@@ -958,14 +955,6 @@ const spawn = {
|
|||||||
this.checkStatus();
|
this.checkStatus();
|
||||||
this.attraction();
|
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.isSpikeReset) {
|
||||||
if (this.seePlayer.recall) {
|
if (this.seePlayer.recall) {
|
||||||
const dist = Vector.sub(this.seePlayer.position, this.position);
|
const dist = Vector.sub(this.seePlayer.position, this.position);
|
||||||
@@ -1002,7 +991,9 @@ const spawn = {
|
|||||||
this.isSpikeReset = true
|
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