time field adjustments

This commit is contained in:
landgreen
2019-10-17 05:26:45 -07:00
parent 963c930120
commit 5809a68360
6 changed files with 74 additions and 82 deletions

View File

@@ -1029,7 +1029,7 @@ const b = {
name: "drones", name: "drones",
description: "release drones that seek out targets<br>if no targets, drones move to mouse<br>", description: "release drones that seek out targets<br>if no targets, drones move to mouse<br>",
ammo: 0, ammo: 0,
ammoPack: 21, ammoPack: 20,
have: false, have: false,
fire() { fire() {
const THRUST = 0.0015 const THRUST = 0.0015
@@ -1042,8 +1042,8 @@ const b = {
friction: 0, friction: 0,
frictionAir: 0.0005, frictionAir: 0.0005,
restitution: 1, restitution: 1,
dmg: 0.15, //damage done in addition to the damage from momentum dmg: 0.14, //damage done in addition to the damage from momentum
lookFrequency: 79 + Math.floor(32 * Math.random()), lookFrequency: 79 + Math.floor(37 * Math.random()),
endCycle: game.cycle + 780 + 360 * Math.random(), endCycle: game.cycle + 780 + 360 * Math.random(),
classType: "bullet", classType: "bullet",
collisionFilter: { collisionFilter: {

View File

@@ -68,15 +68,15 @@ add bullet on damage effects
// collision info: // collision info:
category mask category mask
powerUp: 0x100000 0x100001 powerUp: 0x100000 0x100001
body: 0x010000 0x011111 body: 0x010000 0x011111
player: 0x001000 0x010011 player: 0x001000 0x010011
bullet: 0x000100 0x010011 bullet: 0x000100 0x010011
mob: 0x000010 0x011111 mob: 0x000010 0x011111
mobBull: 0x000010 0x011101 mobBullet: 0x000010 0x011101
mobshld: 0x000010 0x001100 mobShield: 0x000010 0x001100
map: 0x000001 0x111111 map: 0x000001 0x111111

View File

@@ -6,6 +6,7 @@ let consBB = []; //all constraints between two bodies
//main object for spawning levels //main object for spawning levels
const level = { const level = {
maxJump: 390, maxJump: 390,
defaultZoom: 1400,
boostScale: 0.000023, boostScale: 0.000023,
levels: ["skyscrapers", "rooftops", "warehouse", "highrise", "office", "aerie"], levels: ["skyscrapers", "rooftops", "warehouse", "highrise", "office", "aerie"],
onLevel: 0, onLevel: 0,
@@ -16,13 +17,14 @@ const level = {
// game.levelsCleared = 4; //for testing to simulate possible mobs spawns // game.levelsCleared = 4; //for testing to simulate possible mobs spawns
// b.giveGuns(1) // set a starting gun for testing // b.giveGuns(1) // set a starting gun for testing
// b.giveGuns("all", 1000) // b.giveGuns("all", 1000)
mech.fieldUpgrades[1]() //give a field power up for testing // mech.fieldUpgrades[1]() //give a field power up for testing
// this.intro(); //starting level
this.intro(); //starting level
// this.testingMap(); // this.testingMap();
// this.bosses(); // this.bosses();
// this.aerie(); // this.aerie();
// this.rooftops(); // this.rooftops();
this.warehouse(); // this.warehouse();
// this.highrise(); // this.highrise();
// this.office(); // this.office();
} else { } else {
@@ -126,7 +128,8 @@ const level = {
// } // }
}, },
bosses() { bosses() {
game.zoomTransition(1500) level.defaultZoom = 1500
game.zoomTransition(level.defaultZoom)
// spawn.setSpawnList(); // spawn.setSpawnList();
// spawn.setSpawnList(); // spawn.setSpawnList();
@@ -136,15 +139,15 @@ const level = {
// b.dmgScale *= 0.9; //damage done by player decreases each level // b.dmgScale *= 0.9; //damage done by player decreases each level
// } // }
document.body.style.backgroundColor = "#444"; document.body.style.backgroundColor = "#fff";
level.fillBG.push({ // level.fillBG.push({
x: -150, // x: -150,
y: -1150, // y: -1150,
width: 7000, // width: 7000,
height: 1200, // height: 1200,
color: "#eee" // color: "#eee"
}); // });
level.fill.push({ level.fill.push({
x: 6400, x: 6400,
@@ -161,9 +164,9 @@ const level = {
level.exit.y = -230; level.exit.y = -230;
this.addZone(level.exit.x, level.exit.y, 100, 30, "nextLevel"); this.addZone(level.exit.x, level.exit.y, 100, 30, "nextLevel");
spawn.mapRect(-250, 0, 7000, 200); //ground spawn.mapRect(-950, 0, 8200, 800); //ground
spawn.mapRect(-350, -1200, 200, 1400); //left wall spawn.mapRect(-950, -1200, 800, 1400); //left wall
spawn.mapRect(-250, -1200, 7000, 200); //roof spawn.mapRect(-950, -1800, 8200, 800); //roof
spawn.mapRect(-250, -700, 1000, 900); // shelf spawn.mapRect(-250, -700, 1000, 900); // shelf
spawn.mapRect(-250, -1200, 1000, 250); // shelf roof spawn.mapRect(-250, -1200, 1000, 250); // shelf roof
powerUps.spawnStartingPowerUps(600, -800); powerUps.spawnStartingPowerUps(600, -800);
@@ -190,7 +193,7 @@ const level = {
spawn.lineBoss(5000, -200, spawn.allowedBossList[Math.floor(Math.random() * spawn.allowedBossList.length)]); spawn.lineBoss(5000, -200, spawn.allowedBossList[Math.floor(Math.random() * spawn.allowedBossList.length)]);
spawn.mapRect(6400, -1200, 400, 750); //right wall spawn.mapRect(6400, -1200, 400, 750); //right wall
spawn.mapRect(6400, -200, 400, 300); //right wall spawn.mapRect(6400, -200, 400, 300); //right wall
spawn.mapRect(6700, -1200, 200, 1400); //right wall spawn.mapRect(6700, -1800, 800, 2600); //right wall
spawn.mapRect(level.exit.x, level.exit.y + 20, 100, 100); //exit bump spawn.mapRect(level.exit.x, level.exit.y + 20, 100, 100); //exit bump
for (let i = 0; i < 5; ++i) { for (let i = 0; i < 5; ++i) {
@@ -209,7 +212,8 @@ const level = {
intro() { intro() {
// b.giveGuns(0, 1000) // b.giveGuns(0, 1000)
game.zoomScale = 1000 //1400 is normal game.zoomScale = 1000 //1400 is normal
game.zoomTransition(1600, 1) level.defaultZoom = 1600
game.zoomTransition(level.defaultZoom, 1)
mech.setPosToSpawn(460, -100); //normal spawn mech.setPosToSpawn(460, -100); //normal spawn
level.enter.x = -1000000; //offscreen level.enter.x = -1000000; //offscreen
@@ -217,27 +221,7 @@ const level = {
level.exit.x = 2800; level.exit.x = 2800;
level.exit.y = -335; level.exit.y = -335;
this.addZone(level.exit.x, level.exit.y, 100, 30, "nextLevel"); this.addZone(level.exit.x, level.exit.y, 100, 30, "nextLevel");
document.body.style.backgroundColor = "#444"; document.body.style.backgroundColor = "#fff";
//controls instructions
// game.makeTextLog(
// "<br><br><div class='wrapper'> <div class = 'grid-box'> <span class = 'box'>W</span><br> <span class = 'box'>A</span> <span class = 'box'>S</span> <span class = 'box'>D</span></div> <div class = 'grid-box'> <span class = 'mouse'><span class='mouse-line'></span></span> </div></div>",
// Infinity
// );
level.fill.push({
x: -150,
y: -1150,
width: 2750,
height: 1200,
color: "rgba(0,70,80,0.1)"
});
level.fillBG.push({
x: -150,
y: -1150,
width: 2900,
height: 1200,
color: "#fff"
});
level.fillBG.push({ level.fillBG.push({
x: 2600, x: 2600,
y: -600, y: -600,
@@ -309,10 +293,10 @@ const level = {
wallWire(-200 - i * 10, -215 + i * 10, 660, 5); wallWire(-200 - i * 10, -215 + i * 10, 660, 5);
wallWire(460 - i * 10, -215 + i * 10, 5, 300); wallWire(460 - i * 10, -215 + i * 10, 5, 300);
} }
spawn.mapRect(-250, 0, 3000, 200); //ground spawn.mapRect(-250, 0, 3600, 800); //ground
spawn.mapRect(-350, -1200, 200, 1400); //left wall spawn.mapRect(-950, -1800, 800, 2600); //left wall
spawn.mapRect(3000, -1200, 200, 1400); //right wall spawn.mapRect(3000, -1800, 800, 2600); //right wall
spawn.mapRect(-250, -1200, 3000, 200); //roof spawn.mapRect(-250, -1800, 3600, 800); //roof
spawn.mapRect(2600, -300, 500, 500); //exit shelf spawn.mapRect(2600, -300, 500, 500); //exit shelf
spawn.mapRect(2600, -1200, 500, 600); //exit roof spawn.mapRect(2600, -1200, 500, 600); //exit roof
spawn.mapRect(level.exit.x, level.exit.y + 20, 100, 100); //exit bump spawn.mapRect(level.exit.x, level.exit.y + 20, 100, 100); //exit bump
@@ -358,8 +342,8 @@ const level = {
// spawn.healer(1000, -400) // spawn.healer(1000, -400)
}, },
rooftops() { rooftops() {
game.zoomTransition(1700) //1400 is normal level.defaultZoom = 1700
game.zoomTransition(level.defaultZoom)
document.body.style.backgroundColor = "#dcdcde"; document.body.style.backgroundColor = "#dcdcde";
if (Math.random() < 0.75) { if (Math.random() < 0.75) {
@@ -545,7 +529,8 @@ const level = {
aerie() { aerie() {
// game.setZoom(3000); // game.setZoom(3000);
// game.levelsCleared = 4; //for testing to simulate possible mobs spawns // game.levelsCleared = 4; //for testing to simulate possible mobs spawns
game.zoomTransition(2100) //1400 is normal level.defaultZoom = 2100
game.zoomTransition(level.defaultZoom)
const backwards = (Math.random() < 0.75) ? false : true; const backwards = (Math.random() < 0.75) ? false : true;
if (backwards) { if (backwards) {
@@ -708,7 +693,8 @@ const level = {
//add mini boss, giant hopper? or a black hole that spawns hoppers? //add mini boss, giant hopper? or a black hole that spawns hoppers?
}, },
skyscrapers() { skyscrapers() {
game.zoomTransition(2000) //1400 is normal level.defaultZoom = 2000
game.zoomTransition(level.defaultZoom)
mech.setPosToSpawn(-50, -50); //normal spawn mech.setPosToSpawn(-50, -50); //normal spawn
//mech.setPosToSpawn(1550, -1200); //spawn left high //mech.setPosToSpawn(1550, -1200); //spawn left high
@@ -859,7 +845,9 @@ const level = {
spawn.randomBoss(1700, -900, 0.4); spawn.randomBoss(1700, -900, 0.4);
}, },
highrise() { highrise() {
game.zoomTransition(1500) //1400 is normal level.defaultZoom = 1500
game.zoomTransition(level.defaultZoom)
document.body.style.backgroundColor = "#dcdcde" //"#fafcff"; document.body.style.backgroundColor = "#dcdcde" //"#fafcff";
mech.setPosToSpawn(0, -700); //normal spawn mech.setPosToSpawn(0, -700); //normal spawn
//mech.setPosToSpawn(-2000, -1700); // left ledge spawn //mech.setPosToSpawn(-2000, -1700); // left ledge spawn
@@ -1025,7 +1013,9 @@ const level = {
spawn.randomBoss(-2450, -1100, 0); spawn.randomBoss(-2450, -1100, 0);
}, },
warehouse() { warehouse() {
game.zoomTransition(1300) level.defaultZoom = 1300
game.zoomTransition(level.defaultZoom)
document.body.style.backgroundColor = "#f2f5f3"; document.body.style.backgroundColor = "#f2f5f3";
mech.setPosToSpawn(25, -60); //normal spawn mech.setPosToSpawn(25, -60); //normal spawn
//mech.setPosToSpawn(-2000, -1700); // left ledge spawn //mech.setPosToSpawn(-2000, -1700); // left ledge spawn
@@ -1199,7 +1189,9 @@ const level = {
if (game.levelsCleared > 2) spawn.snaker(-1300 + Math.random() * 2000, -2200); //boss snake with head if (game.levelsCleared > 2) spawn.snaker(-1300 + Math.random() * 2000, -2200); //boss snake with head
}, },
office() { office() {
game.zoomTransition(1400) level.defaultZoom = 1400
game.zoomTransition(level.defaultZoom)
if (Math.random() < 0.75) { if (Math.random() < 0.75) {
//normal direction start in top left //normal direction start in top left
mech.setPosToSpawn(1375, -1550); //normal spawn mech.setPosToSpawn(1375, -1550); //normal spawn

View File

@@ -989,7 +989,7 @@ const mobs = {
//large mobs or too many bodies go intangible and fall until removed from game to help performance //large mobs or too many bodies go intangible and fall until removed from game to help performance
if (body[len].mass > 10 || 40 + 30 * Math.random() < body.length) { if (body[len].mass > 10 || 40 + 30 * Math.random() < body.length) {
body[len].collisionFilter.mask = 0x000000; body[len].collisionFilter.mask = 0x001100;
} }
body[len].classType = "body"; body[len].classType = "body";
World.add(engine.world, body[len]); //add to world World.add(engine.world, body[len]); //add to world

View File

@@ -837,6 +837,7 @@ const mech = {
x: who[i].storeVelocity.x, x: who[i].storeVelocity.x,
y: who[i].storeVelocity.y y: who[i].storeVelocity.y
}) })
Matter.Body.setAngularVelocity(who[i], who[i].storeAngularVelocity)
} }
} }
} }
@@ -877,45 +878,41 @@ const mech = {
}, },
() => { () => {
mech.fieldMode = 1; mech.fieldMode = 1;
game.makeTextLog("<strong style='font-size:30px;'>Time Dilation Field</strong><br> (right mouse or space bar)<p> field stops all objects except player</p>", 1200); game.makeTextLog("<strong style='font-size:30px;'>Time Dilation Field</strong><br> (right mouse or space bar)<p> stop time while field is active</p>", 1200);
// <br> field does <span style='color:#a00;'>not</span> shield player
mech.setHoldDefaults(); mech.setHoldDefaults();
// mech.grabRange = 900; mech.grabRange = 130
mech.fieldShieldingScale = 12;
// mech.fieldArc = 1; //field covers full 360 degrees
// mech.calculateFieldThreshold(); //run after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
mech.isBodiesAsleep = false; mech.isBodiesAsleep = false;
mech.hold = function () { mech.hold = function () {
function sleep(who) {
for (let i = 0, len = who.length; i < len; ++i) {
if (!who[i].isSleeping) who[i].storeVelocity = who[i].velocity
Matter.Sleeping.set(who[i], true)
}
}
if (mech.isHolding) { if (mech.isHolding) {
mech.wakeCheck(); mech.wakeCheck();
mech.drawHold(mech.holdingTarget); mech.drawHold(mech.holdingTarget);
mech.holding(); mech.holding();
mech.throw(); mech.throw();
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) { } else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) {
const DRAIN = 0.002 //mech.fieldRegen = 0.0015 const DRAIN = 0.0015 //mech.fieldRegen = 0.0015
if (mech.fieldMeter > DRAIN) { if (mech.fieldMeter > DRAIN) {
mech.fieldMeter -= DRAIN; mech.fieldMeter -= DRAIN;
mech.grabPowerUp();
mech.lookForPickUp(180);
//draw field everywhere //draw field everywhere
ctx.fillStyle = "rgba(255,255,255," + (0.5 + 0.17 * Math.random()) + ")"; ctx.fillStyle = "rgba(110,170,200," + (0.19 + 0.16 * Math.random()) + ")";
ctx.fillRect(-100000, -100000, 200000, 200000) ctx.fillRect(-100000, -100000, 200000, 200000)
//stop time //stop time
mech.isBodiesAsleep = true; mech.isBodiesAsleep = true;
function sleep(who) {
for (let i = 0, len = who.length; i < len; ++i) {
if (!who[i].isSleeping) {
who[i].storeVelocity = who[i].velocity
who[i].storeAngularVelocity = who[i].angularVelocity
}
Matter.Sleeping.set(who[i], true)
}
}
sleep(mob); sleep(mob);
sleep(body); sleep(body);
sleep(bullet); sleep(bullet);
//doesn't really work, just slows down constraints
for (let i = 0, len = cons.length; i < len; i++) { for (let i = 0, len = cons.length; i < len; i++) {
if (cons[i].stiffness !== 0) { if (cons[i].stiffness !== 0) {
cons[i].storeStiffness = cons[i].stiffness; cons[i].storeStiffness = cons[i].stiffness;
@@ -923,6 +920,9 @@ const mech = {
} }
} }
game.cycle--; //pause all functions that depend on game cycle increasing game.cycle--; //pause all functions that depend on game cycle increasing
mech.grabPowerUp();
mech.lookForPickUp(180);
} else { } else {
mech.wakeCheck(); mech.wakeCheck();
mech.fieldCDcycle = mech.cycle + 120; mech.fieldCDcycle = mech.cycle + 120;

View File

@@ -33,7 +33,7 @@ const powerUps = {
mech.fieldUpgrades[this.mode](); //set a predetermined power up mech.fieldUpgrades[this.mode](); //set a predetermined power up
} }
if (previousMode !== 0) { //pop the old field out in case player wants to swap back if (previousMode !== 0) { //pop the old field out in case player wants to swap back
mech.fieldCDcycle = game.cycle + 60; //trigger fieldCD to stop power up grab automatic pick up of spawn mech.fieldCDcycle = mech.cycle + 40; //trigger fieldCD to stop power up grab automatic pick up of spawn
powerUps.spawn(mech.pos.x, mech.pos.y - 15, "field", false, previousMode); powerUps.spawn(mech.pos.x, mech.pos.y - 15, "field", false, previousMode);
} }
} }