added timeSKipBoss to levels

This commit is contained in:
landgreen
2020-04-06 07:12:00 -07:00
parent 51cf02f6d5
commit 6c73043c9f
8 changed files with 100 additions and 148 deletions

View File

@@ -334,25 +334,6 @@ const b = {
b.modNailBotCount = 0;
}
},
{
name: "ablative drones",
description: "rebuild your broken parts as <strong>drones</strong><br>chance to occur after being <strong>harmed</strong>",
maxCount: 1,
count: 0,
allowed() {
return true
},
requires: "",
effect() {
b.isModDroneOnDamage = true;
for (let i = 0; i < 4; i++) {
b.drone() //spawn drone
}
},
remove() {
b.isModDroneOnDamage = false;
}
},
{
name: "ablative mines",
description: "rebuild your broken parts as a <strong>mine</strong><br>chance to occur after being <strong>harmed</strong>",
@@ -376,6 +357,25 @@ const b = {
b.isModMineOnDamage = false;
}
},
{
name: "ablative drones",
description: "rebuild your broken parts as <strong>drones</strong><br>chance to occur after being <strong>harmed</strong>",
maxCount: 1,
count: 0,
allowed() {
return true
},
requires: "",
effect() {
b.isModDroneOnDamage = true;
for (let i = 0; i < 4; i++) {
b.drone() //spawn drone
}
},
remove() {
b.isModDroneOnDamage = false;
}
},
{
name: "Lorentzian topology",
description: "your <strong>bullets</strong> last <strong>+33% longer</strong>",
@@ -591,6 +591,10 @@ const b = {
requires: "",
effect() {
b.isModEntanglement = true
setTimeout(function () {
game.boldActiveGunHUD();
}, 10);
},
remove() {
b.isModEntanglement = false;

View File

@@ -257,21 +257,6 @@ 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 down event
if (keys[189]) {
// - key
@@ -393,16 +378,6 @@ const game = {
game.zoomScale = zoomScale
game.zoom = canvas.height / zoomScale; //sets starting zoom scale
},
noCameraScroll() {
// makes the camera not scroll after changing locations
mech.pos.x = player.position.x;
mech.pos.y = playerBody.position.y - mech.yOff;
const scale = 0.8;
mech.transSmoothX = canvas.width2 - mech.pos.x - (game.mouse.x - canvas.width2) * scale;
mech.transSmoothY = canvas.height2 - mech.pos.y - (game.mouse.y - canvas.height2) * scale;
mech.transX += (mech.transSmoothX - mech.transX) * 1;
mech.transY += (mech.transSmoothY - mech.transY) * 1;
},
zoomTransition(newZoomScale, step = 2) {
if (game.isAutoZoom) {
const isBigger = (newZoomScale - game.zoomScale > 0) ? true : false;
@@ -431,18 +406,6 @@ const game = {
}
}
},
camera() {
ctx.save();
ctx.translate(canvas.width2, canvas.height2); //center
ctx.scale(game.zoom, game.zoom); //zoom in once centered
ctx.translate(-canvas.width2 + mech.transX, -canvas.height2 + mech.transY); //translate
//calculate in game mouse position by undoing the zoom and translations
game.mouseInGame.x = (game.mouse.x - canvas.width2) / game.zoom + canvas.width2 - mech.transX;
game.mouseInGame.y = (game.mouse.y - canvas.height2) / game.zoom + canvas.height2 - mech.transY;
},
restoreCamera() {
ctx.restore();
},
zoomInFactor: 0,
startZoomIn(time = 180) {
game.zoom = 0;
@@ -459,6 +422,28 @@ const game = {
}
}
},
noCameraScroll() {
// makes the camera not scroll after changing locations
mech.pos.x = player.position.x;
mech.pos.y = playerBody.position.y - mech.yOff;
const scale = 0.8;
mech.transSmoothX = canvas.width2 - mech.pos.x - (game.mouse.x - canvas.width2) * scale;
mech.transSmoothY = canvas.height2 - mech.pos.y - (game.mouse.y - canvas.height2) * scale;
mech.transX += (mech.transSmoothX - mech.transX) * 1;
mech.transY += (mech.transSmoothY - mech.transY) * 1;
},
camera() {
ctx.save();
ctx.translate(canvas.width2, canvas.height2); //center
ctx.scale(game.zoom, game.zoom); //zoom in once centered
ctx.translate(-canvas.width2 + mech.transX, -canvas.height2 + mech.transY); //translate
//calculate in game mouse position by undoing the zoom and translations
game.mouseInGame.x = (game.mouse.x - canvas.width2) / game.zoom + canvas.width2 - mech.transX;
game.mouseInGame.y = (game.mouse.y - canvas.height2) / game.zoom + canvas.height2 - mech.transY;
},
restoreCamera() {
ctx.restore();
},
wipe() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
},
@@ -711,6 +696,12 @@ const game = {
x: level.enter.x + 50,
y: level.enter.y - 20
});
// Matter.Body.setPosition(player, {
// x: player.position.x,
// y: -7000
// });
// game.noCameraScroll()
mech.energy = 0;
if (game.difficultyMode === 2) mech.damage(0.3);
if (game.difficultyMode === 1) mech.damage(0.1);

View File

@@ -72,7 +72,6 @@ const build = {
}
},
pauseGrid() {
// let text = `<div class="pause-grid-module" style="border:0px;background:none;"></div>`
let text = `
<div class="pause-grid-module">
<span style="font-size:1.5em;font-weight: 600;">PAUSED</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; press P to resume
@@ -84,13 +83,8 @@ const build = {
<br>
<br>health: ${(mech.health*100).toFixed(0)}% &nbsp; energy: ${(mech.energy*100).toFixed(0)}% &nbsp; mass: ${player.mass.toFixed(1)}
<br>position: (${player.position.x.toFixed(1)}, ${player.position.y.toFixed(1)}) &nbsp; velocity: (${player.velocity.x.toFixed(1)}, ${player.velocity.y.toFixed(1)})
</div>
`;
// <div class="pause-grid-module" style="display: flex; justify-content: space-between;padding-bottom:20px;">
// <span>${game.SVGleftMouse} fire gun</span>
// <span>${game.SVGrightMouse} use field</span>
// </div>
</div>`;
let countGuns = 0
let countMods = 0
for (let i = 0, len = b.guns.length; i < len; i++) {
@@ -212,10 +206,10 @@ const build = {
</g>
</svg>
<svg class="SVG-button" onclick="build.shareURL()" width="52" height="25">
<g stroke='none' fill='#333' stroke-width="2" font-size="17px" font-family="Ariel, sans-serif">
<text x="5" y="18">share</text>
</g>
</svg>
<g stroke='none' fill='#333' stroke-width="2" font-size="17px" font-family="Ariel, sans-serif">
<text x="5" y="18">share</text>
</g>
</svg>
</div>
<div style="align-items: center; text-align:center; font-size: 1.00em; line-height: 220%;background-color:#c4ccd8;">
<div>starting level: <input id='starting-level' type="number" step="1" value="0" min="0" max="99"></div>

View File

@@ -147,7 +147,7 @@ const level = {
spawn.mapRect(level.exit.x, level.exit.y + 20, 100, 100); //exit bump
// spawn.laserBoss(2900, -500)
spawn.springer(3200, -500)
spawn.beamer(1200, -500)
// spawn.timeSkipBoss(2900, -500)
// spawn.randomMob(3200, -500)
@@ -701,7 +701,7 @@ const level = {
//spawn.mapRect(-700, 0, 6250, 100); //ground
spawn.mapRect(3400, 0, 2150, 100); //ground
spawn.mapRect(-700, -2000, 2100, 50); //Top left ledge
spawn.mapRect(-700, -2000, 2110, 50); //Top left ledge
spawn.bodyRect(1300, -2125, 50, 125, 0.8);
spawn.bodyRect(1307, -2225, 50, 100, 0.8);
spawn.mapRect(-700, -2350, 50, 400); //far left starting left wall
@@ -715,6 +715,7 @@ const level = {
spawn.mapRect(1850, -2000, 650, 50);
spawn.bodyRect(200, -2150, 200, 220, 0.8);
spawn.mapRect(700, -2275, 600, 50);
spawn.mapRect(1000, -1350, 410, 50);
spawn.bodyRect(1050, -2350, 30, 30, 0.8);
// spawn.boost(1800, -1000, 1200);
spawn.bodyRect(1625, -1100, 100, 75);
@@ -938,7 +939,7 @@ const level = {
spawn.randomBoss(4000, -350, 0.6);
spawn.randomBoss(2750, -550, 0.1);
if (game.difficulty > 2) {
if (Math.random() < 0.3) { // tether ball
if (Math.random() < 0.1) { // tether ball
spawn.tetherBoss(4250, 0)
cons[cons.length] = Constraint.create({
pointA: {

View File

@@ -7,11 +7,6 @@ const mobs = {
while (i--) {
if (mob[i].alive) {
mob[i].do();
// let j = mob[i].status.length;
// while (j--) {
// mob[i].status[j].effect();
// if (mob[i].status[j].endCycle > game.cycle) mob[i].status.splice(j, 0);
// }
} else {
mob[i].replace(i); //removing mob and replace with body, this is done here to avoid an array index bug with drawing I think
}
@@ -49,6 +44,8 @@ const mobs = {
}
},
statusSlow(who, cycles = 60) {
console.log('slow')
if (!who.shield && !who.isShielded) {
//remove other "slow" effects on this mob
let i = who.status.length
@@ -788,7 +785,6 @@ const mobs = {
if (this.seePlayer.recall && this.cd < game.cycle) {
const dist = Vector.sub(this.seePlayer.position, this.position);
const distMag = Vector.magnitude(dist);
console.log(this.seePlayer.recall)
if (distMag < 400) {
this.cd = game.cycle + this.delay;
ctx.beginPath();

View File

@@ -564,7 +564,7 @@ const mech = {
// freeze game and display a full screen red color
if (dmg > 0.05) {
if (dmg > 0.07 && mech.holdingMassScale > 0.2) mech.drop(); //drop block if holding
if (dmg > 0.15 * mech.holdingMassScale) mech.drop(); //drop block if holding
game.fpsCap = 4 //40 - Math.min(25, 100 * dmg)
game.fpsInterval = 1000 / game.fpsCap;
} else {

View File

@@ -80,7 +80,7 @@ const spawn = {
},
randomLevelBoss(x, y) {
// suckerBoss, laserBoss, tetherBoss, snakeBoss all need a particular level to work so they are not included
const options = ["shooterBoss", "cellBossCulture", "bomberBoss"]
const options = ["shooterBoss", "cellBossCulture", "bomberBoss", "timeSkipBoss"]
spawn[options[Math.floor(Math.random() * options.length)]](x, y)
},
//mob templates *********************************************************************************************
@@ -638,34 +638,40 @@ const spawn = {
}
}
},
timeSkipBoss(x, y, radius = 80) {
timeSkipBoss(x, y, radius = 60) {
mobs.spawn(x, y, 6, radius, '#000');
let me = mob[mob.length - 1];
// me.stroke = "transparent"; //used for drawSneaker
me.timeSkipLastCycle = 0
me.eventHorizon = 1300; //required for black hole
me.seeAtDistance2 = (me.eventHorizon + 1000) * (me.eventHorizon + 1000); //vision limit is event horizon
me.accelMag = 0.00013 * game.accelScale;
me.eventHorizon = 1500; //required for black hole
me.seeAtDistance2 = (me.eventHorizon + 2000) * (me.eventHorizon + 2000); //vision limit is event horizon + 2000
me.accelMag = 0.00022 * game.accelScale;
// me.frictionAir = 0.005;
// me.memory = 1600;
Matter.Body.setDensity(me, 0.018); //extra dense //normal is 0.001 //makes effective life much larger
Matter.Body.setDensity(me, 0.02); //extra dense //normal is 0.001 //makes effective life much larger
me.onDeath = function () {
//applying forces to player doesn't seem to work inside this method, not sure why
powerUps.spawnBossPowerUp(this.position.x, this.position.y)
};
me.do = function () {
//keep it slow, to stop issues from explosion knock backs
if (this.speed > 2) {
Matter.Body.setVelocity(this, {
x: this.velocity.x * 0.99,
y: this.velocity.y * 0.99
});
}
this.seePlayerCheck();
this.checkStatus();
this.attraction()
if (!game.isTimeSkipping) {
const compress = 3
const compress = 2
if (this.timeSkipLastCycle < game.cycle - compress &&
Vector.magnitude(Vector.sub(this.position, player.position)) < this.eventHorizon) {
this.timeSkipLastCycle = game.cycle
game.timeSkip(compress)
this.fill = `rgba(0,0,0,${0.1+0.1*Math.random()})`
this.fill = `rgba(0,0,0,${0.1+0.4*Math.random()})`
this.stroke = "#000"
this.isShielded = false;
this.dropPowerUp = true;
@@ -673,7 +679,7 @@ const spawn = {
ctx.beginPath();
ctx.arc(this.position.x, this.position.y, this.eventHorizon, 0, 2 * Math.PI);
ctx.fillStyle = `rgba(255,255,255,${mech.energy*0.5})`;
ctx.fillStyle = "#fff";
ctx.globalCompositeOperation = "destination-in"; //in or atop
ctx.fill();
ctx.globalCompositeOperation = "source-over";
@@ -703,7 +709,7 @@ const spawn = {
this.collisionFilter.mask = cat.player | cat.map | cat.body | cat.mob; //can't touch bullets
ctx.beginPath();
ctx.arc(this.position.x, this.position.y, this.eventHorizon, 0, 2 * Math.PI);
ctx.fillStyle = `rgba(0,0,0,${0.1*Math.random()})`;
ctx.fillStyle = `rgba(0,0,0,${0.05*Math.random()})`;
ctx.fill();
}
}