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

View File

@@ -74,8 +74,8 @@ body: 0x010000 0x011111
player: 0x001000 0x010011
bullet: 0x000100 0x010011
mob: 0x000010 0x011111
mobBull: 0x000010 0x011101
mobshld: 0x000010 0x001100
mobBullet: 0x000010 0x011101
mobShield: 0x000010 0x001100
map: 0x000001 0x111111

View File

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

View File

@@ -837,6 +837,7 @@ const mech = {
x: who[i].storeVelocity.x,
y: who[i].storeVelocity.y
})
Matter.Body.setAngularVelocity(who[i], who[i].storeAngularVelocity)
}
}
}
@@ -877,45 +878,41 @@ const mech = {
},
() => {
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);
// <br> field does <span style='color:#a00;'>not</span> shield player
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);
mech.setHoldDefaults();
// mech.grabRange = 900;
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.grabRange = 130
mech.isBodiesAsleep = false;
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) {
mech.wakeCheck();
mech.drawHold(mech.holdingTarget);
mech.holding();
mech.throw();
} 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) {
mech.fieldMeter -= DRAIN;
mech.grabPowerUp();
mech.lookForPickUp(180);
//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)
//stop time
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(body);
sleep(bullet);
//doesn't really work, just slows down constraints
for (let i = 0, len = cons.length; i < len; i++) {
if (cons[i].stiffness !== 0) {
cons[i].storeStiffness = cons[i].stiffness;
@@ -923,6 +920,9 @@ const mech = {
}
}
game.cycle--; //pause all functions that depend on game cycle increasing
mech.grabPowerUp();
mech.lookForPickUp(180);
} else {
mech.wakeCheck();
mech.fieldCDcycle = mech.cycle + 120;

View File

@@ -33,7 +33,7 @@ const powerUps = {
mech.fieldUpgrades[this.mode](); //set a predetermined power up
}
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);
}
}