gravity field balance
This commit is contained in:
31
js/player.js
31
js/player.js
@@ -934,7 +934,7 @@ const mech = {
|
|||||||
mech.calculateFieldThreshold();
|
mech.calculateFieldThreshold();
|
||||||
|
|
||||||
mech.hold = function () {
|
mech.hold = function () {
|
||||||
const range = 400
|
const range = 500
|
||||||
if (mech.isHolding) {
|
if (mech.isHolding) {
|
||||||
mech.drawHold(mech.holdingTarget);
|
mech.drawHold(mech.holdingTarget);
|
||||||
mech.holding();
|
mech.holding();
|
||||||
@@ -957,15 +957,34 @@ const mech = {
|
|||||||
}
|
}
|
||||||
zeroG(powerUp);
|
zeroG(powerUp);
|
||||||
zeroG(body);
|
zeroG(body);
|
||||||
|
// zeroG(bullet); //works fine, but not that noticeable and maybe not worth the possible performance hit
|
||||||
// zeroG(mob); //mobs are too irregular to make this work?
|
// zeroG(mob); //mobs are too irregular to make this work?
|
||||||
|
|
||||||
player.force.y -= player.mass * mech.gravity; // + 0.005 * Math.sin(game.cycle / 10); //wobble
|
player.force.y -= player.mass * mech.gravity; // + 0.005 * Math.sin(game.cycle / 10); //wobble
|
||||||
|
|
||||||
//add player vertical friction to reduce map jump exploits
|
//allow player to fly up and down a bit
|
||||||
Matter.Body.setVelocity(player, {
|
flyForce = 0.003;
|
||||||
x: player.velocity.x,
|
if (keys[83] || keys[40]) {
|
||||||
y: player.velocity.y * 0.99
|
player.force.y += flyForce
|
||||||
});
|
Matter.Body.setVelocity(player, { //friction, only when flying
|
||||||
|
x: player.velocity.x,
|
||||||
|
y: player.velocity.y * 0.96
|
||||||
|
});
|
||||||
|
} else if (keys[87] || keys[38]) {
|
||||||
|
player.force.y -= flyForce
|
||||||
|
Matter.Body.setVelocity(player, { //friction, only when flying
|
||||||
|
x: player.velocity.x,
|
||||||
|
y: player.velocity.y * 0.96
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//add extra friction for horizontal motion
|
||||||
|
if (keys[65] || keys[68] || keys[37] || keys[39]) {
|
||||||
|
Matter.Body.setVelocity(player, {
|
||||||
|
x: player.velocity.x * 0.95,
|
||||||
|
y: player.velocity.y
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//draw zero-G range
|
//draw zero-G range
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
|
|||||||
Reference in New Issue
Block a user