added hornets and ablative synthesis, and ceramic plating
This commit is contained in:
111
js/bullets.js
111
js/bullets.js
@@ -14,11 +14,15 @@ const b = {
|
|||||||
modBulletsLastLonger: null,
|
modBulletsLastLonger: null,
|
||||||
modIsImmortal: null,
|
modIsImmortal: null,
|
||||||
modSpores: null,
|
modSpores: null,
|
||||||
|
AoEImmunity: null,
|
||||||
|
makeDroneOnDamage: null,
|
||||||
setModDefaults() {
|
setModDefaults() {
|
||||||
b.modCount = 0;
|
b.modCount = 0;
|
||||||
b.modFireRate = 1;
|
b.modFireRate = 1;
|
||||||
b.modExplosionRadius = 1;
|
b.modExplosionRadius = 1;
|
||||||
|
b.AoEImmunity = false;
|
||||||
b.modBulletSize = 1;
|
b.modBulletSize = 1;
|
||||||
|
b.makeDroneOnDamage = false;
|
||||||
b.modEnergySiphon = 0;
|
b.modEnergySiphon = 0;
|
||||||
b.modHealthDrain = 0;
|
b.modHealthDrain = 0;
|
||||||
b.modNoAmmo = 0;
|
b.modNoAmmo = 0;
|
||||||
@@ -31,7 +35,7 @@ const b = {
|
|||||||
},
|
},
|
||||||
mods: [{
|
mods: [{
|
||||||
name: "depleted uranium rounds",
|
name: "depleted uranium rounds",
|
||||||
description: "your bullets are <strong>larger</strong> and do more physical <span class='color-d'>damage</span>",
|
description: "your <strong class='color-b'>bullets</strong> are larger and do more physical <span class='color-d'>damage</span>",
|
||||||
have: false,
|
have: false,
|
||||||
effect: () => {
|
effect: () => {
|
||||||
//good for guns that do mostly projectile damage:
|
//good for guns that do mostly projectile damage:
|
||||||
@@ -43,7 +47,7 @@ const b = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "auto-loading heuristics",
|
name: "auto-loading heuristics",
|
||||||
description: "your rate of fire is 15% faster",
|
description: "your rate of fire is 15% higher",
|
||||||
have: false,
|
have: false,
|
||||||
effect: () => {
|
effect: () => {
|
||||||
//good for guns with extra ammo: needles, M80, rapid fire, flak, super balls
|
//good for guns with extra ammo: needles, M80, rapid fire, flak, super balls
|
||||||
@@ -53,7 +57,7 @@ const b = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "desublimated ammunition",
|
name: "desublimated ammunition",
|
||||||
description: "use 50% less <span class='color-b'>ammo</span> when <strong>crouching</strong>",
|
description: "use 50% less <strong class='color-b'>ammo</strong> when <strong>crouching</strong>",
|
||||||
have: false,
|
have: false,
|
||||||
effect: () => {
|
effect: () => {
|
||||||
//good with guns that have less ammo: one shot, grenades, missiles, super balls, spray
|
//good with guns that have less ammo: one shot, grenades, missiles, super balls, spray
|
||||||
@@ -62,7 +66,7 @@ const b = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "corrosion resistant topology",
|
name: "corrosion resistant topology",
|
||||||
description: "your <span class='color-b'>bullets</span> last 40% longer",
|
description: "your <strong class='color-b'>bullets</strong> last 40% longer",
|
||||||
have: false,
|
have: false,
|
||||||
effect: () => {
|
effect: () => {
|
||||||
//good with: drones, super balls, spore, missiles, wave beam(range), rapid fire(range), flak(range)
|
//good with: drones, super balls, spore, missiles, wave beam(range), rapid fire(range), flak(range)
|
||||||
@@ -76,12 +80,28 @@ const b = {
|
|||||||
effect: () => {
|
effect: () => {
|
||||||
//at 1.4 gives a flat 40% increase, and increased range, balanced by limited guns and self damage
|
//at 1.4 gives a flat 40% increase, and increased range, balanced by limited guns and self damage
|
||||||
//testing at 1.3: grenade(+0.3), missiles, flak, M80
|
//testing at 1.3: grenade(+0.3), missiles, flak, M80
|
||||||
b.modExplosionRadius = 1.8; //good for guns with explosions:
|
b.modExplosionRadius = 1.8; //good for guns with explosions
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "energy siphon",
|
name: "ceramic plating",
|
||||||
description: "regenerate <span class='color-f'>energy</span> proportional to your <span class='color-d'>damage</span> done",
|
description: "you take no damage from area effects<br>immune to <strong class='color-e'>explosions</strong> and enemy fields",
|
||||||
|
have: false,
|
||||||
|
effect: () => {
|
||||||
|
b.AoEImmunity = true; //good for guns with explosions
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ablative synthesis",
|
||||||
|
description: "your <span class='color-d'>damaged</span> parts are rebuilt as <strong class='color-b'>drones</strong>",
|
||||||
|
have: false,
|
||||||
|
effect: () => {
|
||||||
|
b.makeDroneOnDamage = true; //makes dangerous situations more survivable
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "field siphon",
|
||||||
|
description: "regenerate <span class='color-f'>field energy</span> proportional to your <span class='color-d'>damage</span> done",
|
||||||
have: false,
|
have: false,
|
||||||
effect: () => {
|
effect: () => {
|
||||||
//good with laser, and all fields
|
//good with laser, and all fields
|
||||||
@@ -302,7 +322,7 @@ 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) {
|
||||||
mech.damage(radius * 0.0002);
|
if (!b.AoEImmunity) 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;
|
||||||
@@ -370,7 +390,7 @@ const b = {
|
|||||||
},
|
},
|
||||||
spore(who) { //used with the mod upgrade in mob.death()
|
spore(who) { //used with the mod upgrade in mob.death()
|
||||||
const bIndex = bullet.length;
|
const bIndex = bullet.length;
|
||||||
const RADIUS = (4 + 2 * Math.random()) * b.modBulletSize;
|
const RADIUS = 3 * b.modBulletSize;
|
||||||
bullet[bIndex] = Bodies.circle(who.position.x, who.position.y, RADIUS, {
|
bullet[bIndex] = Bodies.circle(who.position.x, who.position.y, RADIUS, {
|
||||||
// density: 0.0015, //frictionAir: 0.01,
|
// density: 0.0015, //frictionAir: 0.01,
|
||||||
inertia: Infinity,
|
inertia: Infinity,
|
||||||
@@ -378,7 +398,7 @@ const b = {
|
|||||||
angle: Math.random() * 2 * Math.PI,
|
angle: Math.random() * 2 * Math.PI,
|
||||||
friction: 0,
|
friction: 0,
|
||||||
frictionAir: 0.01,
|
frictionAir: 0.01,
|
||||||
dmg: 1.65, //damage done in addition to the damage from momentum
|
dmg: 1.8, //damage done in addition to the damage from momentum
|
||||||
classType: "bullet",
|
classType: "bullet",
|
||||||
collisionFilter: {
|
collisionFilter: {
|
||||||
category: 0x000100,
|
category: 0x000100,
|
||||||
@@ -615,7 +635,7 @@ const b = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "minigun",
|
name: "minigun",
|
||||||
description: "rapidly fire a stream of small bullets",
|
description: "rapidly fire a stream of small <strong>bullets</strong>",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
ammoPack: 105,
|
ammoPack: 105,
|
||||||
have: false,
|
have: false,
|
||||||
@@ -786,7 +806,7 @@ const b = {
|
|||||||
bullet[me].force.y += 0.00045; //a small push down at first to make it seem like the missile is briefly falling
|
bullet[me].force.y += 0.00045; //a small push down at first to make it seem like the missile is briefly falling
|
||||||
bullet[me].frictionAir = 0
|
bullet[me].frictionAir = 0
|
||||||
bullet[me].endCycle = game.cycle + Math.floor((265 + Math.random() * 20) * b.modBulletsLastLonger);
|
bullet[me].endCycle = game.cycle + Math.floor((265 + Math.random() * 20) * b.modBulletsLastLonger);
|
||||||
bullet[me].explodeRad = 165 + 40 * Math.random();
|
bullet[me].explodeRad = 170 + 60 * Math.random();
|
||||||
bullet[me].lookFrequency = Math.floor(8 + Math.random() * 7);
|
bullet[me].lookFrequency = Math.floor(8 + Math.random() * 7);
|
||||||
bullet[me].onEnd = b.explode; //makes bullet do explosive damage at end
|
bullet[me].onEnd = b.explode; //makes bullet do explosive damage at end
|
||||||
bullet[me].onDmg = function () {
|
bullet[me].onDmg = function () {
|
||||||
@@ -817,7 +837,7 @@ const b = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//explode when bullet is close enough to target
|
//explode when bullet is close enough to target
|
||||||
if (this.closestTarget && closeDist < this.explodeRad * 0.7) {
|
if (this.closestTarget && closeDist < this.explodeRad) {
|
||||||
this.endCycle = 0; //bullet ends cycle after doing damage //this also triggers explosion
|
this.endCycle = 0; //bullet ends cycle after doing damage //this also triggers explosion
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -944,7 +964,7 @@ const b = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "vacuum bomb",
|
name: "vacuum bomb",
|
||||||
description: "fire a huge bomb that sucks before it <span class='color-e'>explodes</span><br>click left mouse <strong>again</strong> to detonate",
|
description: "fire a huge <strong>bomb</strong> that sucks before it <span class='color-e'>explodes</span><br>click left mouse <strong>again</strong> to detonate",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
ammoPack: 4,
|
ammoPack: 4,
|
||||||
have: false,
|
have: false,
|
||||||
@@ -1093,7 +1113,7 @@ const b = {
|
|||||||
const NUM = 9;
|
const NUM = 9;
|
||||||
for (let i = 0; i < NUM; i++) {
|
for (let i = 0; i < NUM; i++) {
|
||||||
const bIndex = bullet.length;
|
const bIndex = bullet.length;
|
||||||
const RADIUS = (4 + 2 * Math.random()) * b.modBulletSize;
|
const RADIUS = 3 * b.modBulletSize;
|
||||||
bullet[bIndex] = Bodies.circle(this.position.x, this.position.y, RADIUS, {
|
bullet[bIndex] = Bodies.circle(this.position.x, this.position.y, RADIUS, {
|
||||||
// density: 0.0015, //frictionAir: 0.01,
|
// density: 0.0015, //frictionAir: 0.01,
|
||||||
inertia: Infinity,
|
inertia: Infinity,
|
||||||
@@ -1101,7 +1121,7 @@ const b = {
|
|||||||
angle: dir,
|
angle: dir,
|
||||||
friction: 0,
|
friction: 0,
|
||||||
frictionAir: 0.01,
|
frictionAir: 0.01,
|
||||||
dmg: 1.65, //damage done in addition to the damage from momentum
|
dmg: 1.8, //damage done in addition to the damage from momentum
|
||||||
classType: "bullet",
|
classType: "bullet",
|
||||||
collisionFilter: {
|
collisionFilter: {
|
||||||
category: 0x000100,
|
category: 0x000100,
|
||||||
@@ -1157,8 +1177,8 @@ const b = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "hunter drones",
|
name: "drones",
|
||||||
description: "release <span class='color-b'>drones</span> that seek out targets<br>if no targets are found, <span class='color-b'>drones</span> move towards mouse<br>",
|
description: "release <strong>drones</strong> that seek out targets for 16 seconds<br>follows mouse if no targets are found",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
ammoPack: 20,
|
ammoPack: 20,
|
||||||
have: false,
|
have: false,
|
||||||
@@ -1166,7 +1186,7 @@ const b = {
|
|||||||
const THRUST = 0.0015
|
const THRUST = 0.0015
|
||||||
const dir = mech.angle + 0.2 * (Math.random() - 0.5);
|
const dir = mech.angle + 0.2 * (Math.random() - 0.5);
|
||||||
const me = bullet.length;
|
const me = bullet.length;
|
||||||
const RADIUS = (4 + 4 * Math.random()) * b.modBulletSize
|
const RADIUS = (4.5 + 3 * Math.random()) * b.modBulletSize
|
||||||
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,
|
||||||
@@ -1251,35 +1271,37 @@ const b = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "defense drones",
|
//draw a halo, since there will only be 1-3 balls
|
||||||
description: "release <span class='color-b'>drones</span> that defend the space around the player",
|
name: "hornets",
|
||||||
|
description: "release large <strong>drones</strong> that defend the space around the player for 5 seconds",
|
||||||
ammo: 0,
|
ammo: 0,
|
||||||
ammoPack: 3,
|
ammoPack: 20,
|
||||||
have: false,
|
have: false,
|
||||||
fire() {
|
fire() {
|
||||||
const THRUST = 0.0015
|
const THRUST = 0.004
|
||||||
const dir = mech.angle + 0.2 * (Math.random() - 0.5);
|
const dir = mech.angle + 0.2 * (Math.random() - 0.5);
|
||||||
const me = bullet.length;
|
const me = bullet.length;
|
||||||
const RADIUS = (10 + 6 * Math.random()) * b.modBulletSize
|
const RADIUS = (10 + 5 * Math.random()) * b.modBulletSize
|
||||||
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, {
|
||||||
|
isOrb: true,
|
||||||
angle: dir,
|
angle: dir,
|
||||||
inertia: Infinity,
|
inertia: Infinity,
|
||||||
friction: 0,
|
friction: 0,
|
||||||
frictionAir: 0.001,
|
frictionAir: 0.06,
|
||||||
restitution: 1,
|
restitution: 1,
|
||||||
dmg: 0.14, //damage done in addition to the damage from momentum
|
dmg: 0, // 0.14 //damage done in addition to the damage from momentum
|
||||||
lookFrequency: 27 + Math.floor(37 * Math.random()),
|
minDmgSpeed: 2,
|
||||||
endCycle: game.cycle + Math.floor((2400 + 1800 * Math.random()) * b.modBulletsLastLonger),
|
lookFrequency: 37 + Math.floor(37 * Math.random()),
|
||||||
|
endCycle: game.cycle + Math.floor((300 + 140 * Math.random()) * b.modBulletsLastLonger),
|
||||||
classType: "bullet",
|
classType: "bullet",
|
||||||
collisionFilter: {
|
collisionFilter: {
|
||||||
category: 0x000100,
|
category: 0x000100,
|
||||||
mask: 0x000110 //self collide
|
mask: 0x010111 //self, mob,map,body collide
|
||||||
},
|
},
|
||||||
minDmgSpeed: 0,
|
range: 500 + 150 * Math.random(),
|
||||||
range: 450 + 150 * Math.random(),
|
|
||||||
lockedOn: null,
|
lockedOn: null,
|
||||||
isFollowMouse: true,
|
|
||||||
onDmg() {
|
onDmg() {
|
||||||
|
// this.endCycle = 0;
|
||||||
this.lockedOn = null
|
this.lockedOn = null
|
||||||
},
|
},
|
||||||
onEnd() {},
|
onEnd() {},
|
||||||
@@ -1290,7 +1312,7 @@ const b = {
|
|||||||
for (let i = 0, len = mob.length; i < len; ++i) {
|
for (let i = 0, len = mob.length; i < len; ++i) {
|
||||||
const TARGET_VECTOR = Matter.Vector.sub(mech.pos, mob[i].position)
|
const TARGET_VECTOR = Matter.Vector.sub(mech.pos, mob[i].position)
|
||||||
const DIST = Matter.Vector.magnitude(TARGET_VECTOR);
|
const DIST = Matter.Vector.magnitude(TARGET_VECTOR);
|
||||||
if (DIST < this.range && DIST < closeDist) {
|
if (DIST < this.range && DIST < closeDist && Matter.Query.ray(map, this.position, mob[i].position).length === 0) {
|
||||||
closeDist = DIST;
|
closeDist = DIST;
|
||||||
this.lockedOn = mob[i]
|
this.lockedOn = mob[i]
|
||||||
}
|
}
|
||||||
@@ -1300,20 +1322,23 @@ const b = {
|
|||||||
const distanceToPlayer = Matter.Vector.magnitude(Matter.Vector.sub(this.position, mech.pos))
|
const distanceToPlayer = Matter.Vector.magnitude(Matter.Vector.sub(this.position, mech.pos))
|
||||||
if (this.lockedOn) { //accelerate towards mobs
|
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.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 > 0.2 * this.range) {
|
} else if (distanceToPlayer > 0.2 * this.range) {
|
||||||
this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, mech.pos)), -this.mass * THRUST * 0.5)
|
this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, mech.pos)), -this.mass * THRUST * 0.3)
|
||||||
}
|
this.frictionAir = 0.02
|
||||||
|
// // speed cap instead of friction to give more agility
|
||||||
// speed cap instead of friction to give more agility
|
// if (this.speed > 14) {
|
||||||
if (this.speed > 12) {
|
// Matter.Body.setVelocity(this, {
|
||||||
Matter.Body.setVelocity(this, {
|
// x: this.velocity.x * 0.97,
|
||||||
x: this.velocity.x * 0.97,
|
// y: this.velocity.y * 0.97
|
||||||
y: this.velocity.y * 0.97
|
// });
|
||||||
});
|
// }
|
||||||
|
} else { //must be close to player //add some random motion
|
||||||
|
this.frictionAir = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
b.fireProps(mech.crouch ? 80 : 60, mech.crouch ? 35 : 10, dir, me); //cd , speed
|
b.fireProps(mech.crouch ? 40 : 10, mech.crouch ? 40 : 10, dir, me); //cd , speed
|
||||||
b.drawOneBullet(bullet[me].vertices);
|
b.drawOneBullet(bullet[me].vertices);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
13
js/game.js
13
js/game.js
@@ -304,25 +304,18 @@ const game = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (keys[71]) { // give all guns with G
|
if (keys[71]) { // give all guns with G
|
||||||
b.giveGuns("all", 1000)
|
// b.giveGuns("all", 1000)
|
||||||
|
powerUps.gun.effect()
|
||||||
}
|
}
|
||||||
if (keys[72]) { // power ups with H
|
if (keys[72]) { // power ups with H
|
||||||
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "gun");
|
|
||||||
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "gun");
|
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "gun");
|
||||||
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "ammo");
|
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "ammo");
|
||||||
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "field");
|
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "field");
|
||||||
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "heal");
|
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "heal");
|
||||||
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "heal");
|
|
||||||
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "mod");
|
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "mod");
|
||||||
}
|
}
|
||||||
if (keys[89]) { //add all mods with y
|
if (keys[89]) { //add all mods with y
|
||||||
for (let i = 0; i < b.mods.length; i++) {
|
powerUps.mod.effect()
|
||||||
if (!b.mods[i].have) {
|
|
||||||
b.mods[i].effect()
|
|
||||||
b.mods[i].have = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
game.updateModHUD();
|
|
||||||
}
|
}
|
||||||
if (keys[82]) { // teleport to mouse with R
|
if (keys[82]) { // teleport to mouse with R
|
||||||
Matter.Body.setPosition(player, this.mouseInGame);
|
Matter.Body.setPosition(player, this.mouseInGame);
|
||||||
|
|||||||
12
js/index.js
12
js/index.js
@@ -2,7 +2,17 @@
|
|||||||
/* TODO: *******************************************
|
/* TODO: *******************************************
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
||||||
Boss level
|
diegetic field meter
|
||||||
|
show as the player head filling with teal color
|
||||||
|
|
||||||
|
atmosphere levels
|
||||||
|
give the user a rest, between combat
|
||||||
|
low combat
|
||||||
|
nonaggressive mobs
|
||||||
|
one mob attacking the passive mobs
|
||||||
|
more graphics
|
||||||
|
|
||||||
|
Boss levels
|
||||||
boss grows and spilt, if you don't kill it fast
|
boss grows and spilt, if you don't kill it fast
|
||||||
sensor that locks you in after you enter the boss room
|
sensor that locks you in after you enter the boss room
|
||||||
boss that eats other mobs and gains stats from them
|
boss that eats other mobs and gains stats from them
|
||||||
|
|||||||
10
js/level.js
10
js/level.js
@@ -14,12 +14,12 @@ const level = {
|
|||||||
if (game.levelsCleared === 0) {
|
if (game.levelsCleared === 0) {
|
||||||
// game.levelsCleared = 16; //for testing to simulate possible mobs spawns
|
// game.levelsCleared = 16; //for testing to simulate possible mobs spawns
|
||||||
// b.giveGuns("all", 1000)
|
// b.giveGuns("all", 1000)
|
||||||
b.giveGuns(13) // set a starting gun for testing
|
// b.giveGuns(13) // set a starting gun for testing
|
||||||
// mech.fieldUpgrades[2].effect(); //give a field power up for testing
|
// mech.fieldUpgrades[6].effect(); //give a field power up for testing
|
||||||
// b.giveMod(7)
|
b.giveMod(6)
|
||||||
|
|
||||||
// this.intro(); //starting level
|
this.intro(); //starting level
|
||||||
this.testingMap();
|
// this.testingMap();
|
||||||
// this.bosses();
|
// this.bosses();
|
||||||
// this.aerie();
|
// this.aerie();
|
||||||
// this.rooftops();
|
// this.rooftops();
|
||||||
|
|||||||
@@ -231,8 +231,10 @@ 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) {
|
||||||
mech.damage(0.0003 * game.dmgScale);
|
if (!b.AoEImmunity) {
|
||||||
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.005
|
mech.damage(0.0003 * game.dmgScale);
|
||||||
|
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.005
|
||||||
|
}
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(this.position.x, this.position.y);
|
ctx.moveTo(this.position.x, this.position.y);
|
||||||
ctx.lineTo(mech.pos.x, mech.pos.y);
|
ctx.lineTo(mech.pos.x, mech.pos.y);
|
||||||
|
|||||||
240
js/player.js
240
js/player.js
@@ -374,9 +374,10 @@ const mech = {
|
|||||||
//find what mods I don't have
|
//find what mods I don't have
|
||||||
let options = [];
|
let options = [];
|
||||||
for (let i = 0; i < b.mods.length; i++) {
|
for (let i = 0; i < b.mods.length; i++) {
|
||||||
if (!b.mods[i].have) options.push(i);
|
//can't get quantum immortality again
|
||||||
|
if (i !== 7 && !b.mods[i].have) options.push(i);
|
||||||
}
|
}
|
||||||
//add a new mods
|
//add a new mod
|
||||||
if (options.length > 0) {
|
if (options.length > 0) {
|
||||||
const choose = Math.floor(Math.random() * options.length)
|
const choose = Math.floor(Math.random() * options.length)
|
||||||
let newMod = options[choose]
|
let newMod = options[choose]
|
||||||
@@ -388,7 +389,7 @@ const mech = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function randomizeField() {
|
function randomizeField() {
|
||||||
if (game.levelsCleared > 5 && Math.random() < 0.9) {
|
if (game.levelsCleared * (Math.random() + 0.27) > 2) {
|
||||||
mech.fieldUpgrades[Math.floor(Math.random() * (mech.fieldUpgrades.length))].effect();
|
mech.fieldUpgrades[Math.floor(Math.random() * (mech.fieldUpgrades.length))].effect();
|
||||||
} else {
|
} else {
|
||||||
mech.fieldUpgrades[0].effect();
|
mech.fieldUpgrades[0].effect();
|
||||||
@@ -402,7 +403,7 @@ const mech = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function randomizeGuns() {
|
function randomizeGuns() {
|
||||||
const length = b.inventory.length
|
const length = Math.round(b.inventory.length * (1 + 0.4 * (Math.random() - 0.5)))
|
||||||
//removes guns and ammo
|
//removes guns and ammo
|
||||||
b.inventory = [];
|
b.inventory = [];
|
||||||
b.activeGun = null;
|
b.activeGun = null;
|
||||||
@@ -432,16 +433,16 @@ const mech = {
|
|||||||
randomizeGuns()
|
randomizeGuns()
|
||||||
randomizeField()
|
randomizeField()
|
||||||
randomizeHealth()
|
randomizeHealth()
|
||||||
for (let i = 0; i < 6; i++) {
|
for (let i = 0, len = 7; i < len; i++) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
randomizeMods()
|
randomizeMods()
|
||||||
randomizeGuns()
|
randomizeGuns()
|
||||||
randomizeField()
|
randomizeField()
|
||||||
randomizeHealth()
|
randomizeHealth()
|
||||||
game.replaceTextLog = true;
|
game.replaceTextLog = true;
|
||||||
game.makeTextLog(`probability amplitude will synchronize in ${6-i} seconds`, 1000);
|
game.makeTextLog(`probability amplitude will synchronize in ${len-i-1} seconds`, 1000);
|
||||||
game.wipe = function () { //set wipe to have trails
|
game.wipe = function () { //set wipe to have trails
|
||||||
ctx.fillStyle = `rgba(255,255,255,${(i+1)*(i+1)*0.003})`;
|
ctx.fillStyle = `rgba(255,255,255,${(i+1)*(i+1)*0.006})`;
|
||||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
}
|
}
|
||||||
}, (i + 1) * 1000);
|
}, (i + 1) * 1000);
|
||||||
@@ -514,13 +515,17 @@ const mech = {
|
|||||||
document.getElementById("dmg").style.transition = "opacity 0s";
|
document.getElementById("dmg").style.transition = "opacity 0s";
|
||||||
document.getElementById("dmg").style.opacity = 0.1 + Math.min(0.6, dmg * 4);
|
document.getElementById("dmg").style.opacity = 0.1 + Math.min(0.6, dmg * 4);
|
||||||
|
|
||||||
//drop block if holding
|
//chance to build a drone on damage from mod
|
||||||
if (dmg > 0.07) {
|
if (b.makeDroneOnDamage) {
|
||||||
this.drop();
|
const len = (dmg - 0.08 + 0.05 * Math.random()) / 0.05
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
if (Math.random() < 0.6) b.guns[12].fire() //spawn drone
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// freeze game and display a full screen red color
|
// freeze game and display a full screen red color
|
||||||
if (dmg > 0.05) {
|
if (dmg > 0.05) {
|
||||||
|
this.drop(); //drop block if holding
|
||||||
game.fpsCap = 4 //40 - Math.min(25, 100 * dmg)
|
game.fpsCap = 4 //40 - Math.min(25, 100 * dmg)
|
||||||
game.fpsInterval = 1000 / game.fpsCap;
|
game.fpsInterval = 1000 / game.fpsCap;
|
||||||
} else {
|
} else {
|
||||||
@@ -540,17 +545,133 @@ const mech = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
requestAnimationFrame(normalFPS);
|
requestAnimationFrame(normalFPS);
|
||||||
|
|
||||||
|
// // freeze game and display a full screen red color
|
||||||
|
// if (dmg > 0.05) {
|
||||||
|
// if (dmg > 0.07) {
|
||||||
|
// this.drop(); //drop block if holding
|
||||||
|
// }
|
||||||
|
|
||||||
|
// game.fpsCap = 4 //40 - Math.min(25, 100 * dmg)
|
||||||
|
// game.fpsInterval = 1000 / game.fpsCap;
|
||||||
|
// } else {
|
||||||
|
// game.fpsCap = game.fpsCapDefault
|
||||||
|
// game.fpsInterval = 1000 / game.fpsCap;
|
||||||
|
// }
|
||||||
|
// mech.defaultFPSCycle = mech.cycle
|
||||||
|
|
||||||
|
// const normalFPS = function () {
|
||||||
|
// if (mech.defaultFPSCycle < mech.cycle) { //back to default values
|
||||||
|
// game.fpsCap = game.fpsCapDefault
|
||||||
|
// game.fpsInterval = 1000 / game.fpsCap;
|
||||||
|
// document.getElementById("dmg").style.transition = "opacity 1s";
|
||||||
|
// document.getElementById("dmg").style.opacity = "0";
|
||||||
|
// } else {
|
||||||
|
// requestAnimationFrame(normalFPS);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// requestAnimationFrame(normalFPS);
|
||||||
},
|
},
|
||||||
damageImmune: 0,
|
damageImmune: 0,
|
||||||
hitMob(i, dmg) {
|
hitMob(i, dmg) {
|
||||||
//prevents damage happening too quick
|
//prevents damage happening too quick
|
||||||
},
|
},
|
||||||
buttonCD: 0, //cooldown for player buttons
|
buttonCD: 0, //cool down for player buttons
|
||||||
usePowerUp(i) {
|
usePowerUp(i) {
|
||||||
powerUp[i].effect();
|
powerUp[i].effect();
|
||||||
Matter.World.remove(engine.world, powerUp[i]);
|
Matter.World.remove(engine.world, powerUp[i]);
|
||||||
powerUp.splice(i, 1);
|
powerUp.splice(i, 1);
|
||||||
},
|
},
|
||||||
|
drawLeg(stroke) {
|
||||||
|
// if (game.mouseInGame.x > this.pos.x) {
|
||||||
|
if (mech.angle > -Math.PI / 2 && mech.angle < Math.PI / 2) {
|
||||||
|
this.flipLegs = 1;
|
||||||
|
} else {
|
||||||
|
this.flipLegs = -1;
|
||||||
|
}
|
||||||
|
ctx.save();
|
||||||
|
ctx.scale(this.flipLegs, 1); //leg lines
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(this.hip.x, this.hip.y);
|
||||||
|
ctx.lineTo(this.knee.x, this.knee.y);
|
||||||
|
ctx.lineTo(this.foot.x, this.foot.y);
|
||||||
|
ctx.strokeStyle = stroke;
|
||||||
|
ctx.lineWidth = 7;
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
//toe lines
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(this.foot.x, this.foot.y);
|
||||||
|
ctx.lineTo(this.foot.x - 15, this.foot.y + 5);
|
||||||
|
ctx.moveTo(this.foot.x, this.foot.y);
|
||||||
|
ctx.lineTo(this.foot.x + 15, this.foot.y + 5);
|
||||||
|
ctx.lineWidth = 4;
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
//hip joint
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(this.hip.x, this.hip.y, 11, 0, 2 * Math.PI);
|
||||||
|
//knee joint
|
||||||
|
ctx.moveTo(this.knee.x + 7, this.knee.y);
|
||||||
|
ctx.arc(this.knee.x, this.knee.y, 7, 0, 2 * Math.PI);
|
||||||
|
//foot joint
|
||||||
|
ctx.moveTo(this.foot.x + 6, this.foot.y);
|
||||||
|
ctx.arc(this.foot.x, this.foot.y, 6, 0, 2 * Math.PI);
|
||||||
|
ctx.fillStyle = this.fillColor;
|
||||||
|
ctx.fill();
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.restore();
|
||||||
|
},
|
||||||
|
calcLeg(cycle_offset, offset) {
|
||||||
|
this.hip.x = 12 + offset;
|
||||||
|
this.hip.y = 24 + offset;
|
||||||
|
//stepSize goes to zero if Vx is zero or not on ground (make this transition cleaner)
|
||||||
|
this.stepSize = 0.8 * this.stepSize + 0.2 * (7 * Math.sqrt(Math.min(9, Math.abs(this.Vx))) * this.onGround);
|
||||||
|
//changes to stepsize are smoothed by adding only a percent of the new value each cycle
|
||||||
|
const stepAngle = 0.034 * this.walk_cycle + cycle_offset;
|
||||||
|
this.foot.x = 2.2 * this.stepSize * Math.cos(stepAngle) + offset;
|
||||||
|
this.foot.y = offset + 1.2 * this.stepSize * Math.sin(stepAngle) + this.yOff + this.height;
|
||||||
|
const Ymax = this.yOff + this.height;
|
||||||
|
if (this.foot.y > Ymax) this.foot.y = Ymax;
|
||||||
|
|
||||||
|
//calculate knee position as intersection of circle from hip and foot
|
||||||
|
const d = Math.sqrt((this.hip.x - this.foot.x) * (this.hip.x - this.foot.x) + (this.hip.y - this.foot.y) * (this.hip.y - this.foot.y));
|
||||||
|
const l = (this.legLength1 * this.legLength1 - this.legLength2 * this.legLength2 + d * d) / (2 * d);
|
||||||
|
const h = Math.sqrt(this.legLength1 * this.legLength1 - l * l);
|
||||||
|
this.knee.x = (l / d) * (this.foot.x - this.hip.x) - (h / d) * (this.foot.y - this.hip.y) + this.hip.x + offset;
|
||||||
|
this.knee.y = (l / d) * (this.foot.y - this.hip.y) + (h / d) * (this.foot.x - this.hip.x) + this.hip.y;
|
||||||
|
},
|
||||||
|
draw() {
|
||||||
|
ctx.fillStyle = this.fillColor;
|
||||||
|
this.walk_cycle += this.flipLegs * this.Vx;
|
||||||
|
|
||||||
|
//draw body
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(this.pos.x, this.pos.y);
|
||||||
|
this.calcLeg(Math.PI, -3);
|
||||||
|
this.drawLeg("#4a4a4a");
|
||||||
|
this.calcLeg(0, 0);
|
||||||
|
this.drawLeg("#333");
|
||||||
|
ctx.rotate(this.angle);
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(0, 0, 30, 0, 2 * Math.PI);
|
||||||
|
let grd = ctx.createLinearGradient(-30, 0, 30, 0);
|
||||||
|
grd.addColorStop(0, this.fillColorDark);
|
||||||
|
grd.addColorStop(1, this.fillColor);
|
||||||
|
ctx.fillStyle = grd;
|
||||||
|
ctx.fill();
|
||||||
|
ctx.arc(15, 0, 4, 0, 2 * Math.PI);
|
||||||
|
ctx.strokeStyle = "#333";
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.stroke();
|
||||||
|
// ctx.beginPath();
|
||||||
|
// ctx.arc(15, 0, 3, 0, 2 * Math.PI);
|
||||||
|
// ctx.fillStyle = '#9cf' //'#0cf';
|
||||||
|
// ctx.fill()
|
||||||
|
ctx.restore();
|
||||||
|
},
|
||||||
// *********************************************
|
// *********************************************
|
||||||
// **************** holding ********************
|
// **************** holding ********************
|
||||||
// *********************************************
|
// *********************************************
|
||||||
@@ -1264,6 +1385,7 @@ const mech = {
|
|||||||
name: "nano-scale manufacturing",
|
name: "nano-scale manufacturing",
|
||||||
description: "excess field <span class='color-f'>energy</span> used to build <strong class='color-b'>drones</strong><br> increased <span class='color-f'>energy</span> regeneration",
|
description: "excess field <span class='color-f'>energy</span> used to build <strong class='color-b'>drones</strong><br> increased <span class='color-f'>energy</span> regeneration",
|
||||||
effect: () => {
|
effect: () => {
|
||||||
|
let gunIndex = Math.random() < 0.5 ? 13 : 12
|
||||||
mech.fieldMode = 5;
|
mech.fieldMode = 5;
|
||||||
mech.fieldText();
|
mech.fieldText();
|
||||||
mech.setHoldDefaults();
|
mech.setHoldDefaults();
|
||||||
@@ -1271,7 +1393,7 @@ const mech = {
|
|||||||
mech.hold = function () {
|
mech.hold = function () {
|
||||||
if (mech.fieldMeter === 1) {
|
if (mech.fieldMeter === 1) {
|
||||||
mech.fieldMeter -= 0.5;
|
mech.fieldMeter -= 0.5;
|
||||||
b.guns[12].fire() //spawn drone
|
b.guns[gunIndex].fire() //spawn drone
|
||||||
}
|
}
|
||||||
if (mech.isHolding) {
|
if (mech.isHolding) {
|
||||||
mech.drawHold(mech.holdingTarget);
|
mech.drawHold(mech.holdingTarget);
|
||||||
@@ -1315,9 +1437,9 @@ const mech = {
|
|||||||
player.collisionFilter.mask = 0x000001 //0x010011 is normals
|
player.collisionFilter.mask = 0x000001 //0x010011 is normals
|
||||||
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(mech.pos.x, mech.pos.y, mech.grabRange / (0.3 + 0.7 * mech.fieldMeter), 0, 2 * Math.PI);
|
ctx.arc(mech.pos.x, mech.pos.y, mech.grabRange, 0, 2 * Math.PI);
|
||||||
ctx.globalCompositeOperation = "destination-in"; //in or atop
|
ctx.globalCompositeOperation = "destination-in"; //in or atop
|
||||||
ctx.fillStyle = "rgba(255,255,255,0.25)";
|
ctx.fillStyle = `rgba(255,255,255,${mech.fieldMeter*0.5})`;
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
ctx.globalCompositeOperation = "source-over";
|
ctx.globalCompositeOperation = "source-over";
|
||||||
ctx.strokeStyle = "#000"
|
ctx.strokeStyle = "#000"
|
||||||
@@ -1403,94 +1525,4 @@ const mech = {
|
|||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
],
|
],
|
||||||
drawLeg(stroke) {
|
|
||||||
// if (game.mouseInGame.x > this.pos.x) {
|
|
||||||
if (mech.angle > -Math.PI / 2 && mech.angle < Math.PI / 2) {
|
|
||||||
this.flipLegs = 1;
|
|
||||||
} else {
|
|
||||||
this.flipLegs = -1;
|
|
||||||
}
|
|
||||||
ctx.save();
|
|
||||||
ctx.scale(this.flipLegs, 1); //leg lines
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(this.hip.x, this.hip.y);
|
|
||||||
ctx.lineTo(this.knee.x, this.knee.y);
|
|
||||||
ctx.lineTo(this.foot.x, this.foot.y);
|
|
||||||
ctx.strokeStyle = stroke;
|
|
||||||
ctx.lineWidth = 7;
|
|
||||||
ctx.stroke();
|
|
||||||
|
|
||||||
//toe lines
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(this.foot.x, this.foot.y);
|
|
||||||
ctx.lineTo(this.foot.x - 15, this.foot.y + 5);
|
|
||||||
ctx.moveTo(this.foot.x, this.foot.y);
|
|
||||||
ctx.lineTo(this.foot.x + 15, this.foot.y + 5);
|
|
||||||
ctx.lineWidth = 4;
|
|
||||||
ctx.stroke();
|
|
||||||
|
|
||||||
//hip joint
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(this.hip.x, this.hip.y, 11, 0, 2 * Math.PI);
|
|
||||||
//knee joint
|
|
||||||
ctx.moveTo(this.knee.x + 7, this.knee.y);
|
|
||||||
ctx.arc(this.knee.x, this.knee.y, 7, 0, 2 * Math.PI);
|
|
||||||
//foot joint
|
|
||||||
ctx.moveTo(this.foot.x + 6, this.foot.y);
|
|
||||||
ctx.arc(this.foot.x, this.foot.y, 6, 0, 2 * Math.PI);
|
|
||||||
ctx.fillStyle = this.fillColor;
|
|
||||||
ctx.fill();
|
|
||||||
ctx.lineWidth = 2;
|
|
||||||
ctx.stroke();
|
|
||||||
ctx.restore();
|
|
||||||
},
|
|
||||||
calcLeg(cycle_offset, offset) {
|
|
||||||
this.hip.x = 12 + offset;
|
|
||||||
this.hip.y = 24 + offset;
|
|
||||||
//stepSize goes to zero if Vx is zero or not on ground (make this transition cleaner)
|
|
||||||
this.stepSize = 0.8 * this.stepSize + 0.2 * (7 * Math.sqrt(Math.min(9, Math.abs(this.Vx))) * this.onGround);
|
|
||||||
//changes to stepsize are smoothed by adding only a percent of the new value each cycle
|
|
||||||
const stepAngle = 0.034 * this.walk_cycle + cycle_offset;
|
|
||||||
this.foot.x = 2.2 * this.stepSize * Math.cos(stepAngle) + offset;
|
|
||||||
this.foot.y = offset + 1.2 * this.stepSize * Math.sin(stepAngle) + this.yOff + this.height;
|
|
||||||
const Ymax = this.yOff + this.height;
|
|
||||||
if (this.foot.y > Ymax) this.foot.y = Ymax;
|
|
||||||
|
|
||||||
//calculate knee position as intersection of circle from hip and foot
|
|
||||||
const d = Math.sqrt((this.hip.x - this.foot.x) * (this.hip.x - this.foot.x) + (this.hip.y - this.foot.y) * (this.hip.y - this.foot.y));
|
|
||||||
const l = (this.legLength1 * this.legLength1 - this.legLength2 * this.legLength2 + d * d) / (2 * d);
|
|
||||||
const h = Math.sqrt(this.legLength1 * this.legLength1 - l * l);
|
|
||||||
this.knee.x = (l / d) * (this.foot.x - this.hip.x) - (h / d) * (this.foot.y - this.hip.y) + this.hip.x + offset;
|
|
||||||
this.knee.y = (l / d) * (this.foot.y - this.hip.y) + (h / d) * (this.foot.x - this.hip.x) + this.hip.y;
|
|
||||||
},
|
|
||||||
draw() {
|
|
||||||
ctx.fillStyle = this.fillColor;
|
|
||||||
this.walk_cycle += this.flipLegs * this.Vx;
|
|
||||||
|
|
||||||
//draw body
|
|
||||||
ctx.save();
|
|
||||||
ctx.translate(this.pos.x, this.pos.y);
|
|
||||||
this.calcLeg(Math.PI, -3);
|
|
||||||
this.drawLeg("#4a4a4a");
|
|
||||||
this.calcLeg(0, 0);
|
|
||||||
this.drawLeg("#333");
|
|
||||||
ctx.rotate(this.angle);
|
|
||||||
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(0, 0, 30, 0, 2 * Math.PI);
|
|
||||||
let grd = ctx.createLinearGradient(-30, 0, 30, 0);
|
|
||||||
grd.addColorStop(0, this.fillColorDark);
|
|
||||||
grd.addColorStop(1, this.fillColor);
|
|
||||||
ctx.fillStyle = grd;
|
|
||||||
ctx.fill();
|
|
||||||
ctx.arc(15, 0, 4, 0, 2 * Math.PI);
|
|
||||||
ctx.strokeStyle = "#333";
|
|
||||||
ctx.lineWidth = 2;
|
|
||||||
ctx.stroke();
|
|
||||||
// ctx.beginPath();
|
|
||||||
// ctx.arc(15, 0, 3, 0, 2 * Math.PI);
|
|
||||||
// ctx.fillStyle = '#9cf' //'#0cf';
|
|
||||||
// ctx.fill()
|
|
||||||
ctx.restore();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
@@ -44,7 +44,7 @@ const powerUps = {
|
|||||||
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300);
|
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300);
|
||||||
} else {
|
} else {
|
||||||
//ammo given scales as mobs take more hits to kill
|
//ammo given scales as mobs take more hits to kill
|
||||||
const ammo = Math.ceil((target.ammoPack * (0.5 + 0.08 * Math.random())) / b.dmgScale);
|
const ammo = Math.ceil((target.ammoPack * (0.55 + 0.08 * Math.random())) / b.dmgScale);
|
||||||
target.ammo += ammo;
|
target.ammo += ammo;
|
||||||
game.updateGunHUD();
|
game.updateGunHUD();
|
||||||
game.makeTextLog("<span style='font-size:110%;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
|
game.makeTextLog("<span style='font-size:110%;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
|
||||||
@@ -140,7 +140,7 @@ const powerUps = {
|
|||||||
powerUps.spawn(x, y, "heal");
|
powerUps.spawn(x, y, "heal");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Math.random() < 0.19) {
|
if (Math.random() < 0.2) {
|
||||||
if (b.inventory.length > 0) powerUps.spawn(x, y, "ammo");
|
if (b.inventory.length > 0) powerUps.spawn(x, y, "ammo");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
12
js/spawn.js
12
js/spawn.js
@@ -457,8 +457,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) {
|
if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon) {
|
||||||
mech.damage(0.00015 * game.dmgScale);
|
if (!b.AoEImmunity) {
|
||||||
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01
|
mech.damage(0.00015 * game.dmgScale);
|
||||||
|
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01
|
||||||
|
}
|
||||||
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);
|
||||||
@@ -544,8 +546,10 @@ const spawn = {
|
|||||||
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) {
|
if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon) {
|
||||||
mech.damage(0.00015 * game.dmgScale);
|
if (!b.AoEImmunity) {
|
||||||
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01
|
mech.damage(0.00015 * game.dmgScale);
|
||||||
|
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.01
|
||||||
|
}
|
||||||
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user