From c7c8c0f2bd9e023f320b38b25c73a17edc480531 Mon Sep 17 00:00:00 2001 From: landgreen Date: Wed, 8 Apr 2020 07:36:04 -0700 Subject: [PATCH] double helix and timelike world line --- js/bullets.js | 239 +++++++++++++++++++++++++++++--------------------- js/game.js | 9 +- js/player.js | 26 ++++++ js/spawn.js | 4 +- todo.txt | 5 ++ 5 files changed, 177 insertions(+), 106 deletions(-) diff --git a/js/bullets.js b/js/bullets.js index 7eecc22..2a625fe 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -75,6 +75,7 @@ const b = { modGrenadeFragments: null, isModEnergyDamage: null, isModBotSpawner: null, + modWaveHelix: null, modOnHealthChange() { //used with acid mod if (b.isModAcidDmg && mech.health > 0.8) { b.modAcidDmg = 0.7 @@ -1029,6 +1030,23 @@ const b = { b.modWaveSpeedBody = 0.25 } }, + { + name: "double helix", + description: "wave beam emits two out of phase particles
wave particles do 40% less damage", + maxCount: 1, + count: 0, + allowed() { + return b.haveGunCheck("wave beam") + }, + requires: "wave beam", + effect() { + b.modWaveHelix = 2 + }, + remove() { + b.modWaveHelix = 1 + } + }, + { name: "pocket universe", description: "wave beam bullets last 4 times longer
bullets are confined to a region around player", @@ -1131,7 +1149,7 @@ const b = { }, { name: "tinsellated flagella", - description: "spores accelerate 33% faster", + description: "spores accelerate 50% faster", maxCount: 1, count: 0, allowed() { @@ -1245,6 +1263,22 @@ const b = { b.isModStunField = 0; } }, + { + name: "timelike world line", + description: "time dilation increases your time rate by 2x
while energy drain is decreased by 2x", + maxCount: 9, + count: 0, + allowed() { + return mech.fieldUpgrades[mech.fieldMode].name === "time dilation field" + }, + requires: "time dilation field", + effect() { + b.isModTimeSkip = true; + }, + remove() { + b.isModTimeSkip = false; + } + }, { name: "plasma jet", description: "increase plasma torch's range by 33%", @@ -1494,7 +1528,7 @@ const b = { } } }, - bulletActions() { //run in main loop + bulletRemove() { //run in main loop //remove bullet if at end cycle for that bullet let i = bullet.length; while (i--) { @@ -1508,7 +1542,8 @@ const b = { } } } - //draw + }, + bulletDraw() { ctx.beginPath(); for (let i = 0, len = bullet.length; i < len; i++) { let vertices = bullet[i].vertices; @@ -1520,8 +1555,8 @@ const b = { } ctx.fillStyle = "#000"; ctx.fill(); - - //do bullet things + }, + bulletDo() { for (let i = 0, len = bullet.length; i < len; i++) { bullet[i].do(); } @@ -1962,7 +1997,7 @@ const b = { angle: Math.random() * 2 * Math.PI, friction: 0, frictionAir: 0.025, - thrust: b.isModFastSpores ? 0.0008 : 0.0004, + thrust: b.isModFastSpores ? 0.001 : 0.0004, dmg: 2.4, //damage done in addition to the damage from momentum classType: "bullet", collisionFilter: { @@ -1971,7 +2006,7 @@ const b = { }, endCycle: game.cycle + Math.floor((660 + Math.floor(Math.random() * 240)) * b.isModBulletsLastLonger), minDmgSpeed: 0, - onDmg() { + onDmg(who) { // mobs.statusPoison(who, 0.5, 180) // (2.2) * 1.3 * 30/180 // 6 ticks (3 seconds) this.endCycle = 0; //bullet ends cycle after doing damage }, @@ -2608,106 +2643,108 @@ const b = { isStarterGun: true, isEasyToAim: false, fire() { - const me = bullet.length; + mech.fireCDcycle = mech.cycle + Math.floor(3 * b.modFireRate); // cool down const dir = mech.angle const SPEED = 10 - const wiggleMag = mech.crouch ? 3 : 10 - bullet[me] = Bodies.polygon(mech.pos.x + 25 * Math.cos(dir), mech.pos.y + 25 * Math.sin(dir), 7, 5 * b.modBulletSize, { - angle: dir, - cycle: 0, - endCycle: game.cycle + Math.floor((b.isModWaveReflect ? 480 : 120) * b.isModBulletsLastLonger), - inertia: Infinity, - frictionAir: 0, - slow: 0, - minDmgSpeed: 0, - dmg: 0, - isJustReflected: false, - classType: "bullet", - collisionFilter: { - category: 0, - mask: 0, //cat.mob | cat.mobBullet | cat.mobShield - }, - onDmg() {}, - onEnd() {}, - do() { - if (!mech.isBodiesAsleep) { - let slowCheck = 1; - if (Matter.Query.point(map, this.position).length) { //check if inside map - slowCheck = b.modWaveSpeedMap - } else { //check if inside a body - let q = Matter.Query.point(body, this.position) - if (q.length) { - slowCheck = b.modWaveSpeedBody - Matter.Body.setPosition(this, Vector.add(this.position, q[0].velocity)) //move with the medium - } else { // check if inside a mob - q = Matter.Query.point(mob, this.position) - for (let i = 0; i < q.length; i++) { - slowCheck = 0.3; - Matter.Body.setPosition(this, Vector.add(this.position, q[i].velocity)) //move with the medium - let dmg = b.dmgScale * 0.45 / Math.sqrt(q[i].mass) - q[i].damage(dmg); - q[i].foundPlayer(); - game.drawList.push({ //add dmg to draw queue - x: this.position.x, - y: this.position.y, - radius: Math.log(2 * dmg + 1.1) * 40, - color: 'rgba(0,0,0,0.4)', - time: game.drawTime - }); + const wiggleMag = mech.crouch ? 5 : 12 + for (let i = 0; i < b.modWaveHelix; i++) { + const me = bullet.length; + bullet[me] = Bodies.polygon(mech.pos.x + 25 * Math.cos(dir), mech.pos.y + 25 * Math.sin(dir), 7, 5 * b.modBulletSize, { + angle: dir, + cycle: -0.5, + endCycle: game.cycle + Math.floor((b.isModWaveReflect ? 480 : 120) * b.isModBulletsLastLonger), + inertia: Infinity, + frictionAir: 0, + slow: 0, + minDmgSpeed: 0, + dmg: 0, + isJustReflected: false, + classType: "bullet", + collisionFilter: { + category: 0, + mask: 0, //cat.mob | cat.mobBullet | cat.mobShield + }, + onDmg() {}, + onEnd() {}, + do() { + if (!mech.isBodiesAsleep) { + let slowCheck = 1; + if (Matter.Query.point(map, this.position).length) { //check if inside map + slowCheck = b.modWaveSpeedMap + } else { //check if inside a body + let q = Matter.Query.point(body, this.position) + if (q.length) { + slowCheck = b.modWaveSpeedBody + Matter.Body.setPosition(this, Vector.add(this.position, q[0].velocity)) //move with the medium + } else { // check if inside a mob + q = Matter.Query.point(mob, this.position) + for (let i = 0; i < q.length; i++) { + slowCheck = 0.3; + Matter.Body.setPosition(this, Vector.add(this.position, q[i].velocity)) //move with the medium + let dmg = b.dmgScale * 0.43 / Math.sqrt(q[i].mass) * (b.modWaveHelix ? 0.6 : 1) //1 - 0.4 = 0.6 for helix mod 40% damage reduction + q[i].damage(dmg); + q[i].foundPlayer(); + game.drawList.push({ //add dmg to draw queue + x: this.position.x, + y: this.position.y, + radius: Math.log(2 * dmg + 1.1) * 40, + color: 'rgba(0,0,0,0.4)', + time: game.drawTime + }); + } } } + if (slowCheck !== this.slow) { //toggle velocity based on inside and outside status change + this.slow = slowCheck + Matter.Body.setVelocity(this, Vector.mult(Vector.normalise(this.velocity), SPEED * slowCheck)); + } + this.cycle++ + const wiggle = Vector.mult(transverse, wiggleMag * Math.cos(this.cycle * 0.35) * ((i % 2) ? -1 : 1)) + Matter.Body.setPosition(this, Vector.add(this.position, wiggle)) } - if (slowCheck !== this.slow) { //toggle velocity based on inside and outside status change - this.slow = slowCheck - Matter.Body.setVelocity(this, Vector.mult(Vector.normalise(this.velocity), SPEED * slowCheck)); + // if (b.isModWaveReflect) { //single reflection + // const sub = Vector.sub(this.position, mech.pos) + // if (Vector.magnitude(sub) > 630) { + // // Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * POCKET_RANGE))) //teleport to opposite side + // if (!this.isJustReflected) { + // Matter.Body.setVelocity(this, Vector.mult(this.velocity, -1)); //reflect + // this.isJustReflected = true; + // } + // } + // } + + if (b.isModWaveReflect) { + Matter.Body.setPosition(this, Vector.add(this.position, player.velocity)) //bullets move with player + const sub = Vector.sub(this.position, mech.pos) + if (Vector.magnitude(sub) > 630) { + Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * 630))) //teleport to opposite side + } } - this.cycle++ - const wiggle = Vector.mult(transverse, wiggleMag * Math.cos(this.cycle * 0.35)) - Matter.Body.setPosition(this, Vector.add(this.position, wiggle)) + + // if (b.isModWaveReflect) { + // Matter.Body.setPosition(this, Vector.add(this.position, player.velocity)) //bullets move with player + + // Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * POCKET_RANGE))) //teleport to opposite side + + // const sub = Vector.sub(this.position, mech.pos) + // if (Vector.magnitude(sub) > 630) { + // if (!this.isJustReflected) { + // Matter.Body.setVelocity(this, Vector.mult(this.velocity, -1)); //reflect + // this.isJustReflected = true; + // } + // } else { + // this.isJustReflected = false + // } + // } } - // if (b.isModWaveReflect) { //single reflection - // const sub = Vector.sub(this.position, mech.pos) - // if (Vector.magnitude(sub) > 630) { - // // Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * POCKET_RANGE))) //teleport to opposite side - // if (!this.isJustReflected) { - // Matter.Body.setVelocity(this, Vector.mult(this.velocity, -1)); //reflect - // this.isJustReflected = true; - // } - // } - // } - - if (b.isModWaveReflect) { - Matter.Body.setPosition(this, Vector.add(this.position, player.velocity)) //bullets move with player - const sub = Vector.sub(this.position, mech.pos) - if (Vector.magnitude(sub) > 630) { - Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * 630))) //teleport to opposite side - } - } - - // if (b.isModWaveReflect) { - // Matter.Body.setPosition(this, Vector.add(this.position, player.velocity)) //bullets move with player - - // Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * POCKET_RANGE))) //teleport to opposite side - - // const sub = Vector.sub(this.position, mech.pos) - // if (Vector.magnitude(sub) > 630) { - // if (!this.isJustReflected) { - // Matter.Body.setVelocity(this, Vector.mult(this.velocity, -1)); //reflect - // this.isJustReflected = true; - // } - // } else { - // this.isJustReflected = false - // } - // } - } - }); - World.add(engine.world, bullet[me]); //add bullet to world - mech.fireCDcycle = mech.cycle + Math.floor(3 * b.modFireRate); // cool down - Matter.Body.setVelocity(bullet[me], { - x: SPEED * Math.cos(dir), - y: SPEED * Math.sin(dir) - }); - const transverse = Vector.normalise(Vector.perp(bullet[me].velocity)) + }); + World.add(engine.world, bullet[me]); //add bullet to world + Matter.Body.setVelocity(bullet[me], { + x: SPEED * Math.cos(dir), + y: SPEED * Math.sin(dir) + }); + const transverse = Vector.normalise(Vector.perp(bullet[me].velocity)) + } } }, { @@ -3032,7 +3069,7 @@ const b = { name: "drones", //11 description: "deploy drones that crash into mobs
collisions reduce their lifespan by 1 second", ammo: 0, - ammoPack: 11, + ammoPack: 12, have: false, isStarterGun: true, isEasyToAim: true, diff --git a/js/game.js b/js/game.js index 39e6d8d..ab01791 100644 --- a/js/game.js +++ b/js/game.js @@ -51,7 +51,9 @@ const game = { level.drawFills(); game.draw.drawMapPath(); b.fire(); - b.bulletActions(); + b.bulletRemove(); + b.bulletDraw(); + b.bulletDo(); game.drawCircle(); ctx.restore(); game.drawCursor(); @@ -74,7 +76,8 @@ const game = { mech.hold(); b.fire(); - b.bulletActions(); + b.bulletRemove(); + b.bulletDo(); } game.isTimeSkipping = false; }, @@ -174,7 +177,7 @@ const game = { if (b.inventory[0] === b.activeGun) { let lessDamage = 1 for (let i = 0, len = b.inventory.length; i < len; i++) { - lessDamage *= 0.87 // 1 - 0.13 + lessDamage *= 0.84 // 1 - 0.16 } document.getElementById("mod-entanglement").innerHTML = " " + ((1 - lessDamage) * 100).toFixed(0) + "%" } else { diff --git a/js/player.js b/js/player.js index d7a95c7..c67876e 100644 --- a/js/player.js +++ b/js/player.js @@ -723,6 +723,7 @@ const mech = { fieldEnergyMax: 1, //can be increased by a mod holdingTarget: null, fieldShieldingScale: 1, + timeSkipLastCycle: 0, // these values are set on reset by setHoldDefaults() fieldRange: 155, energy: 0, @@ -1339,7 +1340,32 @@ const mech = { cons[i].stiffness = 0; } } + game.cycle--; //pause all functions that depend on game cycle increasing + if (b.isModTimeSkip) { + game.isTimeSkipping = true; + mech.cycle++; + game.gravity(); + Engine.update(engine, game.delta); + // level.checkZones(); + // level.checkQuery(); + mech.move(); + game.checks(); + // mobs.loop(); + // mech.draw(); + mech.walk_cycle += mech.flipLegs * mech.Vx; + // mech.hold(); + mech.energy += 0.5 * DRAIN; //x1 to undo the energy drain from time speed up, x1.5 to cut energy drain in half + b.fire(); + // b.bulletRemove(); + b.bulletDo(); + game.isTimeSkipping = false; + } + // game.cycle--; //pause all functions that depend on game cycle increasing + // if (b.isModTimeSkip && !game.isTimeSkipping) { //speed up the rate of time + // game.timeSkip(1) + // mech.energy += 1.5 * DRAIN; //x1 to undo the energy drain from time speed up, x1.5 to cut energy drain in half + // } } } else if (mech.holdingTarget && mech.fieldCDcycle < mech.cycle) { //holding, but field button is released mech.wakeCheck(); diff --git a/js/spawn.js b/js/spawn.js index 2051fad..7f2f276 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -80,7 +80,7 @@ const spawn = { }, randomLevelBoss(x, y) { // suckerBoss, laserBoss, tetherBoss, snakeBoss all need a particular level to work so they are not included - const options = ["shooterBoss", "cellBossCulture", "bomberBoss", "timeSkipBoss"] + const options = ["shooterBoss", "cellBossCulture", "bomberBoss"] //, "timeSkipBoss" // const options = ["timeSkipBoss"] spawn[options[Math.floor(Math.random() * options.length)]](x, y) }, @@ -644,7 +644,7 @@ const spawn = { let me = mob[mob.length - 1]; // me.stroke = "transparent"; //used for drawSneaker me.timeSkipLastCycle = 0 - me.eventHorizon = 2000; //required for black hole + me.eventHorizon = 1600; //required for black hole me.seeAtDistance2 = (me.eventHorizon + 2000) * (me.eventHorizon + 2000); //vision limit is event horizon + 2000 me.accelMag = 0.0004 * game.accelScale; // me.frictionAir = 0.005; diff --git a/todo.txt b/todo.txt index 6209e81..1d72872 100644 --- a/todo.txt +++ b/todo.txt @@ -1,9 +1,14 @@ mod - your damage scales with current energy mod - 10% chance after killing a mob to gain a bot that follows you until you exit the map +mod - move extra fast with less energy cost in time dilation +mod - double helix fire two wave bullets, but they do 40% less damage ************** TODO - n-gon ************** +boss level for timeSkipBoss because of game instability for boss on normal levels + boss level needs to be very simple (maybe no other mobs, or no random mobs) + mod - you can no longer see your current health boss mob - just a faster and larger version of a springer mob