added quantum immortaility

This commit is contained in:
landgreen
2019-10-27 16:40:00 -07:00
parent e3e92c8d69
commit 2577d8a3e4
9 changed files with 490 additions and 385 deletions

View File

@@ -33,9 +33,7 @@
<!-- <body oncontextmenu="return false"> -->
<div id='guns'></div>
<div id='mods'>
Auto-Loading Heuristics
</div>
<div id='mods'></div>
<div id="text-log"></div>
<div id="fade-out"></div>
<div id="health-bg"></div>

View File

@@ -12,7 +12,7 @@ const b = {
modHealthDrain: null,
modNoAmmo: null,
modBulletsLastLonger: null,
// modNonEuclidean: null,
modIsImmortal: null,
setModDefaults() {
b.modFireRate = 1;
b.modExplosionRadius = 1;
@@ -21,15 +21,15 @@ const b = {
b.modHealthDrain = 0;
b.modNoAmmo = 0;
b.modBulletsLastLonger = 1;
// b.modNonEuclidean = false;
b.modIsImmortal = false;
},
modText: function () {
game.makeTextLog(`<strong style='font-size:30px;'>${b.mods[b.mod].name}</strong><br> <span class='faded'>(left click)</span><p>${b.mods[b.mod].description}</p>`, 1200);
document.getElementById("mods").innerHTML = b.mods[b.mod].name
modText() {
if (b.mod !== null) game.makeTextLog(`<strong style='font-size:30px;'>${b.mods[b.mod].name}</strong><br> <p>${b.mods[b.mod].description}</p>`, 1200);
game.updateModHUD()
},
mods: [{
name: "Auto-Loading Heuristics",
description: "your <strong>rate of fire</strong> 15% is faster",
description: "your <strong>rate of fire</strong> is 15% faster",
effect: () => {
b.mod = 0
b.modText();
@@ -40,7 +40,7 @@ const b = {
},
{
name: "Anti-Matter Cores",
description: "your <strong>explosions</strong> are larger and do more damage",
description: "your <strong>explosions</strong> are larger and more dangerous",
effect: () => {
b.mod = 1
b.modText();
@@ -68,7 +68,7 @@ const b = {
effect: () => {
b.mod = 3
b.modText();
b.setModDefaults(); //good with laser, Nano-Scale Manufacturing, Standing Wave Harmonics, Phase Decoherence Field
b.setModDefaults(); //good with laser, and all fields
b.modEnergySiphon = 0.2;
}
},
@@ -93,26 +93,26 @@ const b = {
}
},
{
name: "Anti-Decay Coating",
description: "your bullets <strong>last 25% longer</strong>",
name: "Decay Resistant Topology",
description: "your bullets <strong>last 30% longer</strong>",
effect: () => {
b.mod = 6
b.modText();
b.setModDefaults(); //good with: drones, super balls, spore, missiles, wave beam(range), rapid fire(range), flak(range)
b.modBulletsLastLonger = 1.25
b.modBulletsLastLonger = 1.30
}
},
// {
// name: "Non-Euclidean Geometry",
// description: "after you fall loop back to the top of the map",
// have: false,
// effect: () => {
// b.mod = 7
// b.modText();
// b.setModDefaults(); //good with: drones, super balls, spore, missiles, wave beam(range), rapid fire(range), flak(range)
// b.modNonEuclidean = true
// }
// },
{
name: "Quantum Immortality",
description: "after you die continue in an alternate reality with randomized abilities<br>",
effect: () => {
b.mod = 7
b.modText();
b.setModDefaults(); //good with: drones, super balls, spore, missiles, wave beam(range), rapid fire(range), flak(range)
b.modIsImmortal = true;
}
},
// () => {
// b.mod = 8;
// game.makeTextLog("<strong style='font-size:30px;'>Relativistic Velocity</strong><br> <span class='faded'>(left click)</span><p>Your bullets are effected extra by your own velocity</p>", 1200);

View File

@@ -153,6 +153,16 @@ const game = {
}
game.boldActiveGunHUD();
},
updateModHUD() {
let text = ""
if (mech.fieldMode !== 0) {
text += mech.fieldUpgrades[mech.fieldMode].name
if (b.mod !== null) text += "<br>" + b.mods[b.mod].name
} else if (b.mod !== null) {
text += b.mods[b.mod].name
}
document.getElementById("mods").innerHTML = text
},
makeTextLog(text, time = 180) {
document.getElementById("text-log").innerHTML = text;
document.getElementById("text-log").style.opacity = 1;
@@ -250,10 +260,14 @@ const game = {
requestAnimationFrame(cycle);
} else {
game.paused = true;
let text = "<h1>PAUSED</h1>"
// if (b.mod !== null) text+=
//output current mod, field, and gun info when paused
game.makeTextLog(text);
game.makeTextLog("<h1>PAUSED</h1>", 1);
// let text = "<h1>PAUSED</h1><br><div style='font-size: 85%;'>"
// //output current mod, field, and gun info when paused
// if (mech.fieldMode !== 0) text += "<br><p><strong style='font-size:130%;'>" + mech.fieldUpgrades[mech.fieldMode].name + "</strong><br>" + mech.fieldUpgrades[mech.fieldMode].description + "</p>"
// if (b.mod !== null) text += "<br><p><strong style='font-size:130%;'>" + b.mods[b.mod].name + "</strong><br>" + b.mods[b.mod].description + "</p>"
// if (b.activeGun !== null) text += "<br><p><strong style='font-size:130%;'>" + b.guns[b.activeGun].name + "</strong><br>" + b.guns[b.activeGun].description + "</p>"
// text += "</div>"
// game.makeTextLog(text, 1);
}
}
@@ -270,9 +284,9 @@ const game = {
if (keys[70]) { //cycle fields with F
if (mech.fieldMode === mech.fieldUpgrades.length - 1) {
mech.fieldUpgrades[0]()
mech.fieldUpgrades[0].effect()
} else {
mech.fieldUpgrades[mech.fieldMode + 1]()
mech.fieldUpgrades[mech.fieldMode + 1].effect()
}
}
if (keys[71]) { // give all guns with G
@@ -361,8 +375,11 @@ const game = {
},
wipe() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// ctx.fillStyle = "#000";
// ctx.fillStyle = "rgba(255,255,255,1)";
// ctx.globalCompositeOperation = "difference";
// ctx.fillRect(0, 0, canvas.width, canvas.height);
// ctx.globalCompositeOperation = "source-over";
// ctx.globalAlpha = (mech.health < 0.7) ? (mech.health+0.3)*(mech.health+0.3) : 1
// if (mech.health < 0.7) {
@@ -393,11 +410,11 @@ const game = {
b.guns[i].have = false;
if (b.guns[i].ammo != Infinity) b.guns[i].ammo = 0;
}
b.activeGun = null;
game.paused = false;
engine.timing.timeScale = 1;
game.dmgScale = 1;
b.dmgScale = 0.7;
b.activeGun = null;
game.makeGunHUD();
mech.drop();
mech.addHealth(1);
@@ -408,8 +425,7 @@ const game = {
document.getElementById("text-log").style.opacity = 0;
document.getElementById("fade-out").style.opacity = 0;
document.title = "n-gon";
// mech.fieldUpgrades[0](); //reset to starting field? or let them keep the field
if (!mech.fieldMode) mech.fieldUpgrades[0](); //reset to starting field? or let them keep the field
if (!mech.fieldMode) mech.fieldUpgrades[0].effect(); //reset to starting field? or let them keep the field
},
firstRun: true,
splashReturn() {

View File

@@ -2,6 +2,9 @@
/* TODO: *******************************************
*****************************************************
make player legs just slide if the player is above the normal speed
like when you fire the one shot
make power ups keep moving to player if the field is turned off
levels spawn by having the map aspects randomly fly into place

View File

@@ -12,11 +12,11 @@ const level = {
onLevel: 0,
start() {
if (game.levelsCleared === 0) {
// game.levelsCleared = 5; //for testing to simulate possible mobs spawns
// game.levelsCleared = 6; //for testing to simulate possible mobs spawns
// b.giveGuns("all", 1000)
// b.giveGuns(3) // set a starting gun for testing
// mech.fieldUpgrades[2](); //give a field power up for testing
// b.mods[6].effect(); //give specific mod
// mech.fieldUpgrades[2].effect(); //give a field power up for testing
// b.mods[7].effect(); //give specific mod
this.intro(); //starting level
// this.testingMap();
@@ -28,11 +28,11 @@ const level = {
// this.office();
} 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
this.levelAnnounce();
level[level.levels[level.onLevel]](); //picks the current map from the the levels array
level.levelAnnounce();
}
game.setZoom();
this.addToWorld(); //add bodies to game engine
level.addToWorld(); //add bodies to game engine
game.draw.setPaths();
},
difficultyIncrease() {

View File

@@ -358,7 +358,61 @@ const mech = {
},
alive: true,
death() {
if (this.alive) {
if (b.modIsImmortal) { //if player has the immortality buff, spawn on the same level with randomized stats
//remove mod
b.mod = null
b.setModDefaults();
b.modText();
//randomize guns
b.activeGun = null;
b.inventory = []; //removes guns and ammo
for (let i = 0, len = b.guns.length; i < len; ++i) {
b.guns[i].have = false;
if (b.guns[i].ammo != Infinity) b.guns[i].ammo = 0;
}
if (game.levelsCleared > 0) powerUps.gun.effect();
if (game.levelsCleared > 1) powerUps.gun.effect();
if (game.levelsCleared > 3) powerUps.gun.effect();
if (game.levelsCleared > 6) powerUps.gun.effect();
game.makeGunHUD();
//randomize field
if (game.levelsCleared > 5) {
mech.fieldUpgrades[Math.floor(Math.random() * (mech.fieldUpgrades.length))].effect();
} else {
mech.fieldUpgrades[0].effect();
}
mech.addHealth(1);
spawn.setSpawnList();
game.clearNow = true;
game.wipe = function () { //set wipe to have trails
ctx.fillStyle = "rgba(255,255,255,0.01)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
for (let i = 0; i < 7; i++) {
setTimeout(function () {
game.makeTextLog(`<div style='opacity:0.3;'> probability amplitude will synchronize in ${7-i} seconds</div>`, 1000);
game.wipe = function () { //set wipe to have trails
ctx.fillStyle = `rgba(255,255,255,${(i+1)*0.04})`;
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
}, (i + 1) * 1000);
}
setTimeout(function () {
game.wipe = function () { //set wipe to normal
ctx.clearRect(0, 0, canvas.width, canvas.height);
}
game.makeTextLog("<div style='opacity:0.5;'><strong>Quantum Immortality</strong> has stabilized your probability amplitude<br>welcome to your new reality</div>", 1000);
document.title = "n-gon: L" + (game.levelsCleared) + " " + level.levels[level.onLevel] + " version 2";
}, 8000);
} else if (this.alive) { //normal death code here
this.alive = false;
game.paused = true;
this.health = 0;
@@ -844,10 +898,17 @@ const mech = {
}
},
hold() {},
fieldUpgrades: [
() => {
fieldText() {
game.makeTextLog(`<strong style='font-size:30px;'>${mech.fieldUpgrades[mech.fieldMode].name}</strong><br> <span class='faded'>(right click or space bar)</span><p>${mech.fieldUpgrades[mech.fieldMode].description}</p>`, 1200);
game.updateModHUD()
},
fieldUpgrades: [{
name: "Field Emitter",
description: "lets you <strong>pick up</strong> and throw objects<br><strong>shields</strong> you from damage",
effect: () => {
mech.fieldMode = 0;
game.makeTextLog("<strong style='font-size:30px;'>Field Emitter</strong><br> <span class='faded'>(right click or space bar)</span><p>lets you <strong>pick up</strong> and throw objects<br><strong>shields</strong> you from damage</p>", 1200);
mech.fieldText();
// game.makeTextLog("<strong style='font-size:30px;'></strong><br> <span class='faded'>(right click or space bar)</span><p></p>", 1200);
mech.setHoldDefaults();
mech.hold = function () {
if (mech.isHolding) {
@@ -866,10 +927,14 @@ const mech = {
}
mech.drawFieldMeter()
}
}
},
() => {
{
name: "Time Dilation Field",
description: "<strong>stop time</strong> while field is active<br> can fire while field is active",
effect: () => {
mech.fieldMode = 1;
game.makeTextLog("<strong style='font-size:30px;'>Time Dilation Field</strong><br> <span class='faded'>(right click or space bar)</span><p> <strong>stop time</strong> while field is active<br> can fire while field is active</p>", 1200);
mech.fieldText();
mech.setHoldDefaults();
mech.fieldFire = true;
mech.grabRange = 130
@@ -881,7 +946,7 @@ const mech = {
mech.holding();
mech.throw();
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) {
const DRAIN = 0.0022
const DRAIN = 0.0027
if (mech.fieldMeter > DRAIN) {
mech.fieldMeter -= DRAIN;
@@ -933,10 +998,14 @@ const mech = {
}
}
}
},
() => {
{
name: "Electrostatic Force Field",
description: "field does <strong>damage</strong> on contact<br> blocks are thrown at a higher velocity<br> increased field regeneration",
effect: () => {
mech.fieldMode = 2;
game.makeTextLog("<strong style='font-size:30px;'>Electrostatic Force Field</strong><br> <span class='faded'>(right click or space bar)</span><p> field does <strong>damage</strong> on contact<br> blocks are thrown at a higher velocity<br> increased field regeneration</p>", 1200);
mech.fieldText();
mech.setHoldDefaults();
//throw quicker and harder
mech.grabRange = 225;
@@ -1002,10 +1071,14 @@ const mech = {
}
mech.drawFieldMeter()
}
}
},
() => {
{
name: "Negative Mass Field",
description: "field nullifies <strong>gravity</strong><br> player can hold more massive objects<br>can fire while field is active",
effect: () => {
mech.fieldMode = 3;
game.makeTextLog("<strong style='font-size:30px;'>Negative Mass Field</strong><br> <span class='faded'>(right click or space bar)</span><p> field nullifies <strong>gravity</strong><br> player can hold more massive objects<br>can fire while field is active</p>", 1200);
mech.fieldText();
//<br> <span style='color:#a00;'>decreased</span> field shielding efficiency
mech.setHoldDefaults();
mech.fieldFire = true;
@@ -1018,7 +1091,7 @@ const mech = {
mech.holding();
mech.throw();
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) { //push away
const DRAIN = 0.0007
const DRAIN = 0.0006
if (mech.fieldMeter > DRAIN) {
mech.pushMobs360(170);
mech.grabPowerUp();
@@ -1084,10 +1157,14 @@ const mech = {
}
mech.drawFieldMeter()
}
}
},
() => {
{
name: "Standing Wave Harmonics",
description: "oscillating shields always surround player<br> <span style='color:#a00;'>decreased</span> field regeneration",
effect: () => {
mech.fieldMode = 4;
game.makeTextLog("<strong style='font-size:30px;'>Standing Wave Harmonics</strong><br> <span class='faded'>(right click or space bar)</span> <p>oscillating shields always surround player<br> <span style='color:#a00;'>decreased</span> field regeneration</p>", 1200);
mech.fieldText();
mech.setHoldDefaults();
// mech.fieldShieldingScale = 0.5;
mech.fieldRegen *= 0.2;
@@ -1106,9 +1183,9 @@ const mech = {
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)
}
if (mech.fieldMeter > 0.1) {
const grabRange1 = 85 + 60 * Math.sin(mech.cycle / 23)
const grabRange2 = 80 + 70 * Math.sin(mech.cycle / 37)
const grabRange3 = 70 + 70 * Math.sin(mech.cycle / 47)
const grabRange1 = 90 + 60 * Math.sin(mech.cycle / 23)
const grabRange2 = 85 + 70 * Math.sin(mech.cycle / 37)
const grabRange3 = 80 + 80 * Math.sin(mech.cycle / 47)
const netGrabRange = Math.max(grabRange1, grabRange2, grabRange3)
ctx.fillStyle = "rgba(110,170,200," + (0.15 + 0.15 * Math.random()) + ")";
ctx.beginPath();
@@ -1124,12 +1201,16 @@ const mech = {
}
mech.drawFieldMeter()
}
}
},
() => {
{
name: "Nano-Scale Manufacturing",
description: "excess field energy used to build <strong>drones</strong><br> increased field regeneration",
effect: () => {
mech.fieldMode = 5;
game.makeTextLog("<strong style='font-size:30px;'>Nano-Scale Manufacturing</strong><br> <span class='faded'>(passive effect)</span> <p>excess field energy used to build <strong>drones</strong><br> increased field regeneration</p>", 1200);
mech.fieldText();
mech.setHoldDefaults();
mech.fieldRegen *= 3;
mech.fieldRegen *= 3.5;
mech.hold = function () {
if (mech.fieldMeter === 1) {
mech.fieldMeter -= 0.5;
@@ -1151,10 +1232,14 @@ const mech = {
}
mech.drawFieldMeter()
}
}
},
() => {
{
name: "Phase Decoherence Field",
description: "<strong>intangible</strong> while field is active<br>can't see or be seen outside field",
effect: () => {
mech.fieldMode = 6;
game.makeTextLog("<strong style='font-size:30px;'>Phase Decoherence Field</strong><br> <span class='faded'>(right click or space bar)</span> <p><strong>intangible</strong> while field is active<br>can't see or be seen outside field</p>", 1200);
mech.fieldText();
mech.setHoldDefaults();
// mech.grabRange = 230
mech.hold = function () {
@@ -1194,6 +1279,7 @@ const mech = {
}
mech.drawFieldMeter()
}
}
},
// () => {
// mech.fieldMode = 7;

View File

@@ -28,9 +28,9 @@ const powerUps = {
while (mode === mech.fieldMode) {
mode = Math.ceil(Math.random() * (mech.fieldUpgrades.length - 1))
}
mech.fieldUpgrades[mode](); //choose random field upgrade that you don't already have
mech.fieldUpgrades[mode].effect(); //choose random field upgrade that you don't already have
} else {
mech.fieldUpgrades[this.mode](); //set a predetermined power up
mech.fieldUpgrades[this.mode].effect(); //set a predetermined power up
}
//pop the old field out in case player wants to swap back
if (previousMode !== 0) {

View File

@@ -491,12 +491,12 @@ const spawn = {
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)
if (game.levelsCleared > 6) {
for (let i = 0; i < (game.levelsCleared - 5); ++i) {
spawn.sucker(this.position.x + (Math.random() - 0.5) * radius * 2, this.position.y + (Math.random() - 0.5) * radius * 2, 20);
if (game.levelsCleared > 5) {
for (let i = 0; i < (game.levelsCleared - 3); ++i) {
spawn.sucker(this.position.x + (Math.random() - 0.5) * radius * 2, this.position.y + (Math.random() - 0.5) * radius * 2, 70 * Math.random());
Matter.Body.setVelocity(mob[mob.length - 1], {
x: (Math.random() - 0.5) * 25,
y: (Math.random() - 0.5) * 25
x: (Math.random() - 0.5) * 70,
y: (Math.random() - 0.5) * 70
});
}
}
@@ -540,7 +540,7 @@ const spawn = {
ctx.fill();
ctx.beginPath();
ctx.arc(this.position.x, this.position.y, eventHorizon, 0, 2 * Math.PI);
ctx.fillStyle = "rgba(0,20,40,0.05)";
ctx.fillStyle = "rgba(0,0,0,0.05)";
ctx.fill();
//when player is inside event horizon
if (Matter.Vector.magnitude(Matter.Vector.sub(this.position, player.position)) < eventHorizon) {

View File

@@ -68,8 +68,8 @@ summary {
#health-bg {
position: absolute;
top: 30px;
left: 40px;
top: 15px;
left: 15px;
height: 20px;
width: 300px;
background-color: #000;
@@ -81,8 +81,8 @@ summary {
#health {
position: absolute;
top: 30px;
left: 40px;
top: 15px;
left: 15px;
height: 20px;
width: 0px;
transition: width 1s ease-out;
@@ -119,10 +119,10 @@ summary {
#guns {
position: absolute;
top: 55px;
left: 40px;
top: 40px;
left: 15px;
z-index: 2;
font-size: 25px;
font-size: 23px;
color: #111;
background-color: rgba(255, 255, 255, 0.4);
user-select: none;
@@ -134,12 +134,14 @@ summary {
#mods {
position: absolute;
top: 20px;
right: 20px;
top: 15px;
right: 15px;
z-index: 2;
font-size: 21px;
color: #111;
font-size: 19px;
color: #000;
text-align: right;
opacity: 0.5;
line-height: 140%;
background-color: rgba(255, 255, 255, 0.4);
user-select: none;
pointer-events: none;