font spacing, gun discriptions, game balance

This commit is contained in:
landgreen
2019-10-07 06:51:31 -07:00
parent 99813abf79
commit 868a8a3e89
9 changed files with 191 additions and 164 deletions

View File

@@ -259,7 +259,7 @@
<path d="M 430.5 442 v50 h38" />
<path d="M 612.5 442 v50 h-38" />
</g>
<g class="fade-in" stroke="none" fill="#ccc" font-size="16px" font-family="Arial">
<g class="fade-in" stroke="none" fill="#ccc" font-size="16px">
<text x="257" y="438">guns</text>
<text x="255" y="638">move</text>
<text x="420" y="438">fire</text>

View File

@@ -30,22 +30,41 @@ const b = {
});
World.add(engine.world, bullet[me]); //add bullet to world
},
fireAttributes(dir) {
return {
// density: 0.0015, //frictionAir: 0.01, //restitution: 0,
angle: dir,
friction: 0.5,
frictionAir: 0,
dmg: 0, //damage done in addition to the damage from momentum
classType: "bullet",
collisionFilter: {
category: 0x000100,
mask: 0x010011 //mask: 0x000101, //for self collision
},
minDmgSpeed: 10,
onDmg() {}, //this.endCycle = 0 //triggers despawn
onEnd() {}
};
fireAttributes(dir, rotate = true) {
if (rotate) {
return {
// density: 0.0015, //frictionAir: 0.01, //restitution: 0,
angle: dir,
friction: 0.5,
frictionAir: 0,
dmg: 0, //damage done in addition to the damage from momentum
classType: "bullet",
collisionFilter: {
category: 0x000100,
mask: 0x010011 //mask: 0x000101, //for self collision
},
minDmgSpeed: 10,
onDmg() {}, //this.endCycle = 0 //triggers despawn
onEnd() {}
};
} else {
return {
// density: 0.0015, //frictionAir: 0.01, //restitution: 0,
inertia: Infinity, //prevents rotation
angle: dir,
friction: 0.5,
frictionAir: 0,
dmg: 0, //damage done in addition to the damage from momentum
classType: "bullet",
collisionFilter: {
category: 0x000100,
mask: 0x010011 //mask: 0x000101, //for self collision
},
minDmgSpeed: 10,
onDmg() {}, //this.endCycle = 0 //triggers despawn
onEnd() {}
};
}
},
muzzleFlash(radius = 10) {
ctx.fillStyle = "#fb0";
@@ -148,22 +167,23 @@ const b = {
}
}
//bullet knock backs
for (let i = 0, len = bullet.length; i < len; ++i) {
if (me !== i) {
sub = Matter.Vector.sub(bullet[me].position, bullet[i].position);
dist = Matter.Vector.magnitude(sub);
if (dist < bullet[me].explodeRad) {
knock = Matter.Vector.mult(Matter.Vector.normalise(sub), (-Math.sqrt(dmg) * bullet[i].mass) / 10);
bullet[i].force.x += knock.x;
bullet[i].force.y += knock.y;
} else if (dist < alertRange) {
knock = Matter.Vector.mult(Matter.Vector.normalise(sub), (-Math.sqrt(dmg) * bullet[i].mass) / 20);
bullet[i].force.x += knock.x;
bullet[i].force.y += knock.y;
}
}
}
// bullet knock backs (not working: no effect for drones, crash for superballs)
// for (let i = 0, len = bullet.length; i < len; ++i) {
// if (me !== i) {
// sub = Matter.Vector.sub(bullet[me].position, bullet[i].position);
// dist = Matter.Vector.magnitude(sub);
// if (dist < bullet[me].explodeRad) {
// knock = Matter.Vector.mult(Matter.Vector.normalise(sub), (-Math.sqrt(dmg) * bullet[i].mass) / 10);
// bullet[i].force.x += knock.x;
// bullet[i].force.y += knock.y;
// console.log(sub, dist, knock)
// } else if (dist < alertRange) {
// knock = Matter.Vector.mult(Matter.Vector.normalise(sub), (-Math.sqrt(dmg) * bullet[i].mass) / 20);
// bullet[i].force.x += knock.x;
// bullet[i].force.y += knock.y;
// }
// }
// }
//destroy all bullets in range
// for (let i = 0, len = bullet.length; i < len; ++i) {
@@ -219,16 +239,9 @@ const b = {
// Matter.Vector.magnitudeSquared(Matter.Vector.sub(bullet[me].position, mob[i].position))
},
guns: [
// {
// name: "field emitter",
// ammo: Infinity,
// ammoPack: Infinity,
// have: true,
// fire() {}
// },
{
guns: [{
name: "laser",
description: "fire a beam of coherent light<br>reflects off walls at 75% intensity<br>uses energy instead of ammunition",
ammo: 0,
// ammoPack: 350,
ammoPack: Infinity,
@@ -388,6 +401,7 @@ const b = {
},
{
name: "one shot",
description: "fire a huge bullet with high recoil<br>effective at long distances",
ammo: 0,
ammoPack: 5,
have: false,
@@ -411,8 +425,9 @@ const b = {
},
{
name: "rapid fire",
description: "fire a stream of bullets",
ammo: 0,
ammoPack: 105,
ammoPack: 100,
have: false,
fire() {
const me = bullet.length;
@@ -430,8 +445,9 @@ const b = {
},
{
name: "wave beam",
description: "fire a stream of oscillating particles<br>propagates through solids<br>effective at close range",
ammo: 0,
ammoPack: 110,
ammoPack: 100,
have: false,
fire() {
const me = bullet.length;
@@ -484,6 +500,7 @@ const b = {
},
{
name: "super balls",
description: "fire 3 very bouncy balls",
ammo: 0,
ammoPack: 10,
have: false,
@@ -494,7 +511,7 @@ const b = {
let dir = mech.angle - SPREAD;
for (let i = 0; i < 3; i++) {
const me = bullet.length;
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 7, b.fireAttributes(dir));
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 7, b.fireAttributes(dir, false));
b.fireProps(mech.crouch ? 40 : 20, mech.crouch ? 34 : 26, dir, me); //cd , speed
Matter.Body.setDensity(bullet[me], 0.0001);
bullet[me].endCycle = game.cycle + 360;
@@ -511,6 +528,7 @@ const b = {
},
{
name: "spray",
description: "fire a burst of bullets with high recoil<br>more effective at close range",
ammo: 0,
ammoPack: 8,
have: false,
@@ -537,6 +555,7 @@ const b = {
},
{
name: "needles",
description: "fire a narrow projectile<br>effective at long distances",
ammo: 0,
ammoPack: 17,
have: false,
@@ -560,6 +579,7 @@ const b = {
},
{
name: "missiles",
description: "fire a missile that accelerates towards nearby targets<br>explodes when near target",
ammo: 0,
ammoPack: 8,
have: false,
@@ -653,6 +673,7 @@ const b = {
},
{
name: "flak",
description: "fire a cluster of high speed explosive projectiles<br>explode on contact or after half a second",
ammo: 0,
ammoPack: 18,
have: false,
@@ -691,13 +712,14 @@ const b = {
},
{
name: "M80",
description: "rapidly fire small bouncy bombs<br>explodes on contact or after 2 seconds",
ammo: 0,
ammoPack: 45,
have: false,
fire() {
const me = bullet.length;
const dir = mech.angle; // + Math.random() * 0.05;
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 10, b.fireAttributes(dir));
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 10, b.fireAttributes(dir, false));
b.fireProps(mech.crouch ? 15 : 8, mech.crouch ? 32 : 24, dir, me); //cd , speed
b.drawOneBullet(bullet[me].vertices);
Matter.Body.setDensity(bullet[me], 0.000001);
@@ -719,13 +741,14 @@ const b = {
},
{
name: "grenades",
description: "fire a huge sticky bomb<br>explodes on contact or after 2 seconds",
ammo: 0,
ammoPack: 5,
have: false,
fire() {
const me = bullet.length;
const dir = mech.angle;
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 22, b.fireAttributes(dir));
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 22, b.fireAttributes(dir, false));
bullet[me].radius = 22; //used from drawing timer
b.fireProps(mech.crouch ? 60 : 40, mech.crouch ? 38 : 30, dir, me); //cd , speed
b.drawOneBullet(bullet[me].vertices);
@@ -734,6 +757,7 @@ const b = {
// bullet[me].restitution = 0.3;
// bullet[me].frictionAir = 0.01;
// bullet[me].friction = 0.15;
bullet[me].inertia = Infinity; //prevents rotation
bullet[me].restitution = 0;
bullet[me].friction = 1;
@@ -770,13 +794,14 @@ const b = {
},
{
name: "spores",
description: "release an orb discharges spores after 2 seconds<br>spores seek out targets<br>spores can pass through blocks",
ammo: 0,
ammoPack: 6,
have: false,
fire() {
const me = bullet.length;
const dir = mech.angle;
bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 20, 4.5, b.fireAttributes(dir));
bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 20, 4.5, b.fireAttributes(dir, false));
b.fireProps(mech.crouch ? 75 : 55, mech.crouch ? 25 : 14, dir, me); //cd , speed
b.drawOneBullet(bullet[me].vertices);
Matter.Body.setDensity(bullet[me], 0.000001);
@@ -808,6 +833,7 @@ const b = {
const RADIUS = 4 + 2 * Math.random();
bullet[bIndex] = Bodies.circle(this.position.x, this.position.y, RADIUS, {
// density: 0.0015, //frictionAir: 0.01,
inertia: Infinity,
restitution: 0.9,
angle: dir,
friction: 0,
@@ -826,7 +852,7 @@ const b = {
onEnd() {},
lookFrequency: 67 + Math.floor(47 * Math.random()),
do() {
this.force.y += this.mass * 0.00025; // high gravity because of the high friction
this.force.y += this.mass * 0.00025; //gravity
//find mob targets
if (!(game.cycle % this.lookFrequency)) {
@@ -834,12 +860,8 @@ const b = {
this.lockedOn = null;
let closeDist = Infinity;
for (let i = 0, len = mob.length; i < len; ++i) {
if (
// mob[i].alive &&
// mob[i].dropPowerUp &&
Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
Matter.Query.ray(body, this.position, mob[i].position).length === 0
) {
if (Matter.Query.ray(map, this.position, mob[i].position).length === 0) {
// Matter.Query.ray(body, this.position, mob[i].position).length === 0
const targetVector = Matter.Vector.sub(this.position, mob[i].position)
const dist = Matter.Vector.magnitude(targetVector);
if (dist < closeDist) {
@@ -852,8 +874,8 @@ const b = {
}
}
//accelerate towards mobs
const THRUST = this.mass * 0.0008
if (this.lockedOn) {
const THRUST = this.mass * 0.001
this.force.x -= THRUST * this.lockedOn.x
this.force.y -= THRUST * this.lockedOn.y
}
@@ -873,6 +895,7 @@ const b = {
},
{
name: "drones",
description: "release drones that seek out targets<br>waits at crosshairs if no targets are available",
ammo: 0,
ammoPack: 23,
have: false,
@@ -883,6 +906,7 @@ const b = {
const RADIUS = 4 + 4 * Math.random()
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,
frictionAir: 0.0005,
restitution: 1,

View File

@@ -218,6 +218,9 @@ const game = {
levelsCleared: 0,
g: 0.001,
dmgScale: 1,
accelScale: 1,
CDScale: 1,
lookFreqScale: 1,
onTitlePage: true,
paused: false,
testing: false, //testing mode: shows wireframe and some variables
@@ -345,6 +348,21 @@ const game = {
game.boldActiveGunHUD();
// mech.drop();
},
// tips = [
// "You can throw blocks at dangerous speeds by holding the right mouse or spacebar.",
// "You can use your field to block damage. (right mouse or spacebar)",
// "Explosive weapons, like the grenade are good at clearing groups.",
// "Larger and faster bullets do more damage.",
// "You take more damage from colliding with larger baddies",
// "Holding large blocks slows down the player.",
// "holding blocks prevents the field energy from regenerating.",
// `There are ${mech.fieldUpgrades.length-1} possible field upgrades.`,
// `There are ${b.guns.length} different guns.`,
// "You keep field upgrades after you die.",
// "Unique level bosses always drop a field upgrade if you don't have one.",
// "You jump higher if you hold down the jump button.",
// "Crouching while firing makes bullets go faster, but slows the rate of fire.",
// ]
keyPress() {
//runs on key press event
// if (keys[49]) {
@@ -447,8 +465,18 @@ const game = {
}
} else if (this.testing) {
//only in testing mode
if (keys[70]) {
// f for power ups
if (keys[70]) { //cycle fields with F
if (mech.fieldMode === mech.fieldUpgrades.length - 1) {
mech.fieldUpgrades[0]()
} else {
mech.fieldUpgrades[mech.fieldMode + 1]()
}
}
if (keys[71]) { // give all guns with G
b.giveGuns("all", 1000)
}
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");
@@ -456,13 +484,9 @@ const game = {
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");
// for (let i = 0; i < 16; ++i) {
// powerUps.spawnRandomPowerUp(game.mouseInGame.x, game.mouseInGame.y, 0, 0);
// }
}
if (keys[82]) {
// r to teleport to mouse
if (keys[82]) { // teleport to mouse with R
Matter.Body.setPosition(player, this.mouseInGame);
Matter.Body.setVelocity(player, {
x: 0,
@@ -745,7 +769,11 @@ const game = {
line += 20;
ctx.fillText("R: teleport to mouse", x, line);
line += 20;
ctx.fillText("F: spawn power ups", x, line);
ctx.fillText("F: cycle field", x, line);
line += 20;
ctx.fillText("G: give all guns", x, line);
line += 20;
ctx.fillText("H: spawn power ups", x, line);
line += 30;
ctx.fillText("cycle: " + game.cycle, x, line);

View File

@@ -23,8 +23,8 @@ const level = {
// this.towers();
// game.levelsCleared = 3; //for testing to simulate possible mobs spawns
// b.giveGuns(0) // set a starting gun for testing
mech.fieldUpgrades[6]() //give a field power up for testing
// b.giveGuns(11) // set a starting gun for testing
// mech.fieldUpgrades[6]() //give a field power up for testing
} else {
spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
this[this.levels[this.onLevel]](); //picks the current map from the the levels array
@@ -34,6 +34,13 @@ const level = {
this.addToWorld(); //add bodies to game engine
game.draw.setPaths();
},
difficultyIncrease() {
game.dmgScale += 0.35; //damage done by mobs increases each level
b.dmgScale *= 0.92; //damage done by player decreases each level
game.accelScale *= 1.05 //mob acceleration increases each level
game.lookFreqScale *= 0.95 //mob cycles between looks decreases each level
game.CDScale *= 0.95 //mob CD time decreases each level
},
//******************************************************************************************************************
//******************************************************************************************************************
testingMap() {
@@ -42,8 +49,7 @@ const level = {
spawn.setSpawnList();
game.levelsCleared = 3; //for testing to simulate all possible mobs spawns
for (let i = 0; i < game.levelsCleared; i++) {
game.dmgScale += 0.4; //damage done by mobs increases each level
b.dmgScale *= 0.9; //damage done by player decreases each level
level.difficultyIncrease()
}
mech.setPosToSpawn(-75, -60); //normal spawn
level.enter.x = mech.spawnPos.x - 50;
@@ -1298,12 +1304,8 @@ const level = {
nextLevel() {
//enter when player isn't falling
if (player.velocity.y < 0.1) {
//increases difficulty
game.levelsCleared++;
if (game.levelsCleared > 1) {
game.dmgScale += 0.25; //damage done by mobs increases each level
b.dmgScale *= 0.93; //damage done by player decreases each level
}
if (game.levelsCleared > 1) level.difficultyIncrease()
//cycles map to next level
level.onLevel++;
if (level.onLevel > level.levels.length - 1) level.onLevel = 0;
@@ -1401,9 +1403,8 @@ const level = {
}
},
levelAnnounce() {
let text = (game.levelsCleared) + " " + level.levels[level.onLevel];
document.title = "n-gon: L" + text;
game.makeTextLog("level " + text, 300);
document.title = "n-gon: L" + (game.levelsCleared) + " " + level.levels[level.onLevel];
game.makeTextLog(`<div style='font-size: 25px;'>level ${game.levelsCleared} </div> <div style='font-size: 32px;'>${level.levels[level.onLevel]} </div>`, 300);
// if (game.levelsCleared === 0) text = "";
// text = "Level " + (game.levelsCleared + 1) + ": " + spawn.pickList[0] + "s + " + spawn.pickList[1] + "s";

View File

@@ -96,7 +96,7 @@ const mobs = {
gravity() {
this.force.y += this.mass * this.g;
},
seePlayerFreq: 20 + Math.round(Math.random() * 20), //how often NPC checks to see where player is, lower numbers have better vision
seePlayerFreq: Math.round((30 + 30 * Math.random()) * game.lookFreqScale), //how often NPC checks to see where player is, lower numbers have better vision
foundPlayer() {
this.locatePlayer();
if (!this.seePlayer.yes) {

View File

@@ -670,6 +670,7 @@ const mech = {
ctx.moveTo(mech.pos.x + eye * Math.cos(this.angle), mech.pos.y + eye * Math.sin(this.angle));
ctx.lineTo(this.pos.x + range * Math.cos(offAngle), this.pos.y + range * Math.sin(offAngle));
ctx.strokeStyle = "rgba(120,170,255,0.4)";
ctx.lineWidth = 1;
ctx.stroke();
},
grabPowerUp() {
@@ -825,7 +826,7 @@ const mech = {
fieldUpgrades: [
() => {
mech.fieldMode = 0;
game.makeTextLog("<strong style='font-size:30px;'>Field Emitter</strong><br> (right click or space bar)<p>lets you pick up and throw objects<br>shields you from damage</p>", Infinity);
game.makeTextLog("<strong style='font-size:30px;'>Field Emitter</strong><br> (right click or space bar)<p>lets you pick up and throw objects<br>shields you from damage</p>", 1200);
mech.setHoldDefaults();
mech.hold = function () {
if (mech.isHolding) {
@@ -867,7 +868,7 @@ const mech = {
mech.grabPowerUp();
// mech.pushMobs();
mech.pushMobs360(180);
mech.lookForPickUp(130);
mech.lookForPickUp(160);
//draw slow field
ctx.beginPath();
@@ -973,9 +974,9 @@ const mech = {
const DRAIN = 0.001 //mech.fieldRegen = 0.0015
if (mech.fieldMeter > DRAIN) {
mech.fieldMeter -= DRAIN;
mech.pushMobs360(200);
mech.pushMobs360(170);
mech.grabPowerUp();
mech.lookForPickUp();
mech.lookForPickUp(170);
//look for nearby objects to make zero-g
function zeroG(who) {
for (let i = 0, len = who.length; i < len; ++i) {
@@ -1135,7 +1136,7 @@ const mech = {
ctx.beginPath();
ctx.arc(mech.pos.x, mech.pos.y, mech.grabRange, 0, 2 * Math.PI);
ctx.globalCompositeOperation = "destination-in"; //in or atop
ctx.fillStyle = "rgba(255,255,255,0.2)";
ctx.fillStyle = "rgba(255,255,255,0.25)";
ctx.fill();
ctx.globalCompositeOperation = "source-over";
ctx.strokeStyle = "#000"
@@ -1145,7 +1146,7 @@ const mech = {
// mech.pushMobs360(150);
mech.grabPowerUp();
mech.lookForPickUp();
mech.lookForPickUp(110);
} else {
mech.fieldCDcycle = game.cycle + 120;
}

View File

@@ -8,9 +8,10 @@ const powerUps = {
return 40 * Math.sqrt(0.1 + Math.random() * 0.5);
},
effect() {
let heal = this.size / 40;
mech.addHealth(heal * heal);
//game.makeTextLog('heal for '+(heal*100).toFixed(0)+'%',80)
let heal = (this.size / 40) ** 2
heal = Math.min(1 - mech.health, heal)
mech.addHealth(heal);
if (!game.lastLogTime && heal > 0) game.makeTextLog('heal for ' + (heal * 100).toFixed(0) + '%', 180)
}
},
field: {
@@ -37,20 +38,6 @@ const powerUps = {
mech.fieldCDcycle = game.cycle + 60; //trigger fieldCD to stop power up grab automatic pick up of spawn
powerUps.spawn(mech.pos.x, mech.pos.y, "field", false, previousMode);
}
// mech.fieldUpgrades[3]();
//pause game so player can read above the new field
// game.fpsCap = 0 //40 - Math.min(25, 100 * dmg)
// game.fpsInterval = 1000 / game.fpsCap;
// function unpause() {
// game.fpsCap = 72
// game.fpsInterval = 1000 / game.fpsCap;
// document.body.removeEventListener("keydown", unpause);
// }
// document.body.addEventListener("keydown", unpause);
}
},
ammo: {
@@ -80,13 +67,13 @@ const powerUps = {
}
if (target.ammo === Infinity) {
mech.fieldMeter = 1;
game.makeTextLog("+energy", 180);
if (!game.lastLogTime) game.makeTextLog("+energy", 180);
} else {
//ammo given scales as mobs take more hits to kill
const ammo = Math.ceil((target.ammoPack * (0.70 + 0.2 * Math.random())) / b.dmgScale);
const ammo = Math.ceil((target.ammoPack * (0.55 + 0.1 * Math.random())) / b.dmgScale);
target.ammo += ammo;
game.updateGunHUD();
game.makeTextLog("+" + ammo + " ammo: " + target.name, 180);
if (!game.lastLogTime) game.makeTextLog("+" + ammo + " ammo: " + target.name, 180);
}
}
},
@@ -114,18 +101,10 @@ const powerUps = {
Infinity
);
}
if (b.inventory.length === 1) {
game.makeTextLog(
// "<div style='font-size:120%;' >new gun: " + b.guns[newGun].name + "</div><span class = 'box'>E</span> / <span class = 'box'>Q</span>",
"<div style='font-size:170%;'>" + b.guns[newGun].name + "</div> (left click) <br> <p style='font-size:90%;'><strong>Q</strong>, <strong>E</strong>, and <strong>mouse wheel</strong> change weapons</p>",
500
);
if (b.inventory.length === 1) { //on the second gun pick up tell player how to change guns
game.makeTextLog(`<strong style='font-size:30px;'>${b.guns[newGun].name}</strong><br>(left click)<br>(<strong>Q</strong>, <strong>E</strong>, and <strong>mouse wheel</strong> change weapons)<p>${b.guns[newGun].description}</p>`, 1000);
} else {
game.makeTextLog(
// "<div style='font-size:120%;' >new gun: " + b.guns[newGun].name + "</div><span class = 'box'>E</span> / <span class = 'box'>Q</span>",
"<div style='font-size:170%;'>" + b.guns[newGun].name + "</div> (left click)",
400
);
game.makeTextLog(`<strong style='font-size:30px;'>${b.guns[newGun].name}</strong><br> (left click)<p>${b.guns[newGun].description}</p>`, 1000);
}
b.guns[newGun].have = true;
b.inventory.push(newGun);
@@ -150,7 +129,7 @@ const powerUps = {
if (b.inventory.length > 0) powerUps.spawn(x, y, "ammo");
return;
}
if (Math.random() < 0.006 * (6 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun to drop
if (Math.random() < 0.005 * (6 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun to drop
powerUps.spawn(x, y, "gun");
return;
}

View File

@@ -27,19 +27,16 @@ const spawn = {
spawn.pickList.push(spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)]);
},
randomMob(x, y, chance = 1) {
if (Math.random() < chance + 0.1 * (game.levelsCleared - 1) && mob.length < 4 + game.levelsCleared * 2) {
if (Math.random() < chance + 0.09 * (game.levelsCleared - 1) && mob.length < 4 + game.levelsCleared * 1.7) {
const pick = this.pickList[Math.floor(Math.random() * this.pickList.length)];
this[pick](x, y);
}
},
randomSmallMob(
x,
y,
num = Math.max(Math.min(Math.round(Math.random() * (game.levelsCleared - 1) * 0.5 - 0.4), 4), 0),
randomSmallMob(x, y,
num = Math.max(Math.min(Math.round(Math.random() * (game.levelsCleared - 1) * 0.45 - 0.4), 4), 0),
size = 16 + Math.ceil(Math.random() * 15),
chance = 1
) {
if (Math.random() < chance + (game.levelsCleared - 1) * 0.03 && mob.length < 4 + game.levelsCleared * 2) {
chance = 1) {
if (Math.random() < chance + (game.levelsCleared - 1) * 0.03 && mob.length < 4 + game.levelsCleared * 1.7) {
for (let i = 0; i < num; ++i) {
const pick = this.pickList[Math.floor(Math.random() * this.pickList.length)];
this[pick](x + Math.round((Math.random() - 0.5) * 20) + i * size * 2.5, y + Math.round((Math.random() - 0.5) * 20), size);
@@ -47,7 +44,7 @@ const spawn = {
}
},
randomBoss(x, y, chance = 1) {
if (Math.random() < chance + (game.levelsCleared - 1) * 0.15 && game.levelsCleared !== 1 && mob.length < 4 + game.levelsCleared * 2.1 || chance == Infinity) {
if (Math.random() < chance + (game.levelsCleared - 1) * 0.14 && game.levelsCleared !== 1 && mob.length < 4 + game.levelsCleared * 2 || chance == Infinity) {
//choose from the possible picklist
let pick = this.pickList[Math.floor(Math.random() * this.pickList.length)];
//is the pick able to be a boss?
@@ -93,7 +90,7 @@ const spawn = {
mobs.spawn(x, y, 4, radius, "#777");
let me = mob[mob.length - 1];
me.g = 0.0002; //required if using 'gravity'
me.accelMag = 0.0007;
me.accelMag = 0.0007 * game.accelScale;
me.groupingRangeMax = 250000 + Math.random() * 100000;
me.groupingRangeMin = (radius * 8) * (radius * 8);
me.groupingStrength = 0.0005
@@ -133,7 +130,7 @@ const spawn = {
//easy mob for on level 1
mobs.spawn(x, y, 8, radius, "#9ccdc6");
let me = mob[mob.length - 1];
me.accelMag = 0.00055;
me.accelMag = 0.00055 * game.accelScale;
me.memory = 60;
Matter.Body.setDensity(me, 0.0005) // normal density is 0.001 // this reduces life by half and decreases knockback
@@ -148,7 +145,7 @@ const spawn = {
mobs.spawn(x, y, 3, radius, "rgba(50,255,200,0.4)");
let me = mob[mob.length - 1];
me.frictionAir = 0.02;
me.accelMag = 0.0004;
me.accelMag = 0.0004 * game.accelScale;
if (map.length) me.searchTarget = map[Math.floor(Math.random() * (map.length - 1))].position; //required for search
me.lookFrequency = 160 + Math.floor(57 * Math.random())
me.lockedOn = null;
@@ -236,7 +233,7 @@ const spawn = {
// Matter.Body.setDensity(me, 0.0007); //extra dense //normal is 0.001 //makes effective life much lower
me.friction = 0;
me.frictionAir = 0;
me.accelMag = 0.001;
me.accelMag = 0.001 * game.accelScale;;
me.g = me.accelMag * 0.6; //required if using 'gravity'
me.memory = 50;
if (Math.random() < Math.min((game.levelsCleared - 1) * 0.1, 0.7)) spawn.shield(me, x, y);
@@ -251,7 +248,7 @@ const spawn = {
mobs.spawn(x, y, 7, radius, "hsl(144, 15%, 50%)");
let me = mob[mob.length - 1];
me.big = false; //required for grow
me.accelMag = 0.00045;
me.accelMag = 0.00045 * game.accelScale;
me.do = function () {
this.healthBar();
this.seePlayerByLookingAt();
@@ -266,7 +263,7 @@ const spawn = {
me.frictionAir = 0.1;
me.lookTorque = 0.000005;
me.g = 0.0002; //required if using 'gravity'
me.seePlayerFreq = Math.ceil(40 + 25 * Math.random());
me.seePlayerFreq = Math.round((40 + 25 * Math.random()) * game.lookFreqScale);
const springStiffness = 0.002;
const springDampening = 0.1;
@@ -316,7 +313,7 @@ const spawn = {
me.trailFill = "#ff00f0";
me.g = 0.001; //required if using 'gravity'
me.frictionAir = 0.02;
me.accelMag = 0.004;
me.accelMag = 0.004 * game.accelScale;
me.memory = 30;
me.zoomMode = 150;
me.onHit = function () {
@@ -332,7 +329,7 @@ const spawn = {
hopper(x, y, radius = 30 + Math.ceil(Math.random() * 30)) {
mobs.spawn(x, y, 5, radius, "rgb(0,200,180)");
let me = mob[mob.length - 1];
me.accelMag = 0.04;
me.accelMag = 0.04 * game.accelScale;
me.g = 0.0015; //required if using 'gravity'
me.frictionAir = 0.018;
me.restitution = 0;
@@ -368,7 +365,7 @@ const spawn = {
x: 0,
y: 0
};
me.accelMag = 0.16;
me.accelMag = 0.16 * game.accelScale;
me.frictionAir = 0.022;
me.lookTorque = 0.0000014;
me.restitution = 0;
@@ -420,7 +417,7 @@ const spawn = {
me.stroke = "transparent"; //used for drawSneaker
me.eventHorizon = radius * 23; //required for blackhole
me.seeAtDistance2 = (me.eventHorizon + 500) * (me.eventHorizon + 500); //vision limit is event horizon
me.accelMag = 0.00009;
me.accelMag = 0.00009 * game.accelScale;
// me.frictionAir = 0.005;
me.memory = 600;
Matter.Body.setDensity(me, 0.004); //extra dense //normal is 0.001 //makes effective life much larger
@@ -485,8 +482,7 @@ const spawn = {
let me = mob[mob.length - 1];
me.repulsionRange = 73000; //squared
me.laserRange = 370;
// me.seePlayerFreq = 2 + Math.round(Math.random() * 5);
me.accelMag = 0.0005;
me.accelMag = 0.0005 * game.accelScale;
me.frictionStatic = 0;
me.friction = 0;
if (Math.random() < Math.min(0.2 + (game.levelsCleared - 1) * 0.1, 0.7)) spawn.shield(me, x, y);
@@ -507,8 +503,7 @@ const spawn = {
me.restitution = 0;
me.laserPos = me.position; //required for laserTracking
me.repulsionRange = 1200000; //squared
//me.seePlayerFreq = 2 + Math.round(Math.random() * 5);
me.accelMag = 0.0002;
me.accelMag = 0.0002 * game.accelScale;
me.frictionStatic = 0;
me.friction = 0;
me.onDamage = function () {
@@ -576,7 +571,7 @@ const spawn = {
let me = mob[mob.length - 1];
me.vertices = Matter.Vertices.rotate(me.vertices, Math.PI, me.position); //make the pointy side of triangle the front
Matter.Body.rotate(me, Math.random() * Math.PI * 2);
me.accelMag = 0.00007;
me.accelMag = 0.00007 * game.accelScale;
me.onHit = function () {
//run this function on hitting player
this.explode();
@@ -591,7 +586,7 @@ const spawn = {
striker(x, y, radius = 15 + Math.ceil(Math.random() * 25)) {
mobs.spawn(x, y, 5, radius, "rgb(221,102,119)");
let me = mob[mob.length - 1];
me.accelMag = 0.0004;
me.accelMag = 0.0004 * game.accelScale;
me.g = 0.0002; //required if using 'gravity'
me.frictionStatic = 0;
me.friction = 0;
@@ -612,7 +607,7 @@ const spawn = {
let me;
mobs.spawn(x, y, 5, radius, "transparent");
me = mob[mob.length - 1];
me.accelMag = 0.0007;
me.accelMag = 0.0007 * game.accelScale;
me.g = 0.0002; //required if using 'gravity'
me.stroke = "transparent"; //used for drawSneaker
me.alpha = 1; //used in drawSneaker
@@ -620,7 +615,6 @@ const spawn = {
me.canTouchPlayer = false; //used in drawSneaker
me.collisionFilter.mask = 0x010111; //can't touch player
// me.memory = 420;
// me.seePlayerFreq = 60 + Math.round(Math.random() * 30);
me.do = function () {
this.seePlayerCheck();
this.attraction();
@@ -660,7 +654,7 @@ const spawn = {
mobs.spawn(x, y, 7, radius, "transparent");
me = mob[mob.length - 1];
me.seeAtDistance2 = 1000000;
me.accelMag = 0.00014;
me.accelMag = 0.00014 * game.accelScale;
if (map.length) me.searchTarget = map[Math.floor(Math.random() * (map.length - 1))].position; //required for search
Matter.Body.setDensity(me, 0.00065); //normal is 0.001 //makes effective life much lower
me.stroke = "transparent"; //used for drawGhost
@@ -721,7 +715,7 @@ const spawn = {
me.blinkLength = 150 + Math.round(Math.random() * 200); //required for blink
me.isStatic = true;
me.memory = 360;
me.seePlayerFreq = 40 + Math.round(Math.random() * 30);
me.seePlayerFreq = Math.round((40 + 30 * Math.random()) * game.lookFreqScale);
me.isBig = false;
me.scaleMag = Math.max(5 - me.mass, 1.75);
me.onDeath = function () {
@@ -763,7 +757,7 @@ const spawn = {
me.searchTarget = map[Math.floor(Math.random() * (map.length - 1))].position; //required for search
me.hoverElevation = 400 + (Math.random() - 0.5) * 200; //squared
me.hoverXOff = (Math.random() - 0.5) * 100;
me.accelMag = Math.floor(10 * (Math.random() + 5)) * 0.00001;
me.accelMag = Math.floor(10 * (Math.random() + 5)) * 0.00001 * game.accelScale;
me.g = 0.0002; //required if using 'gravity' // gravity called in hoverOverPlayer
me.frictionStatic = 0;
me.friction = 0;
@@ -791,7 +785,7 @@ const spawn = {
me.fireFreq = 0.007 + Math.random() * 0.005;
me.noseLength = 0;
me.fireAngle = 0;
me.accelMag = 0.0005;
me.accelMag = 0.0005 * game.accelScale;
me.frictionAir = 0.05;
me.lookTorque = 0.0000025 * (Math.random() > 0.5 ? -1 : 1);
me.fireDir = {
@@ -814,7 +808,7 @@ const spawn = {
me.fireFreq = 0.02;
me.noseLength = 0;
me.fireAngle = 0;
me.accelMag = 0.005;
me.accelMag = 0.005 * game.accelScale;
me.frictionAir = 0.1;
me.lookTorque = 0.000005 * (Math.random() > 0.5 ? -1 : 1);
me.fireDir = {
@@ -886,10 +880,10 @@ const spawn = {
this.explode();
};
me.g = 0.0001; //required if using 'gravity'
me.accelMag = 0.0003;
me.accelMag = 0.0003 * game.accelScale;
me.memory = 30;
me.leaveBody = false;
me.seePlayerFreq = 80 + Math.round(Math.random() * 50);
me.seePlayerFreq = Math.round((80 + 50 * Math.random()) * game.lookFreqScale);
me.frictionAir = 0.002;
me.do = function () {
this.healthBar();
@@ -917,7 +911,7 @@ const spawn = {
//snake boss with a laser head
mobs.spawn(x, y, 8, radius, "rgb(255,50,130)");
let me = mob[mob.length - 1];
me.accelMag = 0.0012;
me.accelMag = 0.0012 * game.accelScale;
me.memory = 200;
me.laserRange = 500;
Matter.Body.setDensity(me, 0.001 + 0.0005 * Math.sqrt(game.levelsCleared)); //extra dense //normal is 0.001 //makes effective life much larger
@@ -961,7 +955,7 @@ const spawn = {
mobs.spawn(x, y, 8, radius, "rgb(0,60,80)");
let me = mob[mob.length - 1];
me.g = 0.0001; //required if using 'gravity'
me.accelMag = 0.002;
me.accelMag = 0.002 * game.accelScale;
me.memory = 20;
Matter.Body.setDensity(me, 0.001 + 0.0005 * Math.sqrt(game.levelsCleared)); //extra dense //normal is 0.001 //makes effective life much larger
spawn.shield(me, x, y);
@@ -1199,8 +1193,8 @@ const spawn = {
mobs.spawn(breakingPoint, -100, 0, 7.5, "transparent");
let me = mob[mob.length - 1];
//touch nothing
me.collisionFilter.category = 0x000000;
me.collisionFilter.mask = 0x000000;
me.collisionFilter.category = 0x010000; //act like a body
me.collisionFilter.mask = 0x000001; //only collide with map
me.inertia = Infinity;
me.g = 0.0004; //required for gravity
me.restitution = 0;
@@ -1263,8 +1257,8 @@ const spawn = {
mobs.spawn(breakingPoint, -100, 0, 2, "transparent");
let me = mob[mob.length - 1];
//touch nothing
me.collisionFilter.category = 0x000000;
me.collisionFilter.mask = 0x000000;
me.collisionFilter.category = 0x010000; //act like a body
me.collisionFilter.mask = 0x000001; //only collide with map
me.g = 0.0003; //required for gravity
// me.restitution = 0;
me.stroke = "transparent"
@@ -1311,8 +1305,8 @@ const spawn = {
mobs.spawn(breakingPoint, -100, 0, 2, "transparent");
let me = mob[mob.length - 1];
//touch nothing
me.collisionFilter.category = 0x000000;
me.collisionFilter.mask = 0x000000;
me.collisionFilter.category = 0x010000; //act like a body
me.collisionFilter.mask = 0x000001; //only collide with map
me.g = 0.0003; //required for gravity
// me.restitution = 0;
me.stroke = "transparent"
@@ -1359,8 +1353,8 @@ const spawn = {
mobs.spawn(breakingPoint, -100, 0, 2, "transparent");
let me = mob[mob.length - 1];
//touch nothing
me.collisionFilter.category = 0x000000;
me.collisionFilter.mask = 0x000000;
me.collisionFilter.category = 0x010000; //act like a body
me.collisionFilter.mask = 0x000001; //only collide with map
me.g = 0.0003; //required for gravity
me.restitution = 0;
me.stroke = "transparent"
@@ -1406,8 +1400,8 @@ const spawn = {
mobs.spawn(breakingPoint, -100, 0, 2, "transparent");
let me = mob[mob.length - 1];
//touch nothing
me.collisionFilter.category = 0x000000;
me.collisionFilter.mask = 0x000000;
me.collisionFilter.category = 0x010000; //act like a body
me.collisionFilter.mask = 0x000001; //only collide with map
me.g = 0.0003; //required for gravity
me.restitution = 0;
me.stroke = "transparent"

View File

@@ -137,7 +137,7 @@ summary {
top: 20px;
left: 0;
width: 100%;
line-height: 180%;
line-height: 150%;
text-align: center;
z-index: 2;
font-size: 1.3em;