Skip to content

Commit

Permalink
scroll tech when choosing tech
Browse files Browse the repository at this point in the history
you can scroll through the tech and gun menus while selecting power ups
added another classic n-gon option in settings

tech: options exchange - canceling tech,gun,field has a 90% chance for a reroll

stabber mobs now stab 15% shorter distance, but they can stab more often
weak interaction gives 5->10 max energy per unused power up

bug fixes
  • Loading branch information
landgreen committed Apr 25, 2022
1 parent fcbbf29 commit 099fc07
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 104 deletions.
Binary file modified .DS_Store
Binary file not shown.
14 changes: 8 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@
<br>
<label for="classic-select" title="play older versions of n-gon">classic n-gon:</label>
<select name="classic-select" id="classic-select" onChange="window.location.href=this.value">
<option value="https://scratch.mit.edu/projects/14005697/fullscreen/">scratch: 2014</option>
<option value="https://scratch.mit.edu/projects/22573757/fullscreen/">scratch: 2015</option>
<option value="https://codepen.io/lilgreenland/full/ozXNWZ">codepen: 2016</option>
<option value="https://codepen.io/lilgreenland/full/wzARJY">codepen: 2016</option>
<option value="classic/7-1-2017/">n-gon: 2017</option>
<option value="https://scratch.mit.edu/projects/14005697/fullscreen/">mech: 2014</option>
<option value="https://scratch.mit.edu/projects/22573757/fullscreen/">spacetime: 2015</option>
<option value="https://scratch.mit.edu/projects/41429974/fullscreen/">ballistics: 2015</option>
<option value="https://scratch.mit.edu/projects/43690666/fullscreen/">portal: 2016</option>
<option value="https://codepen.io/lilgreenland/full/ozXNWZ">side scroller: 2016</option>
<option value="https://codepen.io/lilgreenland/full/wzARJY">side scroller: 2016</option>
<option value="classic/7-1-2017/">LandGame: 2017</option>
<option value="classic/4-15-2018/">n-gon: 2018</option>
<option value="classic/7-11-2019/">n-gon: summer-2019</option>
<option value="classic/9-8-2019/">n-gon: fall-2019</option>
Expand Down Expand Up @@ -191,7 +193,7 @@
</g>
</svg>
</a>
<a href="https://github.com/landgreen/n-gon">Github</a> hosts the source code for n-gon.<br> It's written in JavaScript, CSS, and HTML using the matter.js 2-D physics library.
<a href="https://github.com/landgreen/n-gon">Github</a> hosts n-gon's 2.5MB source code.<br>It's written in JavaScript, CSS, and HTML and uses the matter.js 2-D physics library.
</div>
</details>
</div>
Expand Down
53 changes: 16 additions & 37 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,33 +220,6 @@ for (let i = 0, len = tech.tech.length; i < len; i++) {
}

const build = {
// onLoadPowerUps() {
// const set = getUrlVars()
// if (Object.keys(set).length !== 0) {
// for (const property in set) {
// set[property] = set[property].replace(/%20/g, " ")
// if (property.substring(0, 3) === "gun") b.giveGuns(set[property])
// if (property.substring(0, 3) === "tech") tech.giveTech(set[property])
// if (property === "field") m.setField(set[property])
// if (property === "difficulty") {
// simulation.difficultyMode = Number(set[property])
// document.getElementById("difficulty-select").value = Number(set[property])
// }
// if (property === "level") {
// level.levelsCleared += Number(set[property]);
// level.difficultyIncrease(Number(set[property]) * simulation.difficultyMode) //increase difficulty based on modes
// spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
// level.onLevel++
// }
// }
// for (let i = 0; i < bullet.length; ++i) Matter.Composite.remove(engine.world, bullet[i]);
// bullet = []; //remove any bullets that might have spawned from tech
// if (b.inventory.length > 0) {
// b.activeGun = b.inventory[0] //set first gun to active gun
// simulation.makeGunHUD();
// }
// }
// },
pauseGrid() {
//left side
let botText = ""
Expand All @@ -264,14 +237,7 @@ const build = {
<br><br><svg class="SVG-button" onclick="build.shareURL(false)" width="92" height="20" style="padding:0px; margin: 1px;">
<g stroke='none' fill='#333' stroke-width="2" font-size="14px" font-family="Ariel, sans-serif"> <text x="5" y="15">copy build url</text></g>
</svg><br>`
//{ /* <strong class='color-d'>damage</strong> increase: ${((tech.damageFromTech()-1)*100).toFixed(0)}% */ }
// <br>damage difficulty reduction: ${((1-m.dmgScale)*100).toFixed(2)}%
// <br>effective damage: ${(((tech.damageFromTech()-1)*m.dmgScale)*100).toFixed(0)}%
// <br>
// <br><strong class='color-d'>damage</strong> = ${((tech.damageFromTech())*100).toFixed(0)}% × ${((m.dmgScale)*100).toFixed(2)}% = ${(((tech.damageFromTech())*m.dmgScale)*100).toFixed(0)}%
/// <br>heal difficulty scale: ${(simulation.healScale*100).toFixed(1)}%
text +=
`
text += `
<br>effective <strong class='color-d'>damage</strong>: ${(tech.damageFromTech() * m.dmgScale).toPrecision(4)}
<br>damage: ${((tech.damageFromTech())).toPrecision(4)}, difficulty: ${((m.dmgScale)).toPrecision(4)}
<br>
Expand Down Expand Up @@ -301,13 +267,13 @@ ${simulation.isCheating ? "<br><br><em>lore disabled</em>": ""}

//right side
text = "";
if (tech.isPauseSwitchField) {
if (tech.isPauseSwitchField && !simulation.isChoosing) {
text += `<div class="pause-grid-module" id ="pause-field" style="animation: fieldColorCycle 1s linear infinite alternate;"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${build.nameLink(m.fieldUpgrades[m.fieldMode].name)}</div> ${m.fieldUpgrades[m.fieldMode].description}</div>`
} else {
text += `<div class="pause-grid-module" id ="pause-field"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${build.nameLink(m.fieldUpgrades[m.fieldMode].name)}</div> ${m.fieldUpgrades[m.fieldMode].description}</div>`
}

const style = tech.isPauseEjectTech ? 'style="animation: techColorCycle 1s linear infinite alternate;"' : ''
const style = (tech.isPauseEjectTech && !simulation.isChoosing) ? 'style="animation: techColorCycle 1s linear infinite alternate;"' : ''
for (let i = 0, len = tech.tech.length; i < len; i++) {
if (tech.tech[i].count > 0 && !tech.tech[i].isNonRefundable) {
const techCountText = tech.tech[i].count > 1 ? `(${tech.tech[i].count}x)` : "";
Expand Down Expand Up @@ -337,11 +303,24 @@ ${simulation.isCheating ? "<br><br><em>lore disabled</em>": ""}
el = document.getElementById("pause-grid-right")
el.style.display = "grid"
el.innerHTML = text

document.getElementById("tech").style.display = "none"
document.getElementById("guns").style.display = "none"
document.getElementById("field").style.display = "none"
document.getElementById("health").style.display = "none"
document.getElementById("health-bg").style.display = "none"
},
unPauseGrid() {
document.getElementById("tech").style.display = "inline"
document.getElementById("guns").style.display = "inline"
document.getElementById("field").style.display = "inline"
document.getElementById("health").style.display = "inline"
document.getElementById("health-bg").style.display = "inline"
// document.body.style.overflow = "hidden"
document.getElementById("pause-grid-left").style.display = "none"
document.getElementById("pause-grid-right").style.display = "none"
document.getElementById("pause-grid-right").style.opacity = "1"
document.getElementById("pause-grid-left").style.opacity = "1"
window.scrollTo(0, 0);
},
isExperimentSelection: false,
Expand Down
44 changes: 27 additions & 17 deletions js/level.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const level = {
start() {
if (level.levelsCleared === 0) { //this code only runs on the first level
// simulation.isHorizontalFlipped = true
// m.setField("metamaterial cloaking")
// m.setField("standing wave")
// b.giveGuns("laser")
// tech.giveTech("scrap-bot manufacturing")
// tech.giveTech("dynamo-bot upgrade")
// tech.giveTech("time crystals")
// tech.giveTech("options exchange")
// tech.giveTech("ICBM")
// tech.giveTech("grappling hook")
// tech.giveTech("annelids")
// for (let i = 0; i < 10; i++) powerUps.directSpawn(0, 0, "tech");
// for (let i = 0; i < 9; i++) tech.giveTech("WIMPs")
// tech.giveTech("paradigm shift")
// for (let i = 0; i < 1; i++) powerUps.directSpawn(450, -50, "tech");
// for (let i = 0; i < 15; i++) tech.giveTech()
// for (let i = 10; i < tech.tech.length; i++) { tech.tech[i].isBanished = true }
// powerUps.research.changeRerolls(100000)
// for (let i = 0; i < 5; i++) tech.giveTech("corona discharge")
Expand Down Expand Up @@ -83,7 +83,7 @@ const level = {
}
}
if (tech.isExtraMaxEnergy) {
tech.healMaxEnergyBonus += 0.05 * powerUps.totalPowerUps //Math.min(0.02 * powerUps.totalPowerUps, 0.51)
tech.healMaxEnergyBonus += 0.1 * powerUps.totalPowerUps //Math.min(0.02 * powerUps.totalPowerUps, 0.51)
m.setMaxEnergy();
}
if (tech.isGunCycle) {
Expand Down Expand Up @@ -243,7 +243,7 @@ const level = {
// level.levels.push(level.communityLevels)
level.levels = level.levels.concat(level.communityLevels)
level.levels = shuffle(level.levels); //shuffles order of maps
level.levels.splice(0, 9); //remove some random levels to make up for adding the community levels
level.levels.splice(0, level.communityLevels.length); //remove some random levels to make up for adding the community levels
simulation.isHorizontalFlipped = false;
} else {
level.levels = shuffle(level.levels); //shuffles order of maps
Expand Down Expand Up @@ -2473,7 +2473,6 @@ const level = {
localSettings.loreCount++ //hear the next conversation next time you win
if (localSettings.isAllowed) localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
}

// const hazardSlime = level.hazard(-1800, 150, 3600, 650, 0.004, "hsla(160, 100%, 35%,0.75)")
level.isHazardRise = false //this is set to true to make the slime rise up
const hazardSlime = level.hazard(-1800, -800, 3600, 1600, 0.004, "hsla(160, 100%, 35%,0.75)")
Expand Down Expand Up @@ -2561,6 +2560,7 @@ const level = {
simulation.zoomTransition(level.defaultZoom)
// document.body.style.backgroundColor = "#aaa";
document.body.style.backgroundColor = "#ddd";
color.map = "#808f8f"

spawn.mapRect(-3000, 800, 5000, 1200); //bottom
spawn.mapRect(-2000, -2000, 5000, 1200); //ceiling
Expand Down Expand Up @@ -2624,7 +2624,7 @@ const level = {
spawn.mapRect(4850, -275, 50, 175);

//???
level.difficultyIncrease(30) //30 is near max on hard //60 is near max on why
// level.difficultyIncrease(30) //30 is near max on hard //60 is near max on why
m.addHealth(Infinity)

// spawn.starter(1900, -500, 200) //big boy
Expand All @@ -2636,7 +2636,7 @@ const level = {
// spawn.powerUpBossBaby(3200, -500)
// spawn.snakeBoss(1700, -500)
// spawn.streamBoss(3200, -500)
spawn.pulsarBoss(1700, -500)
// spawn.pulsarBoss(1700, -500)
// spawn.spawnerBossCulture(3200, -500)
// spawn.grenadierBoss(1700, -500)
// spawn.growBossCulture(3200, -500)
Expand All @@ -2646,16 +2646,16 @@ const level = {
// spawn.launcherBoss(3200, -500)
// spawn.blockBoss(1700, -500)
// spawn.blinkBoss(3200, -500)
// spawn.mantisBoss(1700, -500)
// spawn.spiderBoss(1700, -500)
// spawn.tetherBoss(1700, -500) //go to actual level?
// spawn.revolutionBoss(1900, -500)
// spawn.bomberBoss(1400, -500)
// spawn.cellBossCulture(1600, -500)
// spawn.shieldingBoss(1700, -500)

// for (let i = 0; i < 10; ++i) spawn.bodyRect(1600 + 5, -500, 30, 40);
// for (let i = 0; i < 5; i++) spawn.focuser(1900, -500)
spawn.pulsar(1900, -500)
for (let i = 0; i < 1; i++) spawn.stabber(1900, -500)
// spawn.pulsar(1900, -500)
// spawn.shield(mob[mob.length - 1], 1900, -500, 1);
// mob[mob.length - 1].isShielded = true
// spawn.nodeGroup(1200, 0, "grenadier")
Expand All @@ -2672,6 +2672,7 @@ const level = {
level.defaultZoom = 2000
simulation.zoomTransition(level.defaultZoom)
document.body.style.backgroundColor = "#d0d5df" //"#d8dadf";
color.map = "#334046";
// powerUps.spawnStartingPowerUps(1475, -1175);
// spawn.debris(750, -2200, 3700, 16); //16 debris per level
const button = level.button(1400, 0)
Expand Down Expand Up @@ -3198,6 +3199,8 @@ const level = {
level.defaultZoom = 2300
simulation.zoomTransition(level.defaultZoom)
document.body.style.backgroundColor = "#d8dadf";
color.map = "#3d4240"

powerUps.spawnStartingPowerUps(-575, -2925)
// spawn.debris(750, -2200, 3700, 16); //16 debris per level //no debris?

Expand Down Expand Up @@ -3671,6 +3674,7 @@ const level = {
level.defaultZoom = 2200
simulation.zoomTransition(level.defaultZoom)
document.body.style.backgroundColor = "#d5d5d5";
color.map = "#555"
spawn.mapRect(0, -1955, 175, 30);
const removeIndex1 = map.length - 1 //so much work to catch blocks caught at the bottom of the vertical portals
spawn.mapRect(1225, -1955, 175, 30);
Expand Down Expand Up @@ -3968,6 +3972,7 @@ const level = {
level.defaultZoom = 1800
simulation.zoomTransition(level.defaultZoom)
document.body.style.backgroundColor = "hsl(138, 3%, 74%)";
color.map = "#3d4240"
powerUps.spawnStartingPowerUps(3475, 1775);
spawn.debris(4575, 2550, 1600, 9); //16 debris per level
spawn.debris(7000, 2550, 2000, 7); //16 debris per level
Expand Down Expand Up @@ -9489,10 +9494,9 @@ const level = {
Matter.Body.setDensity(me, 0.014); // 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.spawn(this.position.x, this.position.y, "ammo");
powerUps.spawn(this.position.x, this.position.y, "ammo");
if (Math.random() > 0.2) powerUps.spawn(this.position.x, this.position.y, "heal", true, null,
30 * (simulation.healScale ** 0.25) * Math.sqrt(tech.largerHeals) * Math.sqrt(0.1 + Math.random() * 0.5));
powerUps.spawn(this.position.x + 20, this.position.y, "ammo");
if (Math.random() > 0.5) powerUps.spawn(this.position.x, this.position.y, "ammo");
if (Math.random() > 0.3) powerUps.spawn(this.position.x, this.position.y, "heal", true, null, 30 * (simulation.healScale ** 0.25) * Math.sqrt(tech.largerHeals) * Math.sqrt(0.1 + Math.random() * 0.5));
if (simulation.difficulty > 5) {
// fling player to center
const SUB = V.sub(this.position, player.position)
Expand Down Expand Up @@ -9808,11 +9812,13 @@ const level = {
}
};
let oldNextLevel = level.nextLevel;
const oldFallHeight = simulation.fallHeight;
level.nextLevel = () => {
color.map = "#444";
m.death = m.oldDeath;
canvas.style.filter = "";
level.nextLevel = oldNextLevel;
simulation.fallHeight = oldFallHeight;
oldNextLevel();
}
let bounds = [];
Expand All @@ -9824,6 +9830,7 @@ const level = {
m.death = m.oldDeath;
canvas.style.filter = "";
level.nextLevel = oldNextLevel;
simulation.fallHeight = oldFallHeight;
}
m.oldDeath();
}
Expand Down Expand Up @@ -10233,6 +10240,7 @@ const level = {
level.exit.x = 4500;
level.exit.y = -2030;
relocateTo(50, -2050);
simulation.fallHeight = -1000;
simulation.setZoom(1800);
templePlayer.startAnim = -1;
for (let i = 0; i < tech.wimpCount + tech.wimpExperiment; i++) {
Expand Down Expand Up @@ -10266,6 +10274,7 @@ const level = {
if (templePlayer.room1ToRoom2Anim === 960) {
makeLore("You are trying too hard.");
relocateTo(0, -7050);
simulation.fallHeight = -6000;
templePlayer.stage = 2;
}
if (templePlayer.room1ToRoom2Anim === 1200) {
Expand Down Expand Up @@ -10313,6 +10322,7 @@ const level = {
makeLore("Do not interfere with me.");
templePlayer.stage = 3;
relocateTo(50, -13150);
simulation.fallHeight = -10000;
simulation.zoomTransition(1800);
templePlayer.startAnim = -1;
// Might be a bit harsh to the player if the WIMPs are involved in the third level
Expand Down
1 change: 0 additions & 1 deletion js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,6 @@ const m = {
if (this.drainCD > m.cycle) {
m.pushMass(mob[i], 0);
} else {
console.log(this.drainCD)
m.pushMass(mob[i]);
this.drainCD = m.cycle + 15
}
Expand Down
Loading

0 comments on commit 099fc07

Please sign in to comment.