jumping bug fix, ceramic plating rebalance, added platforms to aerie level

This commit is contained in:
landgreen
2019-12-06 16:13:26 -08:00
parent dc408dd464
commit 619cdae5ac
5 changed files with 119 additions and 104 deletions

View File

@@ -14,7 +14,7 @@ const b = {
isModBulletsLastLonger: null, isModBulletsLastLonger: null,
modIsImmortal: null, modIsImmortal: null,
modSpores: null, modSpores: null,
isModAoEImmunity: null, isModTempResist: null,
isModDroneOnDamage: null, isModDroneOnDamage: null,
modExtraDmg: null, modExtraDmg: null,
annihilation: null, annihilation: null,
@@ -29,7 +29,7 @@ const b = {
b.modCount = 0; b.modCount = 0;
b.modFireRate = 1; b.modFireRate = 1;
b.modExplosionRadius = 1; b.modExplosionRadius = 1;
b.isModAoEImmunity = false; b.isModTempResist = false;
b.modBulletSize = 1; b.modBulletSize = 1;
b.isModDroneOnDamage = false; b.isModDroneOnDamage = false;
b.modEnergySiphon = 0; b.modEnergySiphon = 0;
@@ -100,10 +100,10 @@ const b = {
}, },
{ {
name: "ceramic plating", name: "ceramic plating",
description: "<strong>immune</strong> to <strong class='color-e'>explosions</strong><br> <strong>immune</strong> to enemy field effects", description: "protection from to high <strong>temperatures</strong><br>5x less <strong class='color-d'>damage</strong> from <strong class='color-e'>explosions</strong> and lasers",
have: false, //5 have: false, //5
effect: () => { effect: () => {
b.isModAoEImmunity = true; //good for guns with explosions b.isModTempResist = true; //good for guns with explosions
} }
}, },
{ {
@@ -414,7 +414,11 @@ const b = {
sub = Matter.Vector.sub(bullet[me].position, player.position); sub = Matter.Vector.sub(bullet[me].position, player.position);
dist = Matter.Vector.magnitude(sub); dist = Matter.Vector.magnitude(sub);
if (dist < radius) { if (dist < radius) {
if (!b.isModAoEImmunity) mech.damage(radius * 0.0002); if (b.isModTempResist) {
mech.damage(radius * 0.00004);
} else {
mech.damage(radius * 0.0002);
}
knock = Matter.Vector.mult(Matter.Vector.normalise(sub), -Math.sqrt(dmg) * player.mass / 30); knock = Matter.Vector.mult(Matter.Vector.normalise(sub), -Math.sqrt(dmg) * player.mass / 30);
player.force.x += knock.x; player.force.x += knock.x;
player.force.y += knock.y; player.force.y += knock.y;
@@ -705,7 +709,7 @@ const b = {
}, },
{ {
name: "rail gun", //1 name: "rail gun", //1
description: "electro-magnetically launch a dense rod<br><strong>hold</strong> left mouse to charge <strong>release</strong> to fire", //and <strong>repel</strong> enemies description: "electro-magnetically launch a dense rod<br><strong>hold</strong> left mouse to charge, <strong>release</strong> to fire", //and <strong>repel</strong> enemies
ammo: 0, ammo: 0,
ammoPack: 7, ammoPack: 7,
have: false, have: false,
@@ -1561,7 +1565,7 @@ const b = {
}, },
{ {
name: "drones", //13 name: "drones", //13
description: "fire <strong>drones</strong> that seek out enemies<br>follows mouse if no targets are found", description: "deploy <strong>drones</strong> that seek out enemies<br>collisions reduce drone <strong>cycles</strong> by 1 second",
ammo: 0, ammo: 0,
ammoPack: 20, ammoPack: 20,
have: false, have: false,
@@ -1579,7 +1583,7 @@ const b = {
restitution: 1, restitution: 1,
dmg: 0.13 + b.modExtraDmg, //damage done in addition to the damage from momentum dmg: 0.13 + b.modExtraDmg, //damage done in addition to the damage from momentum
lookFrequency: 83 + Math.floor(41 * Math.random()), lookFrequency: 83 + Math.floor(41 * Math.random()),
endCycle: game.cycle + Math.floor((900 + 360 * Math.random()) * b.isModBulletsLastLonger), endCycle: game.cycle + Math.floor((1080 + 360 * Math.random()) * b.isModBulletsLastLonger),
classType: "bullet", classType: "bullet",
collisionFilter: { collisionFilter: {
category: 0x000100, category: 0x000100,
@@ -1590,6 +1594,10 @@ const b = {
isFollowMouse: true, isFollowMouse: true,
onDmg() { onDmg() {
this.lockedOn = null this.lockedOn = null
if (this.endCycle > game.cycle + 180) {
this.endCycle -= 60
if (game.cycle + 180 > this.endCycle) this.endCycle = game.cycle + 180
}
}, },
onEnd() {}, onEnd() {},
do() { do() {
@@ -1658,6 +1666,73 @@ const b = {
b.fireProps(mech.crouch ? 14 : 10, mech.crouch ? 40 : 1, dir, me); //cd , speed b.fireProps(mech.crouch ? 14 : 10, mech.crouch ? 40 : 1, dir, me); //cd , speed
b.drawOneBullet(bullet[me].vertices); b.drawOneBullet(bullet[me].vertices);
} }
}, {
name: "laser-bot", //14
description: "deploy <strong>bots</strong> that fire <strong>lasers</strong> at nearby enemies<br><em>bots last for one level</em>",
ammo: 0,
ammoPack: 1,
have: false,
isStarterGun: false,
fire() {
const THRUST = 0.004
const dir = mech.angle;
const me = bullet.length;
const RADIUS = (15 + 8 * Math.random()) * b.modBulletSize
const LENGTH = 0.6 + 0.8 * Math.random()
bullet[me] = Bodies.rectangle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS * LENGTH, RADIUS / LENGTH, {
angle: dir,
// inertia: Infinity,
// friction: 0,
density: 0.001, //normal is 0.001
frictionAir: 0.06,
restitution: 0.8,
dmg: b.modExtraDmg, // 0.14 //damage done in addition to the damage from momentum
minDmgSpeed: 2,
lookFrequency: 7 + Math.floor(17 * Math.random()),
endCycle: Infinity,
classType: "bullet",
collisionFilter: {
category: 0x000100,
mask: 0x010111 //self, mob,map,body collide
},
range: 300,
lockedOn: null,
onDmg() {
this.lockedOn = null
// this.endCycle -= 120; //lose 2 seconds after damage is done
},
onEnd() {},
do() {
if (!(game.cycle % this.lookFrequency)) {
this.lockedOn = null;
let closeDist = Infinity;
for (let i = 0, len = mob.length; i < len; ++i) {
const TARGET_VECTOR = Matter.Vector.sub(mech.pos, mob[i].position)
const DIST = Matter.Vector.magnitude(TARGET_VECTOR);
// DIST - mob[i].radius < this.range &&
if (DIST < closeDist && Matter.Query.ray(map, this.position, mob[i].position).length === 0) {
closeDist = DIST;
this.lockedOn = mob[i]
}
}
}
const distanceToPlayer = Matter.Vector.magnitude(Matter.Vector.sub(this.position, mech.pos))
if (this.lockedOn) { //accelerate towards mobs
this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, this.lockedOn.position)), -this.mass * THRUST)
this.frictionAir = 0.06
} else if (distanceToPlayer > 100) {
this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, mech.pos)), -this.mass * THRUST * 0.3)
this.frictionAir = 0.02
} else { //must be close to player //add some random motion
this.frictionAir = 0
}
}
})
b.fireProps(mech.crouch ? 5 : 10, 15, dir, me); //cd , speed
b.drawOneBullet(bullet[me].vertices);
}
}, },
// { // {
// name: "dwarf star", //14 // name: "dwarf star", //14
@@ -1820,78 +1895,5 @@ const b = {
// } // }
// }, // },
// { // {
// //draw a halo, since there will only be 1-3 balls
// name: "junk-bots", //14
// description: "release unreliable <strong>drones</strong> that defend the space around the player<br><strong>collisions</strong> may cause <strong class='color-d'>malfunction</strong>",
// ammo: 0,
// ammoPack: 15,
// have: false,
// isStarterGun: false,
// fire() {
// const THRUST = 0.004
// const dir = mech.angle + 0.2 * (Math.random() - 0.5);
// const me = bullet.length;
// const RADIUS = (15 + 8 * Math.random()) * b.modBulletSize
// const LENGTH = 0.6 + 0.8 * Math.random()
// bullet[me] = Bodies.rectangle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS * LENGTH, RADIUS / LENGTH, {
// isOrb: true,
// angle: dir,
// // inertia: Infinity,
// // friction: 0,
// density: 0.001, //normal is 0.001
// frictionAir: 0.06,
// restitution: 0.8,
// dmg: b.modExtraDmg, // 0.14 //damage done in addition to the damage from momentum
// minDmgSpeed: 2,
// lookFrequency: 7 + Math.floor(17 * Math.random()),
// endCycle: game.cycle + Math.floor((200 + 60 * Math.random()) * b.isModBulletsLastLonger),
// classType: "bullet",
// collisionFilter: {
// category: 0x000100,
// mask: 0x010111 //self, mob,map,body collide
// },
// range: 300,
// lockedOn: null,
// onDmg() {
// this.lockedOn = null
// // this.endCycle -= 120; //lose 2 seconds after damage is done
// },
// onEnd() {},
// do() {
// if (game.cycle + 120 > this.endCycle) { //fall and die
// this.force.y += this.mass * 0.0012;
// } else {
// if (!(game.cycle % this.lookFrequency)) {
// this.lockedOn = null;
// let closeDist = Infinity;
// for (let i = 0, len = mob.length; i < len; ++i) {
// const TARGET_VECTOR = Matter.Vector.sub(mech.pos, mob[i].position)
// const DIST = Matter.Vector.magnitude(TARGET_VECTOR);
// // DIST - mob[i].radius < this.range &&
// if (DIST < closeDist && Matter.Query.ray(map, this.position, mob[i].position).length === 0) {
// closeDist = DIST;
// this.lockedOn = mob[i]
// }
// }
// }
// const distanceToPlayer = Matter.Vector.magnitude(Matter.Vector.sub(this.position, mech.pos))
// if (this.lockedOn) { //accelerate towards mobs
// this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, this.lockedOn.position)), -this.mass * THRUST)
// this.frictionAir = 0.06
// } else if (distanceToPlayer > 100) {
// this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, mech.pos)), -this.mass * THRUST * 0.3)
// this.frictionAir = 0.02
// } else { //must be close to player //add some random motion
// this.frictionAir = 0
// }
// }
// }
// })
// b.fireProps(mech.crouch ? 5 : 10, 15, dir, me); //cd , speed
// b.drawOneBullet(bullet[me].vertices);
// }
// },
] ]
}; };

View File

@@ -34,10 +34,10 @@ function playerOnGroundCheck(event) {
let pair = pairs[i]; let pair = pairs[i];
if (pair.bodyA === jumpSensor) { if (pair.bodyA === jumpSensor) {
mech.standingOn = pair.bodyB; //keeping track to correctly provide recoil on jump mech.standingOn = pair.bodyB; //keeping track to correctly provide recoil on jump
enter(); if (mech.standingOn.alive !== true) enter();
} else if (pair.bodyB === jumpSensor) { } else if (pair.bodyB === jumpSensor) {
mech.standingOn = pair.bodyA; //keeping track to correctly provide recoil on jump mech.standingOn = pair.bodyA; //keeping track to correctly provide recoil on jump
enter(); if (mech.standingOn.alive !== true) enter();
} }
} }
mech.numTouching = 0; mech.numTouching = 0;

View File

@@ -16,7 +16,7 @@ const level = {
// game.difficulty = 6; //for testing to simulate possible mobs spawns // game.difficulty = 6; //for testing to simulate possible mobs spawns
// b.giveGuns(1) // b.giveGuns(1)
// mech.fieldUpgrades[2].effect(); // mech.fieldUpgrades[2].effect();
// b.giveMod(13) // b.giveMod(5)
// spawn.pickList = ["ghoster", "ghoster"] // spawn.pickList = ["ghoster", "ghoster"]
this.intro(); //starting level this.intro(); //starting level
@@ -50,6 +50,7 @@ const level = {
difficultyDecrease(num = 1) { //used in easy mode for game.reset() difficultyDecrease(num = 1) { //used in easy mode for game.reset()
for (let i = 0; i < num; i++) { for (let i = 0; i < num; i++) {
game.dmgScale -= 0.2; //damage done by mobs increases each level game.dmgScale -= 0.2; //damage done by mobs increases each level
if (game.dmgScale < 0.1) game.dmgScale = 0.1;
b.dmgScale /= 0.95; //damage done by player decreases each level b.dmgScale /= 0.95; //damage done by player decreases each level
game.accelScale /= 1.05 //mob acceleration increases each level game.accelScale /= 1.05 //mob acceleration increases each level
game.lookFreqScale /= 0.95 //mob cycles between looks decreases each level game.lookFreqScale /= 0.95 //mob cycles between looks decreases each level
@@ -684,7 +685,10 @@ const level = {
spawn.mapRect(4700, -2910, 100, 510); spawn.mapRect(4700, -2910, 100, 510);
spawn.mapRect(3700, -2600, 300, 50); spawn.mapRect(3700, -2600, 300, 50);
spawn.mapRect(4100, -2900, 900, 50); spawn.mapRect(4100, -2900, 900, 50);
spawn.mapRect(3450, -2300, 1650, 100); spawn.mapRect(3450, -2300, 750, 100);
spawn.mapRect(4300, -2300, 750, 100);
spawn.mapRect(4150, -1600, 200, 25);
spawn.mapRect(4150, -700, 200, 25);
//exit room on top of tower //exit room on top of tower
spawn.mapRect(3700, -3700, 600, 50); spawn.mapRect(3700, -3700, 600, 50);
spawn.mapRect(3700, -3700, 50, 500); spawn.mapRect(3700, -3700, 50, 500);

View File

@@ -231,22 +231,25 @@ const mobs = {
// ctx.lineDashOffset = 6*(game.cycle % 215); // ctx.lineDashOffset = 6*(game.cycle % 215);
if (this.distanceToPlayer() < this.laserRange) { if (this.distanceToPlayer() < this.laserRange) {
//if (Math.random()>0.2 && this.seePlayer.yes && this.distanceToPlayer2()<800000) { //if (Math.random()>0.2 && this.seePlayer.yes && this.distanceToPlayer2()<800000) {
if (!b.isModAoEImmunity) { if (b.isModTempResist) {
mech.damage(0.00006 * game.dmgScale);
} else {
mech.damage(0.0003 * game.dmgScale); mech.damage(0.0003 * game.dmgScale);
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.005
ctx.beginPath();
ctx.moveTo(this.position.x, this.position.y);
ctx.lineTo(mech.pos.x, mech.pos.y);
ctx.lineTo(mech.pos.x + (Math.random() - 0.5) * 3000, mech.pos.y + (Math.random() - 0.5) * 3000);
ctx.lineWidth = 2;
ctx.strokeStyle = "rgb(255,0,170)";
ctx.stroke();
ctx.beginPath();
ctx.arc(mech.pos.x, mech.pos.y, 40, 0, 2 * Math.PI);
ctx.fillStyle = "rgba(255,0,170,0.15)";
ctx.fill();
} }
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.004
ctx.beginPath();
ctx.moveTo(this.position.x, this.position.y);
ctx.lineTo(mech.pos.x, mech.pos.y);
ctx.lineTo(mech.pos.x + (Math.random() - 0.5) * 3000, mech.pos.y + (Math.random() - 0.5) * 3000);
ctx.lineWidth = 2;
ctx.strokeStyle = "rgb(255,0,170)";
ctx.stroke();
ctx.beginPath();
ctx.arc(mech.pos.x, mech.pos.y, 40, 0, 2 * Math.PI);
ctx.fillStyle = "rgba(255,0,170,0.15)";
ctx.fill();
} }
ctx.beginPath(); ctx.beginPath();
ctx.arc(this.position.x, this.position.y, this.laserRange * 0.9, 0, 2 * Math.PI); ctx.arc(this.position.x, this.position.y, this.laserRange * 0.9, 0, 2 * Math.PI);
@@ -320,7 +323,12 @@ const mobs = {
vertexCollision(this.position, look, [player]); vertexCollision(this.position, look, [player]);
// hitting player // hitting player
if (best.who === player) { if (best.who === player) {
dmg = 0.004 * game.dmgScale; if (b.isModTempResist) {
dmg = 0.0008 * game.dmgScale;
} else {
dmg = 0.004 * game.dmgScale;
}
mech.damage(dmg); mech.damage(dmg);
//draw damage //draw damage
ctx.fillStyle = color; ctx.fillStyle = color;

View File

@@ -456,9 +456,10 @@ const spawn = {
this.healthBar(); this.healthBar();
//when player is inside event horizon //when player is inside event horizon
if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon && !b.isModAoEImmunity) { if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon) {
mech.damage(0.00015 * game.dmgScale); mech.damage(0.00015 * game.dmgScale);
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01 if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.007
const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x); 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.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.y -= 0.96 * player.mass * game.g * Math.sin(angle);
@@ -545,9 +546,9 @@ const spawn = {
ctx.fillStyle = "rgba(0,0,0,0.05)"; ctx.fillStyle = "rgba(0,0,0,0.05)";
ctx.fill(); ctx.fill();
//when player is inside event horizon //when player is inside event horizon
if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon && !b.isModAoEImmunity) { if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon) {
mech.damage(0.00015 * game.dmgScale); mech.damage(0.00015 * game.dmgScale);
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01 if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.007
const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x); 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.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.y -= 1.2 * Math.sin(angle) * player.mass * game.g;