settings
diff --git a/js/bullets.js b/js/bullets.js
index eb40817..0ce979b 100644
--- a/js/bullets.js
+++ b/js/bullets.js
@@ -250,11 +250,24 @@ const b = {
}
},
],
- giveMod(i) {
- b.mods[i].effect(); //give specific mod
- b.modCount++
- b.mods[i].have = true
- game.updateModHUD();
+ giveMod(index = 'random') {
+ if (index === 'random') {
+ let options = [];
+ for (let i = 0; i < b.mods.length; i++) {
+ if (!b.mods[i].have) options.push(i);
+ }
+
+ // give a random mod from the mods I don't have
+ if (options.length > 0) {
+ let newMod = options[Math.floor(Math.random() * options.length)]
+ b.giveMod(newMod)
+ }
+ } else {
+ b.mods[index].effect(); //give specific mod
+ b.modCount++
+ b.mods[index].have = true
+ game.updateModHUD();
+ }
},
activeGun: null, //current gun in use by player
inventoryGun: 0,
@@ -812,7 +825,7 @@ const b = {
have: false,
isStarterGun: true,
fire() {
- mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 25 : 18) * b.modFireRate); // cool down
+ mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 35 : 20) * b.modFireRate); // cool down
b.muzzleFlash(20);
// mobs.alert(450);
const SPEED = mech.crouch ? 55 : 35
@@ -1665,7 +1678,7 @@ const b = {
},
{
name: "laser", //14
- description: "emit a beam of collimated coherent light
uses energy instead of ammunition",
+ description: "emit a beam of collimated coherent light
drains energy instead of ammunition",
ammo: 0,
ammoPack: Infinity,
have: false,
@@ -1784,7 +1797,7 @@ const b = {
x: best.x,
y: best.y
};
- laserHitMob(0.75);
+ laserHitMob(0.8);
//2nd reflection beam
//ugly bug fix: this stops the reflection on a bug where the beam gets trapped inside a body
@@ -1797,7 +1810,19 @@ const b = {
x: best.x,
y: best.y
};
- laserHitMob(0.5);
+ laserHitMob(0.63);
+
+
+ reflection();
+ checkForCollisions();
+ if (best.dist2 != Infinity) {
+ //if hitting something
+ path[path.length - 1] = {
+ x: best.x,
+ y: best.y
+ };
+ laserHitMob(0.5);
+ }
}
}
}
@@ -1814,7 +1839,7 @@ const b = {
ctx.moveTo(path[i - 1].x, path[i - 1].y);
ctx.lineTo(path[i].x, path[i].y);
ctx.stroke();
- ctx.globalAlpha *= 0.5; //reflections are less intense
+ ctx.globalAlpha *= 0.65; //reflections are less intense
// ctx.globalAlpha -= 0.1; //reflections are less intense
}
ctx.setLineDash([0, 0]);
diff --git a/js/game.js b/js/game.js
index 5c2e49b..0b21d76 100644
--- a/js/game.js
+++ b/js/game.js
@@ -83,6 +83,7 @@ const game = {
buttonCD: 0,
isBodyDamage: true,
isEasyMode: false,
+ isDraftMode: false,
difficulty: null,
// dropFPS(cap = 40, time = 15) {
// game.fpsCap = cap
@@ -308,7 +309,6 @@ const game = {
} else if (keys[53]) { // 5
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "mod");
} else if (keys[54]) { // 6 spawn mob
-
const pick = spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)];
spawn.allowShields = false;
spawn[pick](game.mouseInGame.x, game.mouseInGame.y);
@@ -321,19 +321,16 @@ const game = {
body[index].classType = "body";
World.add(engine.world, body[index]); //add to world
} else if (keys[70]) { //cycle fields with F
- if (mech.fieldMode === mech.fieldUpgrades.length - 1) {
- mech.fieldUpgrades[0].effect()
- } else {
- mech.fieldUpgrades[mech.fieldMode + 1].effect()
- }
+ const mode = (mech.fieldMode === mech.fieldUpgrades.length - 1) ? 0 : mech.fieldMode + 1
+ mech.setField(mode)
} else if (keys[71]) { // give all guns with G
// b.giveGuns("all", 1000)
powerUps.gun.effect()
} else if (keys[72]) { // heal with H
mech.addHealth(Infinity)
mech.fieldMeter = mech.fieldEnergyMax;
- } else if (keys[89]) { //add all mods with y
- powerUps.mod.effect()
+ } else if (keys[89]) { //add mods with y
+ b.giveMod()
} else if (keys[82]) { // teleport to mouse with R
Matter.Body.setPosition(player, game.mouseInGame);
Matter.Body.setVelocity(player, {
@@ -456,9 +453,8 @@ const game = {
b.activeGun = null;
b.setModDefaults(); //remove mods
game.updateModHUD();
- mech.fieldEnergyMax = 1
mech.maxHealth = 1
- mech.fieldUpgrades[0].effect(); //set to default field
+ mech.fieldEnergyMax = 1
game.paused = false;
build.isShowingBuilds = false
engine.timing.timeScale = 1;
@@ -490,7 +486,11 @@ const game = {
document.getElementById("text-log").style.opacity = 0;
document.getElementById("fade-out").style.opacity = 0;
document.title = "n-gon";
- if (!mech.fieldMode) mech.fieldUpgrades[0].effect(); //reset to starting field? or let them keep the field
+ //set to default field
+ mech.fieldMode = 0;
+ game.replaceTextLog = true;
+ game.makeTextLog(`${game.SVGrightMouse} ${mech.fieldUpgrades[mech.fieldMode].name}
${mech.fieldUpgrades[mech.fieldMode].description}`, 600);
+ mech.setField(mech.fieldMode)
},
firstRun: true,
splashReturn() {
@@ -499,8 +499,10 @@ const game = {
document.getElementById("splash").onclick = function () {
game.startGame();
};
+ document.getElementById("choose-grid").style.display = "none"
document.getElementById("controls").style.display = "inline";
document.getElementById("build-button").style.display = "inline"
+ document.getElementById("draft-button").style.display = "inline"
isShowingBuilds = false
document.getElementById("settings").style.display = "inline";
document.getElementById("splash").style.display = "inline";
@@ -511,13 +513,15 @@ const game = {
fpsInterval: 0, //set in startGame
then: null,
startGame() {
- level.isBuildRun = false; //can get set back to true in buld.startBuildRun()
+ level.isBuildRun = false; //can get set back to true in build.startBuildRun()
game.onTitlePage = false;
document.body.style.overflow = "hidden"
+ document.getElementById("choose-grid").style.display = "none"
document.getElementById("build-grid").style.display = "none"
document.getElementById("controls").style.display = "none";
document.getElementById("settings").style.display = "none";
document.getElementById("build-button").style.display = "none";
+ document.getElementById("draft-button").style.display = "none"
document.getElementById("splash").onclick = null; //removes the onclick effect so the function only runs once
document.getElementById("splash").style.display = "none"; //hides the element that spawned the function
document.getElementById("dmg").style.display = "inline";
diff --git a/js/index.js b/js/index.js
index 7ca9046..94aa588 100644
--- a/js/index.js
+++ b/js/index.js
@@ -82,26 +82,6 @@ game mechanics
*/
-//find what mods I don't have
-function doNotHave(who) {
- let options = [];
- for (let i = 0; i < who.length; i++) {
- if (!who[i].have) options.push(i);
- }
- if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
-}
-
-
-//give a random mod from the mods I don't have
-let newMod = doNotHave(b.mods)
-
-let t = ""
-for (let i = 0; i < 3; i++) {
- t += ``
-}
-// document.getElementById("choose-grid").innerHTML = t
-
-
//collision groups
// cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet | cat.mobShield
const cat = {
@@ -115,6 +95,13 @@ const cat = {
mobShield: 0x10000000,
}
+
+document.getElementById("draft-button").addEventListener("click", () => {
+ game.isDraftMode = true;
+ game.startGame();
+});
+
+
//build build grid display
const build = {
isShowingBuilds: false,
@@ -140,7 +127,6 @@ const build = {
}
if (build.list.length < 5) { //add to build array
- // who.style.border = "2px solid #333"
who.style.backgroundColor = "#919ba8" //"#868f9a"
build.list[build.list.length] = {
who: who,
@@ -151,7 +137,7 @@ const build = {
},
startBuildRun() {
spawn.setSpawnList();
- spawn.setSpawnList();
+ spawn.setSpawnList(); //gives random mobs, not starter
game.startGame();
game.difficulty = 6;
level.isBuildRun = true;
@@ -169,6 +155,7 @@ const build = {
document.getElementById("build-button").addEventListener("click", () => {
document.getElementById("build-button").style.display = "none";
+ document.getElementById("draft-button").style.display = "none";
const el = document.getElementById("build-grid")
if (build.isShowingBuilds) {
el.style.display = "none"
diff --git a/js/level.js b/js/level.js
index 27a4612..7398eba 100644
--- a/js/level.js
+++ b/js/level.js
@@ -70,7 +70,7 @@ const level = {
level.exit.x = 3500;
level.exit.y = -870;
- level.testingMap.addZone(level.exit.x, level.exit.y, 100, 30, "nextLevel");
+ level.addZone(level.exit.x, level.exit.y, 100, 30, "nextLevel");
document.body.style.backgroundColor = "#dcdcde";
@@ -105,10 +105,10 @@ const level = {
// spawn.lineBoss(-500, -600, spawn.allowedBossList[Math.floor(Math.random() * spawn.allowedBossList.length)]);
// spawn.bodyRect(-135, -50, 50, 50);
// spawn.bodyRect(-140, -100, 50, 50);
- powerUps.spawn(420, -400, "field", false);
- powerUps.spawn(420, -400, "field", false);
- powerUps.spawn(420, -400, "field", false);
- powerUps.spawn(420, -400, "field", false);
+ powerUps.spawn(420, -400, "mod", false);
+ // powerUps.spawn(420, -400, "field", false);
+ // powerUps.spawn(420, -400, "field", false);
+ // powerUps.spawn(420, -400, "field", false);
// powerUps.spawn(450, -400, "mod", false, 6);
// powerUps.spawn(450, -400, "mod", false);
// spawn.bodyRect(-45, -100, 40, 50);
diff --git a/js/player.js b/js/player.js
index 6a4dfdd..7af49ed 100644
--- a/js/player.js
+++ b/js/player.js
@@ -1033,21 +1033,17 @@ const mech = {
}
},
hold() {},
- fieldText() {
- game.replaceTextLog = true;
- game.makeTextLog(`${game.SVGrightMouse} ${mech.fieldUpgrades[mech.fieldMode].name}
${mech.fieldUpgrades[mech.fieldMode].description}`, 1000);
- game.replaceTextLog = false;
- document.getElementById("field").innerHTML = mech.fieldUpgrades[mech.fieldMode].name //add field
+ setField(index) {
+ mech.fieldMode = index;
+ document.getElementById("field").innerHTML = mech.fieldUpgrades[index].name
+ mech.setHoldDefaults();
+ mech.fieldUpgrades[index].effect();
},
fieldUpgrades: [{
name: "field emitter",
description: "use energy to shield yourself from damage
lets you pick up and throw objects",
effect: () => {
- mech.fieldMode = 0;
- mech.fieldText();
game.replaceTextLog = true; //allow text over write
- // game.makeTextLog("
(right click or space bar)", 1200);
- mech.setHoldDefaults();
mech.hold = function () {
if (mech.isHolding) {
mech.drawHold(mech.holdingTarget);
@@ -1071,9 +1067,6 @@ const mech = {
name: "time dilation field",
description: "use energy to stop time
can fire bullets while field is active",
effect: () => {
- mech.fieldMode = 1;
- mech.fieldText();
- mech.setHoldDefaults();
mech.fieldFire = true;
mech.grabRange = 130
mech.isBodiesAsleep = false;
@@ -1140,9 +1133,6 @@ const mech = {
name: "plasma torch",
description: "use energy to emit damaging plasma
effective at close range",
effect: () => {
- mech.fieldMode = 2;
- mech.fieldText();
- mech.setHoldDefaults();
// mech.fieldShieldingScale = 2;
// mech.grabRange = 125;
mech.fieldArc = 0.1 //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
@@ -1309,9 +1299,6 @@ const mech = {
name: "negative mass field",
description: "use energy to nullify gravity
can fire bullets while active",
effect: () => {
- mech.fieldMode = 3;
- mech.fieldText();
- mech.setHoldDefaults();
mech.fieldFire = true;
mech.hold = function () {
@@ -1396,9 +1383,6 @@ const mech = {
name: "standing wave harmonics",
description: "three oscillating shields are permanently active
energy regenerates while field is active",
effect: () => {
- mech.fieldMode = 4;
- mech.fieldText();
- mech.setHoldDefaults();
// mech.fieldRegen *= 0.6;
mech.fieldShieldingScale = 1.33;
@@ -1441,9 +1425,6 @@ const mech = {
name: "nano-scale manufacturing",
description: "excess energy used to build drones
2x energy regeneration",
effect: () => {
- mech.fieldMode = 5;
- mech.fieldText();
- mech.setHoldDefaults();
mech.fieldRegen *= 2;
mech.hold = function () {
if (mech.fieldMeter > mech.fieldEnergyMax - 0.02) {
@@ -1473,9 +1454,6 @@ const mech = {
name: "phase decoherence field",
description: "use energy to to become intangible
can't see or be seen outside field",
effect: () => {
- mech.fieldMode = 6;
- mech.fieldText();
- mech.setHoldDefaults();
// mech.grabRange = 230
mech.hold = function () {
mech.isStealth = false //isStealth is checked in mob foundPlayer()
diff --git a/js/powerups.js b/js/powerups.js
index 80236cd..0e2ac8a 100644
--- a/js/powerups.js
+++ b/js/powerups.js
@@ -1,6 +1,37 @@
let powerUp = [];
const powerUps = {
+ choose(type, index) {
+ if (type === "gun") {
+ if (b.activeGun === null) b.activeGun = index //if no active gun switch to new gun
+ b.guns[index].have = true;
+ b.inventory.push(index);
+ b.guns[index].ammo += b.guns[index].ammoPack * 2;
+ game.makeGunHUD();
+
+ // game.replaceTextLog = true;
+ // game.makeTextLog(`${game.SVGleftMouse} ${b.guns[index].name}
${b.guns[index].description}`, 500);
+ // game.replaceTextLog = false;
+ } else if (type === "field") {
+ mech.setField(index)
+ } else if (type === "mod") {
+ b.giveMod(index)
+ // game.replaceTextLog = true;
+ // game.makeTextLog(` ${b.mods[index].name}
${b.mods[index].description}`, 500);
+ // game.replaceTextLog = false;
+ }
+ document.body.style.cursor = "none";
+ document.getElementById("choose-grid").style.display = "none"
+ document.getElementById("choose-background").style.display = "none"
+ game.paused = false;
+ requestAnimationFrame(cycle);
+ },
+ showDraft() {
+ document.getElementById("choose-grid").style.display = "grid"
+ document.getElementById("choose-background").style.display = "inline"
+ document.body.style.cursor = "auto";
+ game.paused = true;
+ },
heal: {
name: "heal",
color: "#0eb",
@@ -60,26 +91,54 @@ const powerUps = {
return 45;
},
effect() {
- const previousMode = mech.fieldMode
- if (this.mode) { //this.mode is set if the power up has been ejected from player
- mech.fieldUpgrades[this.mode].effect(); //set a predetermined power up
- } else { //choose a random mode that you don't already have
- availableModes = []
- for (let i = 1; i < mech.fieldUpgrades.length; i++) { //start on 1 to skip the default field
- if (i !== previousMode) {
- availableModes.push(i)
+ if (game.isDraftMode) {
+ function doNotHave(who, skip1 = -1, skip2 = -1) {
+ let options = [];
+ for (let i = 1; i < who.length; i++) {
+ if (i !== mech.fieldMode && i !== skip1 && i !== skip2) options.push(i);
}
+ if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
}
- const mode = availableModes[Math.floor(Math.random() * availableModes.length)]
- mech.fieldUpgrades[mode].effect();
- }
- //pop the old field out in case player wants to swap back
- if (previousMode !== 0) {
- mech.fieldCDcycle = mech.cycle + 40; //trigger fieldCD to stop power up grab automatic pick up of spawn
- setTimeout(function () {
- powerUps.spawn(mech.pos.x, mech.pos.y - 15, "field", false, previousMode);
- }, 100);
+ let choice1 = doNotHave(mech.fieldUpgrades)
+ let choice2 = doNotHave(mech.fieldUpgrades, choice1)
+ let choice3 = doNotHave(mech.fieldUpgrades, choice1, choice2)
+ if (choice1 > -1) {
+ let text = `choose a field
`
+ text += ` ${mech.fieldUpgrades[choice1].name}
${mech.fieldUpgrades[choice1].description}
`
+ if (choice2 > -1) text += ` ${mech.fieldUpgrades[choice2].name}
${mech.fieldUpgrades[choice2].description}
`
+ if (choice3 > -1) text += ` ${mech.fieldUpgrades[choice3].name}
${mech.fieldUpgrades[choice3].description}
`
+ // text += `${game.SVGrightMouse} activate the shield with the right mouse
fields shield you from damage
and let you pick up and throw blocks
`
+ document.getElementById("choose-grid").innerHTML = text
+ powerUps.showDraft();
+ } else {
+ powerUps.giveRandomAmmo()
+ }
+ } else {
+ const previousMode = mech.fieldMode
+ if (this.mode) { //this.mode is set if the power up has been ejected from player
+ // mech.fieldUpgrades[this.mode].effect(); //set a predetermined power up
+ mech.setField(this.mode)
+ } else { //choose a random mode that you don't already have
+ availableModes = []
+ for (let i = 1; i < mech.fieldUpgrades.length; i++) { //start on 1 to skip the default field
+ if (i !== previousMode) {
+ availableModes.push(i)
+ }
+ }
+ const mode = availableModes[Math.floor(Math.random() * availableModes.length)]
+ mech.setField(mode)
+ }
+ game.replaceTextLog = true;
+ game.makeTextLog(`${game.SVGrightMouse} ${mech.fieldUpgrades[mech.fieldMode].name}
${mech.fieldUpgrades[mech.fieldMode].description}`, 600);
+ game.replaceTextLog = false;
+ //pop the old field out in case player wants to swap back
+ if (previousMode !== 0) {
+ mech.fieldCDcycle = mech.cycle + 40; //trigger fieldCD to stop power up grab automatic pick up of spawn
+ setTimeout(function () {
+ powerUps.spawn(mech.pos.x, mech.pos.y - 15, "field", false, previousMode);
+ }, 100);
+ }
}
}
},
@@ -90,18 +149,43 @@ const powerUps = {
return 42;
},
effect() {
- //find what mods I don't have
- let options = [];
- for (let i = 0; i < b.mods.length; i++) {
- if (!b.mods[i].have) options.push(i);
- }
- //give a random mod from the mods I don't have
- if (options.length > 0) {
- let newMod = options[Math.floor(Math.random() * options.length)]
- b.giveMod(newMod)
- game.replaceTextLog = true;
- game.makeTextLog(` ${b.mods[newMod].name}
${b.mods[newMod].description}`, 1000);
- game.replaceTextLog = false;
+ if (game.isDraftMode) {
+ function doNotHave(who, skip1 = -1, skip2 = -1) {
+ let options = [];
+ for (let i = 0; i < who.length; i++) {
+ if (!who[i].have && i !== skip1 && i !== skip2) options.push(i);
+ }
+ if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
+ }
+
+ let choice1 = doNotHave(b.mods)
+ let choice2 = doNotHave(b.mods, choice1)
+ let choice3 = doNotHave(b.mods, choice1, choice2)
+ if (choice1 > -1) {
+ let text = "choose a mod
"
+ text += ` ${b.mods[choice1].description}
`
+ if (choice2 > -1) text += ` ${b.mods[choice2].description}
`
+ if (choice3 > -1) text += ` ${b.mods[choice3].description}
`
+ document.getElementById("choose-grid").innerHTML = text
+ powerUps.showDraft();
+ } else {
+ powerUps.giveRandomAmmo()
+ }
+ } else {
+ //find what mods I don't have
+ let options = [];
+ for (let i = 0; i < b.mods.length; i++) {
+ if (!b.mods[i].have) options.push(i);
+ }
+
+ // give a random mod from the mods I don 't have
+ if (options.length > 0) {
+ let newMod = options[Math.floor(Math.random() * options.length)]
+ b.giveMod(newMod)
+ game.replaceTextLog = true;
+ game.makeTextLog(` ${b.mods[newMod].name}
${b.mods[newMod].description}`, 1000);
+ game.replaceTextLog = false;
+ }
}
}
},
@@ -112,40 +196,68 @@ const powerUps = {
return 35;
},
effect() {
- //find what guns I don't have
- let options = [];
- if (b.activeGun === null && game.difficulty < 3) {
- //choose the first gun to be one that is good for the early game
- for (let i = 0; i < b.guns.length; ++i) {
- if (!b.guns[i].have && b.guns[i].isStarterGun) options.push(i);
+ if (game.isDraftMode) {
+
+ function doNotHave(who, skip1 = -1, skip2 = -1) {
+ let options = [];
+ for (let i = 0; i < who.length; i++) {
+ if (!who[i].have && i !== skip1 && i !== skip2) options.push(i);
+ }
+ if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
+ }
+
+ let choice1 = doNotHave(b.guns)
+ let choice2 = doNotHave(b.guns, choice1)
+ let choice3 = doNotHave(b.guns, choice1, choice2)
+
+ if (choice1 > -1) {
+ let text = "choose a gun
"
+ text += ` ${b.guns[choice1].description}
`
+ if (choice2 > -1) text += ` ${b.guns[choice2].description}
`
+ if (choice3 > -1) text += ` ${b.guns[choice3].description}
`
+ document.getElementById("choose-grid").innerHTML = text
+ powerUps.showDraft();
+ } else {
+ powerUps.giveRandomAmmo()
}
} else {
- //choose a gun you don't have
- for (let i = 0; i < b.guns.length; ++i) {
- if (!b.guns[i].have) options.push(i);
+ //find what guns I don't have
+ let options = [];
+ if (b.activeGun === null && game.difficulty < 3) {
+ //choose the first gun to be one that is good for the early game
+ for (let i = 0; i < b.guns.length; ++i) {
+ if (!b.guns[i].have && b.guns[i].isStarterGun) options.push(i);
+ }
+ } else {
+ //choose a gun you don't have
+ for (let i = 0; i < b.guns.length; ++i) {
+ if (!b.guns[i].have) options.push(i);
+ }
}
+ //give player a gun they don't already have if possible
+ game.replaceTextLog = true;
+ if (options.length > 0) {
+ let newGun = options[Math.floor(Math.random() * options.length)];
+ if (b.activeGun === null) b.activeGun = newGun //if no active gun switch to new gun
+ b.guns[newGun].have = true;
+ b.inventory.push(newGun);
+ b.guns[newGun].ammo += b.guns[newGun].ammoPack * 2;
+ game.makeGunHUD();
+ game.makeTextLog(`${game.SVGleftMouse} ${b.guns[newGun].name}
${b.guns[newGun].description}`, 900);
+ } else {
+ powerUps.giveRandomAmmo()
+ }
+ game.replaceTextLog = false
}
- //give player a gun they don't already have if possible
- game.replaceTextLog = true;
- if (options.length > 0) {
- let newGun = options[Math.floor(Math.random() * options.length)];
- if (b.activeGun === null) b.activeGun = newGun //if no active gun switch to new gun
- game.makeTextLog(`${game.SVGleftMouse} ${b.guns[newGun].name}
${b.guns[newGun].description}`, 900);
- b.guns[newGun].have = true;
- b.inventory.push(newGun);
- b.guns[newGun].ammo += b.guns[newGun].ammoPack * 2;
- game.makeGunHUD();
- } else {
- //if you have all guns then get ammo
- const ammoTarget = Math.floor(Math.random() * (b.guns.length));
- const ammo = Math.ceil(b.guns[ammoTarget].ammoPack * 2);
- b.guns[ammoTarget].ammo += ammo;
- game.updateGunHUD();
- game.makeTextLog("+" + ammo + " ammo for " + b.guns[ammoTarget].name + "", 300);
- }
- game.replaceTextLog = false
}
},
+ giveRandomAmmo() {
+ const ammoTarget = Math.floor(Math.random() * (b.guns.length));
+ const ammo = Math.ceil(b.guns[ammoTarget].ammoPack * 2);
+ b.guns[ammoTarget].ammo += ammo;
+ game.updateGunHUD();
+ game.makeTextLog("+" + ammo + " ammo for " + b.guns[ammoTarget].name + "", 300);
+ },
spawnRandomPowerUp(x, y) { //mostly used after mob dies
if (Math.random() * Math.random() - 0.25 > Math.sqrt(mech.health) || Math.random() < 0.04) { //spawn heal chance is higher at low health
powerUps.spawn(x, y, "heal");
@@ -167,7 +279,7 @@ const powerUps = {
if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "mod");
return;
}
- if (Math.random() < 0.005) {
+ if (Math.random() < 0.003) {
powerUps.spawn(x, y, "field");
if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "field");
return;
@@ -177,21 +289,29 @@ const powerUps = {
if (mech.fieldMode === 0) {
powerUps.spawn(x, y, "field")
if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "field")
- } else if (Math.random() < 0.27) {
+ } else if (Math.random() < 0.4) {
powerUps.spawn(x, y, "mod")
if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "mod")
- } else if (Math.random() < 0.27) {
- powerUps.spawn(x, y, "field");
- if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "field");
- } else if (Math.random() < 0.27) {
+ } else if (Math.random() < 0.3) {
powerUps.spawn(x, y, "gun")
if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "gun")
+ } else if (Math.random() < 0.15) {
+ powerUps.spawn(x, y, "field");
+ if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "field");
} else if (mech.health < 0.6) {
powerUps.spawn(x, y, "heal");
- if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "heal");
+ powerUps.spawn(x, y, "heal");
+ if (Math.random() < b.modMoreDrops) {
+ powerUps.spawn(x, y, "heal");
+ powerUps.spawn(x, y, "heal");
+ }
} else {
powerUps.spawn(x, y, "ammo");
- if (Math.random() < b.modMoreDrops) powerUps.spawn(x, y, "ammo");
+ powerUps.spawn(x, y, "ammo");
+ if (Math.random() < b.modMoreDrops) {
+ powerUps.spawn(x, y, "ammo");
+ powerUps.spawn(x, y, "ammo");
+ }
}
},
chooseRandomPowerUp(x, y) { //100% chance to drop a random power up //used in spawn.debris
diff --git a/style.css b/style.css
index f3667d6..5427cf7 100644
--- a/style.css
+++ b/style.css
@@ -53,6 +53,13 @@ summary {
background-color: #efeff5;
}
+#draft-button {
+ position: absolute;
+ top: 3px;
+ left: 3px;
+ z-index: 12;
+}
+
#build-button {
position: absolute;
top: 3px;
@@ -60,36 +67,40 @@ summary {
z-index: 12;
}
+#choose-background {
+ position: absolute;
+ z-index: 2;
+ width: 100%;
+ height: 100%;
+ display: none;
+ background-color: #fff;
+ opacity: 0.5;
+ /* transition: display 0.5s; */
+}
+
#choose-grid {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
padding: 10px;
margin: 0px;
- border-radius: 7px;
- position: absolute;
- bottom: 0px;
- left: 0px;
+ border-radius: 8px;
z-index: 12;
background-color: #444;
- /* background-color: rgba(68, 68, 68, 0.5); */
-
- display: grid;
+ display: none;
grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
grid-auto-rows: minmax(auto, auto);
grid-gap: 10px;
- z-index: 12;
font-size: 1.3em;
- cursor: auto;
}
.choose-grid-module {
- /* box-shadow: 0px 1px 4px #234; */
padding: 10px;
- /* margin: 4px; */
line-height: 170%;
border-radius: 6px;
background-color: #fff;
- /* background-color: rgba(255, 255, 255, 0.5); */
font-size: 0.8em;
- /* display: flex; */
}
.choose-grid-module:hover {
@@ -100,32 +111,25 @@ summary {
padding: 16px;
margin: 0px;
border: 0px;
- /* border-radius: 8px; */
background-color: #c4ccd8;
- /* #b6bfca; */
display: none;
- /* display: grid; */
grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
grid-auto-rows: minmax(auto, auto);
grid-gap: 16px;
position: relative;
bottom: 0px;
- /* left: 0px; */
- z-index: 12;
+ z-index: 10;
font-size: 1.3em;
}
.build-grid-module {
- /* box-shadow: 0px 1px 4px #234; */
padding: 10px;
- /* margin: 4px; */
line-height: 170%;
border-radius: 6px;
background: #fff;
font-size: 0.65em;
- /* display: flex; */
}
.grid-title {
@@ -138,26 +142,6 @@ summary {
background-color: #efeff5;
}
-.gun-module {
- background: #d5dde5;
-}
-
-.field-module {
- background: #bde;
-}
-
-.mod-module {
- background: #fdf;
-}
-
-
-/* #build {
- position: absolute;
- bottom: 0px;
- right: 1px;
- z-index: 12;
- font-size: 1.3em;
-} */
#settings {
position: absolute;
bottom: 0px;