removed junk-bot, rail gun balance and bug fixes (working on dwarf star mines)

This commit is contained in:
landgreen
2019-11-28 16:35:10 -08:00
parent 12ab87ea1d
commit f739e62a7e
7 changed files with 1288 additions and 1132 deletions

View File

@@ -150,7 +150,7 @@
<details> <details>
<summary>settings</summary> <summary>settings</summary>
<div id="details-div"> <div id="details-div">
<label for="body-damage" title="allow damage from heavy, fast moving blocks">damage from blocks:</label> <label for="body-damage" title="allow damage from heavy, fast moving blocks">block collision damage:</label>
<input type="checkbox" id="body-damage" name="body-damage" checked> <input type="checkbox" id="body-damage" name="body-damage" checked>
<br><br> <br><br>
<label for="difficulty-select" title="effects: number of mobs, damage done by mobs, damage done to mobs, mob speed">combat difficulty:</label> <label for="difficulty-select" title="effects: number of mobs, damage done by mobs, damage done to mobs, mob speed">combat difficulty:</label>

View File

@@ -19,6 +19,7 @@ const b = {
modExtraDmg: null, modExtraDmg: null,
annihilation: null, annihilation: null,
fullHeal: null, fullHeal: null,
modSquirrelFx: 1,
setModDefaults() { setModDefaults() {
b.modCount = 0; b.modCount = 0;
b.modFireRate = 1; b.modFireRate = 1;
@@ -35,6 +36,7 @@ const b = {
b.modExtraDmg = 0; b.modExtraDmg = 0;
b.modAnnihilation = false; b.modAnnihilation = false;
b.isModFullHeal = false; b.isModFullHeal = false;
b.modSquirrelFx = 1;
mech.Fx = 0.015; mech.Fx = 0.015;
mech.jumpForce = 0.38; mech.jumpForce = 0.38;
mech.throwChargeRate = 2; mech.throwChargeRate = 2;
@@ -145,7 +147,7 @@ const b = {
}, },
{ {
name: "annihilation", name: "annihilation",
description: "after you touch any enemy, they are <strong class='color-l'>annihilated</strong><br><em>touching enemies damages you, but destroys them</em>", description: "after you touch any enemy, they are <strong class='color-l'>annihilated</strong><br><em>touching enemies <span class='color-d'>damages</span> you, but <span class='color-d'>destroys</span> them</em>",
have: false, //12 have: false, //12
effect: () => { //good with mods that heal: superconductive healing, entropy transfer effect: () => { //good with mods that heal: superconductive healing, entropy transfer
b.modAnnihilation = true b.modAnnihilation = true
@@ -175,7 +177,8 @@ const b = {
description: "jump higher and move faster", description: "jump higher and move faster",
have: false, //15 have: false, //15
effect: () => { // effect: () => { //
mech.Fx = 0.015 * 1.2; b.modSquirrelFx = 1.2;
mech.Fx = 0.015 * b.modSquirrelFx;
mech.jumpForce = 0.38 * 1.1; mech.jumpForce = 0.38 * 1.1;
} }
}, },
@@ -560,7 +563,7 @@ const b = {
} }
} }
}; };
const checkforCollisions = function () { const checkForCollisions = function () {
best = { best = {
x: null, x: null,
y: null, y: null,
@@ -595,7 +598,7 @@ const b = {
path[path.length] = Matter.Vector.add(Matter.Vector.mult(r, range), path[path.length - 1]); path[path.length] = Matter.Vector.add(Matter.Vector.mult(r, range), path[path.length - 1]);
}; };
//beam before reflection //beam before reflection
checkforCollisions(); checkForCollisions();
if (best.dist2 != Infinity) { if (best.dist2 != Infinity) {
//if hitting something //if hitting something
path[path.length - 1] = { path[path.length - 1] = {
@@ -608,7 +611,7 @@ const b = {
reflection(); reflection();
//ugly bug fix: this stops the reflection on a bug where the beam gets trapped inside a body //ugly bug fix: this stops the reflection on a bug where the beam gets trapped inside a body
let who = best.who; let who = best.who;
checkforCollisions(); checkForCollisions();
if (best.dist2 != Infinity) { if (best.dist2 != Infinity) {
//if hitting something //if hitting something
path[path.length - 1] = { path[path.length - 1] = {
@@ -621,7 +624,7 @@ const b = {
//ugly bug fix: this stops the reflection on a bug where the beam gets trapped inside a body //ugly bug fix: this stops the reflection on a bug where the beam gets trapped inside a body
if (who !== best.who) { if (who !== best.who) {
reflection(); reflection();
checkforCollisions(); checkForCollisions();
if (best.dist2 != Infinity) { if (best.dist2 != Infinity) {
//if hitting something //if hitting something
path[path.length - 1] = { path[path.length - 1] = {
@@ -652,16 +655,17 @@ const b = {
ctx.globalAlpha = 1; ctx.globalAlpha = 1;
} }
} }
}, { },
name: "rail gun", //15 {
description: "<strong>hold left mouse</strong> to charge and release to fire<br>charging repels enemies and drains <span class='color-f'>field energy</span><br><em><strong>crouching</strong> improves charging and reduces recoil</em>", name: "rail gun", //1
description: "<strong>hold left mouse</strong> to charge and release to fire<br>charging repels small enemies<br><em>crouching charges quicker and reduces recoil</em>",
ammo: 0, ammo: 0,
ammoPack: 9, ammoPack: 12,
have: false, have: false,
isStarterGun: false, isStarterGun: false,
fire() { fire() {
const me = bullet.length; const me = bullet.length;
bullet[me] = Bodies.rectangle(9, -90, 0.01 * b.modBulletSize, 0.0015 * b.modBulletSize, { bullet[me] = Bodies.rectangle(9, -90, 0.01 * b.modBulletSize, 0.0017 * b.modBulletSize, {
// density: 0.0015, //frictionAir: 0.01, //restitution: 0, // density: 0.0015, //frictionAir: 0.01, //restitution: 0,
angle: 0, angle: 0,
friction: 0.5, friction: 0.5,
@@ -683,15 +687,10 @@ const b = {
bullet[me].charge = 0; bullet[me].charge = 0;
bullet[me].do = function () { bullet[me].do = function () {
if (this.isCharging) { if (this.isCharging) {
const DRAIN = 0.0001 + mech.fieldRegen if ((!game.mouseDown && this.charge > 0.5)) { //fire on mouse release
if ((!game.mouseDown && this.charge > 0.5) || mech.fieldMeter < DRAIN) { //fire on mouse release
this.isCharging = false this.isCharging = false
if (mech.fieldMeter < DRAIN) {
mech.fireCDcycle = mech.cycle + 120; // long CD if out of mana
} else {
mech.fireCDcycle = mech.cycle + 2; // set fire cool down mech.fireCDcycle = mech.cycle + 2; // set fire cool down
} Matter.Body.scale(this, 8000, 8000) // show the bullet by scaling it up (don't judge me... I know this is a bad way to do it)
Matter.Body.scale(this, 10000, 10000) // un hide the bullet by scaling it up (don't judge me... I know this is a bad way to do it)
this.endCycle = game.cycle + Math.floor(140 * b.isModBulletsLastLonger) this.endCycle = game.cycle + Math.floor(140 * b.isModBulletsLastLonger)
this.collisionFilter.category = 0x000100 this.collisionFilter.category = 0x000100
Matter.Body.setPosition(this, { Matter.Body.setPosition(this, {
@@ -706,34 +705,45 @@ const b = {
}); });
//knock back //knock back
const KNOCK = ((mech.crouch) ? 0.1 : 0.7) * b.modBulletSize * b.modBulletSize * this.charge * this.charge const KNOCK = ((mech.crouch) ? 0.1 : 0.5) * b.modBulletSize * b.modBulletSize * this.charge * this.charge
player.force.x -= KNOCK * Math.cos(mech.angle) player.force.x -= KNOCK * Math.cos(mech.angle)
player.force.y -= KNOCK * Math.sin(mech.angle) * 0.3 //reduce knock back in vertical direction to stop super jumps player.force.y -= KNOCK * Math.sin(mech.angle) * 0.35 //reduce knock back in vertical direction to stop super jumps
//push away blocks on fire //push away blocks when firing
const RANGE = 450 * this.charge const RANGE = 450 * this.charge
for (let i = 0, len = body.length; i < len; ++i) { for (let i = 0, len = body.length; i < len; ++i) {
const SUB = Matter.Vector.sub(body[i].position, mech.pos) const SUB = Matter.Vector.sub(body[i].position, mech.pos)
const DISTANCE = Matter.Vector.magnitude(SUB) const DISTANCE = Matter.Vector.magnitude(SUB)
if (DISTANCE < RANGE) { if (DISTANCE < RANGE) {
const DEPTH = RANGE - DISTANCE const DEPTH = Math.max(RANGE - DISTANCE, 100)
const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.005 * Math.sqrt(DEPTH) * Math.sqrt(body[i].mass)) const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.005 * Math.sqrt(DEPTH) * Math.sqrt(body[i].mass))
body[i].force.x += FORCE.x body[i].force.x += FORCE.x
body[i].force.y += FORCE.y - body[i].mass * (game.g * 25); //kick up a bit to give them some arc body[i].force.y += FORCE.y - body[i].mass * (game.g * 1.5); //kick up a bit to give them some arc
} }
} }
//push mobs around player when firing
// for (let i = 0, len = mob.length; i < len; ++i) {
// const SUB = Matter.Vector.sub(mob[i].position, mech.pos)
// const DISTANCE = Matter.Vector.magnitude(SUB)
// if (DISTANCE < RANGE) {
// const DEPTH = RANGE - DISTANCE
// const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.00000001 * DEPTH * DEPTH * DEPTH * Math.sqrt(mob[i].mass))
// mob[i].force.x += FORCE.x
// mob[i].force.y += FORCE.y
// }
// }
} else { // charging on mouse down } else { // charging on mouse down
mech.fieldMeter -= DRAIN;
mech.fireCDcycle = Infinity //can't fire until mouse is released mech.fireCDcycle = Infinity //can't fire until mouse is released
if (mech.crouch) { if (mech.crouch) {
this.charge = this.charge * 0.97 + 0.03 // this.charge converges to 1 this.charge = this.charge * 0.97 + 0.03 // this.charge converges to 1
} else { } else {
this.charge = this.charge * 0.99 + 0.01 // this.charge converges to 1 this.charge = this.charge * 0.98 + 0.02 // this.charge converges to 1
} }
//gently push away mobs while charging //gently push away mobs while charging
const RANGE = 300 * this.charge const RANGE = 350 * this.charge
for (let i = 0, len = mob.length; i < len; ++i) { for (let i = 0, len = mob.length; i < len; ++i) {
const SUB = Matter.Vector.sub(mob[i].position, mech.pos) const SUB = Matter.Vector.sub(mob[i].position, mech.pos)
const DISTANCE = Matter.Vector.magnitude(SUB) const DISTANCE = Matter.Vector.magnitude(SUB)
@@ -861,31 +871,8 @@ const b = {
} }
} }
} }
// }, { },
// name: "kinetic slugs", //1 {
// description: "fire a large <strong>rod</strong> that does excessive physical <span class='color-d'>damage</span><br><em>high recoil</em>",
// ammo: 0,
// ammoPack: 5,
// have: false,
// isStarterGun: true,
// fire() {
// b.muzzleFlash(45);
// // mobs.alert(800);
// const me = bullet.length;
// const dir = mech.angle;
// bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), 70 * b.modBulletSize, 30 * b.modBulletSize, b.fireAttributes(dir));
// b.fireProps(mech.crouch ? 55 : 40, 50, dir, me); //cd , speed
// bullet[me].endCycle = game.cycle + Math.floor(180 * b.isModBulletsLastLonger);
// bullet[me].do = function () {
// this.force.y += this.mass * 0.0005;
// };
// //knock back
// const KNOCK = ((mech.crouch) ? 0.025 : 0.25) * b.modBulletSize * b.modBulletSize
// player.force.x -= KNOCK * Math.cos(dir)
// player.force.y -= KNOCK * Math.sin(dir) * 0.3 //reduce knock back in vertical direction to stop super jumps
// }
}, {
name: "minigun", //2 name: "minigun", //2
description: "rapidly fire a stream of small <strong>bullets</strong>", description: "rapidly fire a stream of small <strong>bullets</strong>",
ammo: 0, ammo: 0,
@@ -1203,7 +1190,7 @@ const b = {
ammo: 0, ammo: 0,
ammoPack: 9, ammoPack: 9,
have: false, have: false,
isStarterGun: true, isStarterGun: false,
fire() { fire() {
const me = bullet.length; const me = bullet.length;
const dir = mech.angle; // + Math.random() * 0.05; const dir = mech.angle; // + Math.random() * 0.05;
@@ -1519,12 +1506,12 @@ const b = {
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS, { bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS, {
angle: dir, angle: dir,
inertia: Infinity, inertia: Infinity,
friction: 0, friction: 0.05,
frictionAir: 0.0005, frictionAir: 0.0005,
restitution: 1, restitution: 1,
dmg: 0.14 + b.modExtraDmg, //damage done in addition to the damage from momentum dmg: 0.14 + b.modExtraDmg, //damage done in addition to the damage from momentum
lookFrequency: 79 + Math.floor(37 * Math.random()), lookFrequency: 79 + Math.floor(37 * Math.random()),
endCycle: game.cycle + Math.floor((780 + 360 * Math.random()) * b.isModBulletsLastLonger), endCycle: game.cycle + Math.floor((960 + 360 * Math.random()) * b.isModBulletsLastLonger),
classType: "bullet", classType: "bullet",
collisionFilter: { collisionFilter: {
category: 0x000100, category: 0x000100,
@@ -1538,6 +1525,10 @@ const b = {
}, },
onEnd() {}, onEnd() {},
do() { do() {
if (game.cycle + 180 > this.endCycle) { //fall and die
this.force.y += this.mass * 0.0012;
this.restitution = 0.2;
} else {
this.force.y += this.mass * 0.0002; this.force.y += this.mass * 0.0002;
//find mob targets //find mob targets
if (!(game.cycle % this.lookFrequency)) { if (!(game.cycle % this.lookFrequency)) {
@@ -1594,83 +1585,245 @@ const b = {
}); });
} }
} }
}
}) })
b.fireProps(mech.crouch ? 19 : 15, mech.crouch ? 35 : 1, dir, me); //cd , speed b.fireProps(mech.crouch ? 19 : 15, mech.crouch ? 35 : 1, dir, me); //cd , speed
b.drawOneBullet(bullet[me].vertices); b.drawOneBullet(bullet[me].vertices);
} }
}, {
//draw a halo, since there will only be 1-3 balls
name: "junk-bots", //14
description: "release large <strong>drones</strong> that defend the space around the player<br>despawn after not doing <span class='color-d'>damage</span> for 3 seconds",
ammo: 0,
ammoPack: 20,
have: false,
isStarterGun: true,
fire() {
const THRUST = 0.004
const dir = mech.angle + 0.2 * (Math.random() - 0.5);
const me = bullet.length;
const RADIUS = (18 + 5 * 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,
frictionAir: 0.06,
restitution: 1,
dmg: b.modExtraDmg, // 0.14 //damage done in addition to the damage from momentum
minDmgSpeed: 2,
lookFrequency: 37 + Math.floor(37 * Math.random()),
endCycle: game.cycle + Math.floor((170 + 120 * Math.random()) * b.isModBulletsLastLonger),
classType: "bullet",
collisionFilter: {
category: 0x000100,
mask: 0x010111 //self, mob,map,body collide
}, },
range: 700, // {
lockedOn: null, // name: "dwarf star", //14
onDmg() { // description: "drop a mine that gravitational pulls in matter",
// ammo: 0,
// ammoPack: 1000,
// have: false,
// isStarterGun: false,
// fire() {
// const me = bullet.length;
// const dir = mech.angle
// const TOTAL_CYCLES = 1020
// bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(dir), mech.pos.y + 30 * Math.sin(dir), 3 * b.modBulletSize, {
// density: 0.05,
// //frictionAir: 0.01,
// restitution: 0,
// angle: 0,
// friction: 1,
// // frictionAir: 1,
// endCycle: game.cycle + TOTAL_CYCLES,
// dmg: b.modExtraDmg, //damage done in addition to the damage from momentum
// classType: "bullet",
// collisionFilter: {
// category: 0x000100,
// mask: 0x010011 //mask: 0x000101, //for self collision
// },
// minDmgSpeed: 5,
// range: 0,
// onDmg() {
// this.endCycle = 0; // this.endCycle = 0;
this.lockedOn = null // }, //this.endCycle = 0 //triggers despawn
this.endCycle = game.cycle + Math.floor(180 * b.isModBulletsLastLonger) // onEnd() {},
}, // do() {
onEnd() {}, // this.force.y += this.mass * 0.005;
do() { // this.range += 0.5
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);
if (DIST < this.range && 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)) // //damage nearby mobs
if (this.lockedOn) { //accelerate towards mobs // const dmg = b.dmgScale * 0.02
this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, this.lockedOn.position)), -this.mass * THRUST) // for (let i = 0, len = mob.length; i < len; ++i) {
this.frictionAir = 0.06 // if (mob[i].alive) {
} else if (distanceToPlayer > 0.2 * this.range) { // sub = Matter.Vector.sub(this.position, mob[i].position);
this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, mech.pos)), -this.mass * THRUST * 0.3) // dist = Matter.Vector.magnitude(sub) - mob[i].radius;
this.frictionAir = 0.02 // if (dist < this.range) {
// // speed cap instead of friction to give more agility // mob[i].damage(dmg);
// if (this.speed > 14) { // mob[i].locatePlayer();
// Matter.Body.setVelocity(this, {
// x: this.velocity.x * 0.97,
// y: this.velocity.y * 0.97
// });
// } // }
} else { //must be close to player //add some random motion // }
this.frictionAir = 0 // }
}
} // //pull in body, and power ups?, and bullets?
}) // for (let i = 0, len = body.length; i < len; ++i) {
b.fireProps(mech.crouch ? 40 : 10, mech.crouch ? 40 : 10, dir, me); //cd , speed // sub = Matter.Vector.sub(this.position, body[i].position);
b.drawOneBullet(bullet[me].vertices); // dist = Matter.Vector.magnitude(sub)
} // if (dist < this.range) {
}, ] // this.range += body[i].mass * 2
// Matter.World.remove(engine.world, body[i]);
// body.splice(i, 1);
// break;
// }
// }
// //draw
// const opacity = (this.endCycle - game.cycle) / TOTAL_CYCLES
// ctx.fillStyle = `rgba(170,220,255,${opacity})`;
// ctx.beginPath();
// ctx.arc(this.position.x, this.position.y, this.range, 0, 2 * Math.PI);
// ctx.fill();
// }
// });
// b.fireProps(60, 0, dir, me); //cd , speed
// }
// },
// {
// name: "kinetic slugs", //1
// description: "fire a large <strong>rod</strong> that does excessive physical <span class='color-d'>damage</span><br><em>high recoil</em>",
// ammo: 0,
// ammoPack: 5,
// have: false,
// isStarterGun: true,
// fire() {
// b.muzzleFlash(45);
// // mobs.alert(800);
// const me = bullet.length;
// const dir = mech.angle;
// bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), 70 * b.modBulletSize, 30 * b.modBulletSize, b.fireAttributes(dir));
// b.fireProps(mech.crouch ? 55 : 40, 50, dir, me); //cd , speed
// bullet[me].endCycle = game.cycle + Math.floor(180 * b.isModBulletsLastLonger);
// bullet[me].do = function () {
// this.force.y += this.mass * 0.0005;
// };
// //knock back
// const KNOCK = ((mech.crouch) ? 0.025 : 0.25) * b.modBulletSize * b.modBulletSize
// player.force.x -= KNOCK * Math.cos(dir)
// player.force.y -= KNOCK * Math.sin(dir) * 0.3 //reduce knock back in vertical direction to stop super jumps
// },
// {
// name: "triboelectricty", //14
// description: "release <strong>particles</strong> that quickly seek out targets",
// ammo: 0,
// ammoPack: 40,
// have: false,
// isStarterGun: true,
// fire() {
// const dir = mech.angle + 0.2 * (Math.random() - 0.5);
// const me = bullet.length;
// const RADIUS = 6 * b.modBulletSize
// bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS, {
// angle: dir,
// inertia: Infinity,
// // friction: 0.05,
// // frictionAir: 0.05,
// restitution: 0.8,
// dmg: 0.14 + b.modExtraDmg, //damage done in addition to the damage from momentum
// lookFrequency: 3,
// endCycle: game.cycle + Math.floor(120 * b.isModBulletsLastLonger),
// classType: "bullet",
// collisionFilter: {
// category: 0x000100,
// mask: 0x010111 //self collide
// },
// minDmgSpeed: 0,
// lockedOn: null,
// isFollowMouse: true,
// onDmg() {
// this.endCycle = 0;
// },
// onEnd() {},
// do() {
// if (this.lockedOn) { //accelerate towards mobs
// this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, this.lockedOn.position)), -this.mass * 0.01)
// Matter.Body.setVelocity(this, {
// x: this.velocity.x * 0.93,
// y: this.velocity.y * 0.93
// });
// } else {
// this.force.y += this.mass * 0.0004;
// }
// }
// })
// b.fireProps(mech.crouch ? 19 : 15, mech.crouch ? 45 : 30, dir, me); //cd , speed
// b.drawOneBullet(bullet[me].vertices);
// //find mob targets
// let closeDist = Infinity;
// for (let i = 0, len = mob.length; i < len; ++i) {
// if (
// Matter.Query.ray(map, bullet[me].position, mob[i].position).length === 0 &&
// Matter.Query.ray(body, bullet[me].position, mob[i].position).length === 0
// ) {
// const TARGET_VECTOR = Matter.Vector.sub(bullet[me].position, mob[i].position)
// const DIST = Matter.Vector.magnitude(TARGET_VECTOR);
// if (DIST < closeDist) {
// closeDist = DIST;
// bullet[me].lockedOn = mob[i]
// }
// }
// }
// }
// },
// {
// //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 <span class='color-d'>malfunction</span>",
// 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

@@ -608,7 +608,7 @@ const game = {
} }
if (!(mech.cycle % 420)) { if (!(mech.cycle % 420)) {
remove = function (who) { fallCheck = function (who) {
let i = who.length; let i = who.length;
while (i--) { while (i--) {
if (who[i].position.y > game.fallHeight) { if (who[i].position.y > game.fallHeight) {
@@ -617,9 +617,9 @@ const game = {
} }
} }
}; };
remove(mob); fallCheck(mob);
remove(body); fallCheck(body);
remove(powerUp); fallCheck(powerUp);
} }
}, },
testingOutput() { testingOutput() {

View File

@@ -2,8 +2,15 @@
/* TODO: ******************************************* /* TODO: *******************************************
***************************************************** *****************************************************
gun: Spirit Bomb gun: like drones, but fast moving and short lived
dies after doing damage
gun: Spirit Bomb (singularity)
use charge up like rail gun use charge up like rail gun
electricity graphics like plasma torch
suck in nearby mobs, power ups?, blocks?
sucked in stuff increase size
uses energy
left and right click mouse icons for text displays left and right click mouse icons for text displays
@@ -17,7 +24,7 @@ mod: + move speed and jump height
this could just slow the mobs down instead? this could just slow the mobs down instead?
how? how?
rework junk bot, or remove it rework junk bot
it's behavior is too unpredictable it's behavior is too unpredictable
range is unclear range is unclear
having the bullets last long after doing dmg isn't fun having the bullets last long after doing dmg isn't fun

View File

@@ -14,9 +14,9 @@ const level = {
start() { start() {
if (level.levelsCleared === 0) { if (level.levelsCleared === 0) {
// 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(14)
// mech.fieldUpgrades[7].effect(); // mech.fieldUpgrades[2].effect();
b.giveMod(15) // b.giveMod(15)
// spawn.pickList = ["ghoster", "ghoster"] // spawn.pickList = ["ghoster", "ghoster"]
this.intro(); //starting level this.intro(); //starting level

View File

@@ -65,12 +65,13 @@ const mech = {
}, },
defaultMass: 5, defaultMass: 5,
mass: 5, mass: 5,
FxNotHolding: 0.015,
Fx: 0.015, //run Force on ground //this is reset in b.setModDefaults() Fx: 0.015, //run Force on ground //this is reset in b.setModDefaults()
FxAir: 0.015, //run Force in Air FxAir: 0.015, //run Force in Air
definePlayerMass(mass = mech.defaultMass) { definePlayerMass(mass = mech.defaultMass) {
Matter.Body.setMass(player, mass); Matter.Body.setMass(player, mass);
//reduce air and ground move forces //reduce air and ground move forces
this.Fx = 0.075 / mass this.Fx = 0.075 / mass * b.modSquirrelFx
this.FxAir = 0.375 / mass / mass this.FxAir = 0.375 / mass / mass
//make player stand a bit lower when holding heavy masses //make player stand a bit lower when holding heavy masses
this.yOffWhen.stand = Math.max(this.yOffWhen.crouch, Math.min(49, 49 - (mass - 5) * 6)) this.yOffWhen.stand = Math.max(this.yOffWhen.crouch, Math.min(49, 49 - (mass - 5) * 6))
@@ -212,11 +213,10 @@ const mech = {
this.yOff = this.yOffWhen.jump; this.yOff = this.yOffWhen.jump;
this.hardLandCD = mech.cycle + Math.min(momentum / 6 - 6, 40) this.hardLandCD = mech.cycle + Math.min(momentum / 6 - 6, 40)
if (game.isBodyDamage && momentum > 200 && player.velocity.y > 20) { //falling damage if (game.isBodyDamage && player.velocity.y > 26 && momentum > 165) { //falling damage
mech.damageImmune = mech.cycle + 30; //player is immune to collision damage for 30 cycles mech.damageImmune = mech.cycle + 30; //player is immune to collision damage for 30 cycles
let dmg = Math.sqrt(momentum - 200) * 0.01 let dmg = Math.sqrt(momentum - 165) * 0.01
console.log(dmg, momentum, player.velocity.y) dmg = Math.min(Math.max(dmg, 0.02), 0.20);
dmg = Math.min(Math.max(dmg, 0.02), 0.15);
mech.damage(dmg); mech.damage(dmg);
} }
} else { } else {
@@ -661,10 +661,6 @@ const mech = {
this.grabRange = 175; this.grabRange = 175;
this.fieldArc = 0.2; //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) this.fieldArc = 0.2; //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
this.calculateFieldThreshold(); //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) this.calculateFieldThreshold(); //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
this.jumpForce = 0.38;
this.Fx = 0.015; //run Force on ground
this.FxAir = 0.015; //run Force in Air
this.gravity = 0.0019;
mech.isBodiesAsleep = true; mech.isBodiesAsleep = true;
mech.wakeCheck(); mech.wakeCheck();
// this.phaseBlocks(0x011111) // this.phaseBlocks(0x011111)

View File

@@ -9,7 +9,7 @@ const powerUps = {
}, },
effect() { effect() {
let heal = (this.size / 40) ** 2 let heal = (this.size / 40) ** 2
if (b.isModFullHeal) heal = Infinity if (b.fullHeal) heal = Infinity
heal = Math.min(1 - mech.health, heal) heal = Math.min(1 - mech.health, heal)
mech.addHealth(heal); mech.addHealth(heal);
if (heal > 0) game.makeTextLog("<div class='circle heal'></div> &nbsp; <span style='font-size:115%;'> <strong style = 'letter-spacing: 2px;'>heal</strong> " + (heal * 100).toFixed(0) + "%</span>", 300) if (heal > 0) game.makeTextLog("<div class='circle heal'></div> &nbsp; <span style='font-size:115%;'> <strong style = 'letter-spacing: 2px;'>heal</strong> " + (heal * 100).toFixed(0) + "%</span>", 300)
@@ -108,7 +108,7 @@ const powerUps = {
effect() { effect() {
//find what guns I don't have //find what guns I don't have
let options = []; let options = [];
if (b.activeGun === null) { if (b.activeGun === null && game.difficulty < 3) {
//choose the first gun to be one that is good for the early game //choose the first gun to be one that is good for the early game
for (let i = 0; i < b.guns.length; ++i) { for (let i = 0; i < b.guns.length; ++i) {
if (!b.guns[i].have && b.guns[i].isStarterGun) options.push(i); if (!b.guns[i].have && b.guns[i].isStarterGun) options.push(i);