From 7510fb3f45eefb8d8958f86a4c5fc7290a95f8b5 Mon Sep 17 00:00:00 2001 From: landgreen Date: Sun, 16 Feb 2020 05:01:47 -0800 Subject: [PATCH] speed up player movement and gravity --- js/bullets.js | 10 +++++----- js/level.js | 18 +++++++++++++----- js/mobs.js | 4 ++-- js/player.js | 22 +++++++++++----------- js/spawn.js | 10 +++++----- todo.md | 13 +------------ 6 files changed, 37 insertions(+), 40 deletions(-) diff --git a/js/bullets.js b/js/bullets.js index f282f48..678f3e3 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -89,8 +89,8 @@ const b = { b.isModEnergyRecovery = false; b.isModHealthRecovery = false; mech.fieldRange = 175; - mech.Fx = 0.015; - mech.jumpForce = 0.38; + mech.Fx = 0.016; //if this changes update the values in definePlayerMass + mech.jumpForce = 0.42; //was 0.38 at 0.0019 gravity mech.maxHealth = 1; mech.fieldEnergyMax = 1; for (i = 0, len = b.guns.length; i < len; i++) { //find which gun is flak @@ -312,11 +312,11 @@ const b = { }, { name: "field superposition", - description: "increase your field radius by 40%", + description: "increase your field radius by 40%", maxCount: 1, count: 0, allowed() { - return b.modBlockDmg > 0 + return mech.fieldUpgrades[mech.fieldMode].name !== "time dilation field" && mech.fieldUpgrades[mech.fieldMode].name !== "phase decoherence field" }, effect() { mech.fieldRange = 175 * 1.4 //175 is default @@ -368,7 +368,7 @@ const b = { }, effect() { // good with melee builds, content skipping builds b.modSquirrelFx += 0.2; - mech.Fx = 0.015 * b.modSquirrelFx; + mech.Fx = 0.016 * b.modSquirrelFx; mech.jumpForce += 0.038; } }, diff --git a/js/level.js b/js/level.js index 52f7430..b108d1f 100644 --- a/js/level.js +++ b/js/level.js @@ -1756,16 +1756,24 @@ const level = { }); target.torque = (Math.random() - 0.5) * 2 * target.mass; }, - boost(target, info) { + boost(target, yVelocity) { // if (target.velocity.y < 0) { // mech.undoCrouch(); // mech.enterAir(); mech.buttonCD_jump = 0; // reset short jump counter to prevent short jumps on boosts mech.hardLandCD = 0 // disable hard landing - Matter.Body.setVelocity(target, { - x: target.velocity.x + (Math.random() - 0.5) * 2, - y: info - }); + if (target.velocity.y > 30) { + Matter.Body.setVelocity(target, { + x: target.velocity.x + (Math.random() - 0.5) * 2, + y: -23 //gentle bounce if coming down super fast + }); + } else { + Matter.Body.setVelocity(target, { + x: target.velocity.x + (Math.random() - 0.5) * 2, + y: yVelocity + }); + } + }, force(target, info) { if (target.velocity.y < 0) { diff --git a/js/mobs.js b/js/mobs.js index 96544d9..04866d0 100644 --- a/js/mobs.js +++ b/js/mobs.js @@ -614,8 +614,8 @@ const mobs = { pullPlayer() { if (this.seePlayer.yes && Vector.magnitudeSquared(Vector.sub(this.position, player.position)) < 1000000) { const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x); - player.force.x -= game.accelScale * 1.13 * Math.cos(angle) * (mech.onGround ? 2 * player.mass * game.g : player.mass * game.g); - player.force.y -= game.accelScale * 0.84 * player.mass * game.g * Math.sin(angle); + player.force.x -= game.accelScale * 0.00113 * player.mass * Math.cos(angle) * (mech.onGround ? 2 : 1); + player.force.y -= game.accelScale * 0.00084 * player.mass * Math.sin(angle); ctx.beginPath(); ctx.moveTo(this.position.x, this.position.y); diff --git a/js/player.js b/js/player.js index 357fd62..1a0ff7a 100644 --- a/js/player.js +++ b/js/player.js @@ -67,8 +67,8 @@ const mech = { defaultMass: 5, mass: 5, FxNotHolding: 0.015, - Fx: 0.015, //run Force on ground //this is reset in b.setModDefaults() - FxAir: 0.015, //run Force in Air + Fx: null, //run Force on ground //0.015 //this is set in b.setModDefaults() + FxAir: 0.016, //run Force in Air yOff: 70, yOffGoal: 70, onGround: false, //checks if on ground or in air @@ -105,8 +105,8 @@ const mech = { Sy: 0, //adds a smoothing effect to vertical only Vx: 0, Vy: 0, - jumpForce: 0.38, //this is reset in b.setModDefaults() - gravity: 0.0019, + jumpForce: null, //0.38 //this is reset in b.setModDefaults() + gravity: 0.0024, //0.0019 //game.g is 0.001 friction: { ground: 0.01, air: 0.0025 @@ -202,21 +202,21 @@ const mech = { //sets a hard land where player stays in a crouch for a bit and can't jump //crouch is forced in keyMove() on ground section below const momentum = player.velocity.y * player.mass //player mass is 5 so this triggers at 20 down velocity, unless the player is holding something - if (momentum > 120) { + if (momentum > 130) { mech.doCrouch(); mech.yOff = mech.yOffWhen.jump; - mech.hardLandCD = mech.cycle + Math.min(momentum / 6 - 6, 40) + mech.hardLandCD = mech.cycle + Math.min(momentum / 6.5 - 6, 40) // if (b.isModStompPauli) { // mech.collisionImmune = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles // } if (b.isModStomp) { - const len = Math.min(25, (momentum - 110) * 0.1) + const len = Math.min(25, (momentum - 120) * 0.1) for (let i = 0; i < len; i++) { b.spore(player) //spawn drone } - } else if (game.isBodyDamage && player.velocity.y > 26 && momentum > 165 * b.modSquirrelFx) { //falling damage - let dmg = Math.sqrt(momentum - 165) * 0.01 + } else if (game.isBodyDamage && 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); } @@ -719,8 +719,8 @@ const mech = { definePlayerMass(mass = mech.defaultMass) { Matter.Body.setMass(player, mass); //reduce air and ground move forces - mech.Fx = 0.075 / mass * b.modSquirrelFx - mech.FxAir = 0.375 / mass / mass + mech.Fx = 0.08 / mass * b.modSquirrelFx //base player mass is 5 + mech.FxAir = 0.4 / mass / mass //base player mass is 5 //make player stand a bit lower when holding heavy masses mech.yOffWhen.stand = Math.max(mech.yOffWhen.crouch, Math.min(49, 49 - (mass - 5) * 6)) if (mech.onGround && !mech.crouch) mech.yOffGoal = mech.yOffWhen.stand; diff --git a/js/spawn.js b/js/spawn.js index 4506b8b..0a33e9e 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -510,8 +510,8 @@ const spawn = { mech.damage(0.0002 * game.dmgScale); } const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x); - player.force.x -= 1.25 * Math.cos(angle) * player.mass * game.g * (mech.onGround ? 1.8 : 1); - player.force.y -= 0.96 * player.mass * game.g * Math.sin(angle); + player.force.x -= 0.00125 * player.mass * Math.cos(angle) * (mech.onGround ? 1.8 : 1); + player.force.y -= 0.0001 * player.mass * Math.sin(angle); //draw line to player ctx.beginPath(); ctx.moveTo(this.position.x, this.position.y); @@ -608,8 +608,8 @@ const spawn = { mech.damage(0.0003 * game.dmgScale); } const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x); - player.force.x -= 1.3 * Math.cos(angle) * player.mass * game.g * (mech.onGround ? 1.7 : 1); - player.force.y -= 1.2 * Math.sin(angle) * player.mass * game.g; + player.force.x -= 0.0013 * Math.cos(angle) * player.mass * (mech.onGround ? 1.7 : 1); + player.force.y -= 0.0013 * Math.sin(angle) * player.mass; //draw line to player ctx.beginPath(); ctx.moveTo(this.position.x, this.position.y); @@ -1713,7 +1713,7 @@ const spawn = { // level.addZone(x, y, 100, 30, "fling", {Vx:Vx, Vy: Vy}); level.addQueryRegion(x, y - 20, 100, 20, "boost", [ [player], body, mob, powerUp, bullet - ], -1.1 * Math.sqrt(Math.abs(height))); + ], -1.21 * Math.sqrt(Math.abs(height))); let color = "rgba(200,0,255,"; level.fillBG.push({ x: x, diff --git a/todo.md b/todo.md index 29fa7dc..6b2b6b5 100644 --- a/todo.md +++ b/todo.md @@ -1,5 +1,3 @@ - \ No newline at end of file + bouncy ground \ No newline at end of file