working on a new map

This commit is contained in:
lilgreenland
2019-10-07 15:26:20 -07:00
parent 868a8a3e89
commit c31a5ef5c9
3 changed files with 106 additions and 77 deletions

View File

@@ -13,10 +13,10 @@ const level = {
// game.zoomScale = 1400 //1400 // game.zoomScale = 1400 //1400
if (game.levelsCleared === 0) { if (game.levelsCleared === 0) {
document.title = "n-gon"; document.title = "n-gon";
this.intro(); //starting level // this.intro(); //starting level
// this.testingMap(); // this.testingMap();
// this.bosses(); // this.bosses();
// this.skyscrapers(); this.excavation();
// this.rooftops(); // this.rooftops();
// this.warehouse(); // this.warehouse();
// this.highrise(); // this.highrise();
@@ -374,7 +374,6 @@ const level = {
// spawn.healer(1000, -500) // spawn.healer(1000, -500)
// spawn.healer(1000, -400) // spawn.healer(1000, -400)
}, },
rooftops() { rooftops() {
game.zoomTransition(1700) //1400 is normal game.zoomTransition(1700) //1400 is normal
@@ -568,6 +567,47 @@ const level = {
//spawn.randomBoss(4850, -1250,0.7); //spawn.randomBoss(4850, -1250,0.7);
if (game.levelsCleared > 4) spawn.bomber(2500, -2400, 100); if (game.levelsCleared > 4) spawn.bomber(2500, -2400, 100);
}, },
excavation() {
game.zoomTransition(2200) //1400 is normal
mech.setPosToSpawn(-50, -50); //normal spawn
level.enter.x = mech.spawnPos.x - 50;
level.enter.y = mech.spawnPos.y + 20;
level.exit.x = 1500;
level.exit.y = -1875;
this.addZone(level.exit.x, level.exit.y, 100, 30, "nextLevel");
// powerUps.spawnStartingPowerUps(1475, -1175);
// spawn.debris(0, -2200, 4500, 20); //20 debris per level
document.body.style.backgroundColor = "#dcdcde";
// //foreground
// level.fill.push({
// x: 2500,
// y: -1100,
// width: 450,
// height: 250,
// color: "rgba(0,0,0,0.1)"
// });
// //background
// level.fillBG.push({
// x: 1300,
// y: -1800,
// width: 750,
// height: 1800,
// color: "#d4d4d7"
// });
// starting room
spawn.mapRect(-200, 0, 500, 1500);
spawn.mapRect(-200, -300, 500, 50);
spawn.mapRect(-200, -300, 50, 350);
spawn.bodyRect(100, -250, 200, 240);
//top of building
spawn.mapRect(600, 0, 800, 100);
spawn.mapRect(200, 1100, 800, 400);
spawn.mapRect(1250, 1100, 800, 400);
},
skyscrapers() { skyscrapers() {
game.zoomTransition(2000) //1400 is normal game.zoomTransition(2000) //1400 is normal

View File

@@ -597,8 +597,8 @@ const mobs = {
pullPlayer() { pullPlayer() {
if (this.seePlayer.yes && Matter.Vector.magnitudeSquared(Matter.Vector.sub(this.position, player.position)) < 1000000) { if (this.seePlayer.yes && Matter.Vector.magnitudeSquared(Matter.Vector.sub(this.position, player.position)) < 1000000) {
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) * (mech.onGround ? 2 * player.mass * game.g : player.mass * game.g); player.force.x -= game.accelScale * 1.13 * Math.cos(angle) * (mech.onGround ? 2 * player.mass * game.g : player.mass * game.g);
player.force.y -= 0.97 * player.mass * game.g * Math.sin(angle); player.force.y -= game.accelScale * 0.84 * player.mass * game.g * Math.sin(angle);
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(this.position.x, this.position.y); ctx.moveTo(this.position.x, this.position.y);

View File

@@ -1158,81 +1158,70 @@ const mech = {
mech.drawFieldMeter() mech.drawFieldMeter()
} }
}, },
() => { // () => {
mech.fieldMode = 7; // mech.fieldMode = 7;
game.makeTextLog("<strong style='font-size:30px;'>Thermal Radiation Field</strong><br> (right mouse or space bar) <p>field grows while active<br>damages all targets within range, <span style='color:#a00;'>including player</span><br> <span style='color:#a00;'>decreased</span> field shielding efficiency</p>", 1200); // game.makeTextLog("<strong style='font-size:30px;'>Thermal Radiation Field</strong><br> (right mouse or space bar) <p>field grows while active<br>damages all targets within range, <span style='color:#a00;'>including player</span><br> <span style='color:#a00;'>decreased</span> field shielding efficiency</p>", 1200);
mech.setHoldDefaults(); // mech.setHoldDefaults();
mech.fieldShieldingScale = 10; // mech.fieldShieldingScale = 10;
mech.rangeSmoothing = 0 // mech.rangeSmoothing = 0
mech.hold = function () { // mech.hold = function () {
if (mech.isHolding) { // if (mech.isHolding) {
mech.drawHold(mech.holdingTarget); // mech.drawHold(mech.holdingTarget);
mech.holding(); // mech.holding();
mech.throw(); // mech.throw();
} else if ((keys[32] || game.mouseDownRight && mech.fieldCDcycle < game.cycle)) { //not hold but field button is pressed // } else if ((keys[32] || game.mouseDownRight && mech.fieldCDcycle < game.cycle)) { //not hold but field button is pressed
mech.grabPowerUp(); // mech.grabPowerUp();
mech.lookForPickUp(Math.max(180, mech.grabRange)); // mech.lookForPickUp(Math.max(180, mech.grabRange));
mech.pushMobs360(140); // mech.pushMobs360(140);
// //draw grab field
// ctx.beginPath();
// ctx.arc(this.pos.x, this.pos.y, this.grabRange - 20, this.angle - Math.PI * this.fieldArc, this.angle + Math.PI * this.fieldArc, false);
// let EYE_RADIUS = 13;
// ctx.lineTo(mech.pos.x + EYE_RADIUS * Math.cos(this.angle), mech.pos.y + EYE_RADIUS * Math.sin(this.angle));
// if (this.holdingTarget) {
// ctx.fillStyle = "rgba(150,150,150," + (0.05 + 0.1 * Math.random()) + ")";
// } else {
// ctx.fillStyle = "rgba(150,150,150," + (0.15 + 0.15 * Math.random()) + ")";
// }
// ctx.fill();
if (mech.health > 0.1) { // if (mech.health > 0.1) {
const DRAIN = 0.0008 //mech.fieldRegen = 0.0015 // const DRAIN = 0.0008 //mech.fieldRegen = 0.0015
if (mech.fieldMeter > DRAIN) { // if (mech.fieldMeter > DRAIN) {
mech.fieldMeter -= DRAIN; // mech.fieldMeter -= DRAIN;
mech.damage(0.00005 + 0.00000012 * mech.grabRange) // mech.damage(0.00005 + 0.00000012 * mech.grabRange)
//draw damage field // //draw damage field
mech.grabRange = mech.grabRange * 0.997 + (1350 + 150 * Math.cos(game.cycle / 30)) * 0.003 // mech.grabRange = mech.grabRange * 0.997 + (1350 + 150 * Math.cos(game.cycle / 30)) * 0.003
let gradient = ctx.createRadialGradient(this.pos.x, this.pos.y, 0, this.pos.x, this.pos.y, mech.grabRange); // let gradient = ctx.createRadialGradient(this.pos.x, this.pos.y, 0, this.pos.x, this.pos.y, mech.grabRange);
gradient.addColorStop(0, 'rgba(255,255,255,0.7)'); // gradient.addColorStop(0, 'rgba(255,255,255,0.7)');
gradient.addColorStop(1, 'rgba(255,0,50,' + (0.6 + 0.2 * Math.random()) + ')'); // gradient.addColorStop(1, 'rgba(255,0,50,' + (0.6 + 0.2 * Math.random()) + ')');
const angleOff = 2 * Math.PI * Math.random() // const angleOff = 2 * Math.PI * Math.random()
ctx.beginPath(); // ctx.beginPath();
ctx.arc(this.pos.x, this.pos.y, mech.grabRange + Math.sqrt(mech.grabRange) * 0.7 * (Math.random() - 0.5), angleOff, 1.8 * Math.PI + angleOff); // ctx.arc(this.pos.x, this.pos.y, mech.grabRange + Math.sqrt(mech.grabRange) * 0.7 * (Math.random() - 0.5), angleOff, 1.8 * Math.PI + angleOff);
ctx.fillStyle = gradient //rgba(255,0,0,0.2) // ctx.fillStyle = gradient //rgba(255,0,0,0.2)
ctx.fill(); // ctx.fill();
//damage and push away mobs in range // //damage and push away mobs in range
for (let i = 0, len = mob.length; i < len; ++i) { // for (let i = 0, len = mob.length; i < len; ++i) {
if (mob[i].alive) { // if (mob[i].alive) {
sub = Matter.Vector.sub(this.pos, mob[i].position); // sub = Matter.Vector.sub(this.pos, mob[i].position);
dist = Matter.Vector.magnitude(sub); // dist = Matter.Vector.magnitude(sub);
if (dist < mech.grabRange) { // if (dist < mech.grabRange) {
mob[i].damage(0.01); // mob[i].damage(0.01);
mob[i].locatePlayer(); // mob[i].locatePlayer();
mob[i].force = Matter.Vector.mult(Matter.Vector.normalise(sub), -0.0001 * mob[i].mass) //gently push mobs back // mob[i].force = Matter.Vector.mult(Matter.Vector.normalise(sub), -0.0001 * mob[i].mass) //gently push mobs back
} // }
} // }
} // }
} else { // } else {
mech.fieldCDcycle = game.cycle + 120; // mech.fieldCDcycle = game.cycle + 120;
} // }
} else { // } else {
mech.grabRange = 180; // mech.grabRange = 180;
mech.drawField(); // mech.drawField();
mech.grabPowerUp(); // mech.grabPowerUp();
mech.lookForPickUp(); // mech.lookForPickUp();
} // }
} else if (mech.holdingTarget && mech.fireCDcycle < game.cycle && mech.fieldMeter > 0.05) { //holding, but field button is released // } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle && mech.fieldMeter > 0.05) { //holding, but field button is released
mech.grabRange = 0 // mech.grabRange = 0
mech.pickUp(); // mech.pickUp();
} else { // } else {
mech.grabRange = 0 // mech.grabRange = 0
mech.holdingTarget = null; //clears holding target (this is so you only pick up right after the field button is released and a hold target exists) // mech.holdingTarget = null; //clears holding target (this is so you only pick up right after the field button is released and a hold target exists)
} // }
mech.drawFieldMeter() // mech.drawFieldMeter()
} // }
}, // },
], ],
drawLeg(stroke) { drawLeg(stroke) {
// if (game.mouseInGame.x > this.pos.x) { // if (game.mouseInGame.x > this.pos.x) {