slime station

added a random station in subway
a few bug fixes
This commit is contained in:
landgreen
2023-06-08 19:43:28 -07:00
parent 09c9e93fcf
commit d8e978fbe6
6 changed files with 125 additions and 62 deletions

View File

@@ -54,8 +54,8 @@
<select name="difficulty-select" id="difficulty-select" style="background-color: #fff">
<option value="1">easy ⚆</option>
<option value="2" selected>normal ⚆</option>
<option value="4">hard </option>
<option value="6">why </option>
<option value="4">hard </option>
<option value="6">why </option>
</select>
<br>
<label for="fps-select" title="use this to slow the game down">limit frames per second:</label>
@@ -228,19 +228,7 @@
<details>
<summary>about</summary>
<div class="details-div" style="max-width: 450px;">
<a href="https://discord.gg/2eC9pgJ" aria-label="discord">
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1400 235">
<style>
.st0 {
fill: #1B1F23;
}
</style>
<path class="st0" d="M142.8 120.1c-5.7 0-10.2 4.9-10.2 11s4.6 11 10.2 11c5.7 0 10.2-4.9 10.2-11s-4.6-11-10.2-11zM106.3 120.1c-5.7 0-10.2 4.9-10.2 11s4.6 11 10.2 11c5.7 0 10.2-4.9 10.2-11 .1-6.1-4.5-11-10.2-11z" />
<path class="st0" d="M191.4 36.9h-134c-11.3 0-20.5 9.2-20.5 20.5v134c0 11.3 9.2 20.5 20.5 20.5h113.4l-5.3-18.3 12.8 11.8 12.1 11.1 21.6 18.7V57.4c-.1-11.3-9.3-20.5-20.6-20.5zm-38.6 129.5s-3.6-4.3-6.6-8c13.1-3.7 18.1-11.8 18.1-11.8-4.1 2.7-8 4.6-11.5 5.9-5 2.1-9.8 3.4-14.5 4.3-9.6 1.8-18.4 1.3-25.9-.1-5.7-1.1-10.6-2.6-14.7-4.3-2.3-.9-4.8-2-7.3-3.4-.3-.2-.6-.3-.9-.5-.2-.1-.3-.2-.4-.2-1.8-1-2.8-1.7-2.8-1.7s4.8 7.9 17.5 11.7c-3 3.8-6.7 8.2-6.7 8.2-22.1-.7-30.5-15.1-30.5-15.1 0-31.9 14.4-57.8 14.4-57.8 14.4-10.7 28-10.4 28-10.4l1 1.2c-18 5.1-26.2 13-26.2 13s2.2-1.2 5.9-2.8c10.7-4.7 19.2-5.9 22.7-6.3.6-.1 1.1-.2 1.7-.2 6.1-.8 13-1 20.2-.2 9.5 1.1 19.7 3.9 30.1 9.5 0 0-7.9-7.5-24.9-12.6l1.4-1.6s13.7-.3 28 10.4c0 0 14.4 25.9 14.4 57.8 0-.1-8.4 14.3-30.5 15zM303.8 79.7h-33.2V117l22.1 19.9v-36.2h11.8c7.5 0 11.2 3.6 11.2 9.4v27.7c0 5.8-3.5 9.7-11.2 9.7h-34v21.1h33.2c17.8.1 34.5-8.8 34.5-29.2v-29.8c.1-20.8-16.6-29.9-34.4-29.9zm174 59.7v-30.6c0-11 19.8-13.5 25.8-2.5l18.3-7.4c-7.2-15.8-20.3-20.4-31.2-20.4-17.8 0-35.4 10.3-35.4 30.3v30.6c0 20.2 17.6 30.3 35 30.3 11.2 0 24.6-5.5 32-19.9l-19.6-9c-4.8 12.3-24.9 9.3-24.9-1.4zM417.3 113c-6.9-1.5-11.5-4-11.8-8.3.4-10.3 16.3-10.7 25.6-.8l14.7-11.3c-9.2-11.2-19.6-14.2-30.3-14.2-16.3 0-32.1 9.2-32.1 26.6 0 16.9 13 26 27.3 28.2 7.3 1 15.4 3.9 15.2 8.9-.6 9.5-20.2 9-29.1-1.8l-14.2 13.3c8.3 10.7 19.6 16.1 30.2 16.1 16.3 0 34.4-9.4 35.1-26.6 1-21.7-14.8-27.2-30.6-30.1zm-67 55.5h22.4V79.7h-22.4v88.8zM728 79.7h-33.2V117l22.1 19.9v-36.2h11.8c7.5 0 11.2 3.6 11.2 9.4v27.7c0 5.8-3.5 9.7-11.2 9.7h-34v21.1H728c17.8.1 34.5-8.8 34.5-29.2v-29.8c0-20.8-16.7-29.9-34.5-29.9zm-162.9-1.2c-18.4 0-36.7 10-36.7 30.5v30.3c0 20.3 18.4 30.5 36.9 30.5 18.4 0 36.7-10.2 36.7-30.5V109c0-20.4-18.5-30.5-36.9-30.5zm14.4 60.8c0 6.4-7.2 9.7-14.3 9.7-7.2 0-14.4-3.1-14.4-9.7V109c0-6.5 7-10 14-10 7.3 0 14.7 3.1 14.7 10v30.3zM682.4 109c-.5-20.8-14.7-29.2-33-29.2h-35.5v88.8h22.7v-28.2h4l20.6 28.2h28L665 138.1c10.7-3.4 17.4-12.7 17.4-29.1zm-32.6 12h-13.2v-20.3h13.2c14.1 0 14.1 20.3 0 20.3z" />
</svg>
</a>
Chat about n-gon in the <a href="https://discord.gg/JyfrKbXTfw">discord</a>.<br> Let me know about ideas, or bugs.
<br><br><br>
n-gon is a solo project written in JavaScript, CSS, and HTML using the matter.js 2-D physics library. It's free and open source on <a href="https://github.com/landgreen/n-gon">Github</a>.
<a id="github" href="https://github.com/landgreen/n-gon" aria-label="github">
<svg viewBox="0 0 100 16" xmlns="http://www.w3.org/2000/svg" fill="#1B1F23">
<path d="M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z" />
@@ -249,7 +237,6 @@
</g>
</svg>
</a>
<a href="https://github.com/landgreen/n-gon">Github</a> hosts n-gon's source code.<br>It's written in JavaScript, CSS, and HTML and uses the matter.js 2-D physics library. Images are generated mostly through midJourney.
</div>
</details>
</div>

View File

@@ -34,7 +34,7 @@ const level = {
// b.giveGuns("nail gun") //0 nail gun 1 shotgun 2 super balls 3 wave 4 missiles 5 grenades 6 spores 7 drones 8 foam 9 harpoon 10 mine 11 laser
// b.giveGuns("shotgun") //0 nail gun 1 shotgun 2 super balls 3 wave 4 missiles 5 grenades 6 spores 7 drones 8 foam 9 harpoon 10 mine 11 laser
// b.guns[3].ammo = 100000000
// tech.giveTech("nitinol")
// tech.giveTech("accretion")
// tech.giveTech("surface plasmons")
// for (let i = 0; i < 6; ++i) tech.giveTech("Lorentz transformation")
// for (let i = 0; i < 1; ++i) tech.giveTech("waste heat recovery")
@@ -1521,10 +1521,10 @@ const level = {
for (let i = 0, len = powerUpCollide.length; i < len; i++) {
const diameter = 2 * powerUpCollide[i].size
const buoyancy = 1 - 0.2 * Math.max(0, Math.min(diameter, this.min.y - powerUpCollide[i].position.y + powerUpCollide[i].size)) / diameter
powerUpCollide[i].force.y -= buoyancy * 1.14 * powerUpCollide[i].mass * simulation.g;
powerUpCollide[i].force.y -= buoyancy * 1.24 * powerUpCollide[i].mass * simulation.g;
Matter.Body.setVelocity(powerUpCollide[i], {
x: powerUpCollide[i].velocity.x,
y: 0.96 * powerUpCollide[i].velocity.y
y: 0.97 * powerUpCollide[i].velocity.y
});
}
}
@@ -2629,8 +2629,8 @@ const level = {
subway() {
// simulation.enableConstructMode() //tech.giveTech('motion sickness') //used to build maps in testing mode
// level.difficultyIncrease(10 * 4);
// spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
m.maxHealth = m.health = 100
// m.maxHealth = m.health = 100
const mobSpawnCap = mobs.mobDeaths + 100
level.isProcedural = true //used in generating text for the level builder
@@ -2660,7 +2660,7 @@ const level = {
train[train.length - 1].stops = { left: -7225, right: -1725 }
const stationList = [] //organize the possible stations into a random order, with one station removed
for (let i = 0, totalNumberOfStations = 4; i < totalNumberOfStations; ++i) stationList.push(i)
for (let i = 0, totalNumberOfStations = 5; i < totalNumberOfStations; ++i) stationList.push(i) //!!!! update station number when you add a new station
shuffle(stationList);
stationList.splice(Math.floor(Math.random() * stationList.length), 1); //remove one random element from array
let isExitOpen = false
@@ -2689,13 +2689,20 @@ const level = {
// bullet = [];
// removeAll(composite);
// composite = [];
removeAll(powerUp);
powerUp = [];
// removeAll(cons); // don't allow constraints that don't come from a mob (like elevators, rotors?)
// cons = [];
// removeAll(consBB); // don't allow constraints that don't come from a mob (like elevators, rotors?)
// consBB = [];
// removeAll(powerUp);
// powerUp = [];
//remove any powerUp that is too far from player
for (let i = 0; i < powerUp.length; ++i) {
if (Vector.magnitudeSquared(Vector.sub(player.position, powerUp[i].position)) > 9000000) { //remove any powerUp farther then 3000 pixels from player
Matter.Composite.remove(engine.world, powerUp[i]);
powerUp.splice(i--, 1)
}
}
//remove any mob that is too far from player
for (let i = 0; i < mob.length; ++i) {
if (Vector.magnitudeSquared(Vector.sub(player.position, mob[i].position)) > 4000000) { //remove any mob farther then 2000 pixels from player
@@ -2710,7 +2717,91 @@ const level = {
} else {
for (let i = 0; i < 8; ++i) powerUps.chooseRandomPowerUp(100 * (Math.random() - 0.5), -200 - 100 * Math.random())//only spawn heal or ammo once at the first station
}
const stations = [ //update totalNumberOfStations as you add move stations
const stations = [ //update totalNumberOfStations as you add more stations
() => { //slime
if (isExitOpen) {
level.exit.x = x - 665;
level.exit.y = -920;
}
spawn.mapRect(x + -1575, -2000, 3025, 100); //roof
// spawn.mapRect(x + -1575, -2200, 3025, 300); //roof
// spawn.mapRect(x + -1500, -210, 3000, 400);//station floor
spawn.mapRect(x + -1500, -210, 500, 350); //station floor left
spawn.mapRect(x + 1000, -210, 500, 350); //station floor right
spawn.mapRect(x + 900, -1250, 125, 1250);
spawn.mapRect(x - 1025, -1550, 125, 1625);
spawn.mapRect(x - 50, -1900, 100, 1500);
spawn.mapRect(x + -975, -1250, 200, 25);
spawn.mapRect(x + -950, -625, 150, 25);
spawn.mapRect(x - 925, -400, 250, 175);
spawn.mapRect(x - 725, -900, 225, 300);
spawn.mapRect(x + 325, -225, 325, 75);
spawn.mapRect(x + 400, -950, 275, 25);
spawn.mapRect(x + 775, -575, 200, 25);
spawn.mapRect(x + 0, -1225, 125, 25);
spawn.mapRect(x + 0, -575, 225, 175);
spawn.mapRect(x - 925, -75, 875, 150);
spawn.mapRect(x + 475, -1400, 75, 1250);
if (mobs.mobDeaths < mobSpawnCap) {
if (Math.random() < 0.5) {
spawn.randomMob(x + -850, -450, 0);
spawn.randomMob(x + -850, -125, 0);
spawn.randomMob(x + -725, -100, 0);
spawn.randomMob(x + 0, -100, 0);
spawn.randomMob(x + 800, -50, 0);
spawn.randomMob(x + 50, -275, 0);
spawn.randomMob(x + -300, -425, 0);
spawn.randomMob(x + -750, -475, 0);
spawn.randomMob(x + -850, -775, 0);
spawn.randomMob(x + -650, -1000, 0);
spawn.randomMob(x + -150, -1325, 0);
spawn.randomMob(x + -825, -1350, 0);
spawn.randomMob(x + -375, -150, 0);
} else {
spawn.randomMob(x + 350, -350, 0);
spawn.randomMob(x + 175, -700, 0);
spawn.randomMob(x + 350, -1175, 0);
spawn.randomMob(x + 200, -1600, 0);
spawn.randomMob(x + 500, -1675, 0);
spawn.randomMob(x + 425, -50, 0);
spawn.randomMob(x + 725, -75, 0);
spawn.randomMob(x + 650, -700, 0);
spawn.randomMob(x + 775, -1150, 0);
spawn.randomMob(x + 500, -1675, 0);
spawn.randomMob(x + -150, -175, 0);
spawn.randomMob(x + -800, -150, 0);
}
}
const boost1 = level.boost(x - 1185, -225, 1400)
const boost2 = level.boost(x + 1100, -225, 1100)
const hazard1 = level.hazard(x - 900, -1225, 1800, 1225)
let isSlimeRiseUp = false
const drip = []
drip.push(level.drip(x - 900 + 1800 * Math.random(), -1900, 0, 100)) // drip(x, yMin, yMax, period = 100, color = "hsla(160, 100%, 35%, 0.5)") {
drip.push(level.drip(x - 900 + 1800 * Math.random(), -1900, 0, 150))
drip.push(level.drip(x - 900 + 1800 * Math.random(), -1900, 0, 70))
// drip.push(level.drip(x - 900 + 1800 * Math.random(), -1900, 0, 210))
// drip.push(level.drip(x - 900 + 1800 * Math.random(), -1900, 0, 67))
stationCustom = () => {
for (let i = 0; i < drip.length; i++) drip[i].draw()
// drip1.draw();
// drip2.draw();
// drip3.draw();
}
stationCustomTopLayer = () => {
hazard1.query();
hazard1.level(isSlimeRiseUp, 1.5)
if (!(hazard1.height < hazard1.maxHeight)) {
isSlimeRiseUp = false
} else if (!(hazard1.height > 0)) {
isSlimeRiseUp = true
}
boost1.query();
boost2.query();
}
},
() => { //portals
if (isExitOpen) {
level.exit.x = x + 950;
@@ -2748,9 +2839,6 @@ const level = {
spawn.randomMob(x + 17150, -3150, 0);
spawn.randomMob(x + 17700, -3300, 0);
}
if (!isInProgress) spawn.secondaryBossChance(420, -2200) // spawn.randomLevelBoss(5750, -600);
const portal1 = level.portal({
x: x + 0,
y: -200
@@ -2879,7 +2967,6 @@ const level = {
},
]
if (mobs.mobDeaths < mobSpawnCap) mobPlacement[Math.floor(Math.random() * mobPlacement.length)]()//different random mob placements, with mobs clustered to surprise player
if (!isInProgress) spawn.secondaryBossChance(900, -2700) // spawn.randomLevelBoss(5750, -600);
stationCustom = () => { }
stationCustomTopLayer = () => { }
},
@@ -2963,7 +3050,6 @@ const level = {
},
]
if (mobs.mobDeaths < mobSpawnCap) mobPlacement[Math.floor(Math.random() * mobPlacement.length)]()//different random mob placements, with mobs clustered to surprise player
if (!isInProgress) spawn.secondaryBossChance(600, -2500) // spawn.randomLevelBoss(5750, -600);
const boost1 = level.boost(x - 50, -225, 790)
const boost2 = level.boost(x + 550, -985, 900)
const boost3 = level.boost(x + -850, -835, 1900)
@@ -3015,7 +3101,6 @@ const level = {
spawn.randomMob(x + 75, -1750, 0);
spawn.randomMob(x + 1000, -375, 0);
}
if (!isInProgress) spawn.secondaryBossChance(100, -850) // spawn.randomLevelBoss(5750, -600);
stationCustom = () => { }
stationCustomTopLayer = () => {
ctx.fillStyle = "rgba(0,0,0,0.08)"
@@ -3025,7 +3110,7 @@ const level = {
}
},
]
// stations[3]() //for testing a specific station
// stations[0]() //for testing a specific station
stations[stationList[Math.abs((stationNumber + Math.floor(stationList.length / 2)) % stationList.length)]]() //*************** run this one when uploading
//add in standard station map infrastructure
spawn.mapRect(x + -8000, 0, 16000, 800);//tunnel floor

View File

@@ -1959,7 +1959,7 @@ const m = {
if (tech.isTimeCrystals) {
m.fieldRegen *= 2.5
} else if (tech.isGroundState) {
m.fieldRegen *= 0.6
m.fieldRegen *= 0.66
}
},
regenEnergy: function () { //used in drawRegenEnergy // rewritten by some tech

View File

@@ -1262,6 +1262,8 @@ const simulation = {
m.holdingTarget.collisionFilter.category = 0;
m.holdingTarget.collisionFilter.mask = 0;
m.definePlayerMass(m.defaultMass + m.holdingTarget.mass * m.holdingMassScale)
Composite.add(engine.world, m.holdingTarget); //add to world
m.holdingTarget.classType = "body"
}
//set fps back to default
simulation.fpsCap = simulation.fpsCapDefault

View File

@@ -2533,7 +2533,7 @@ const tech = {
},
{
name: "ground state",
description: "<strong>+200</strong> maximum <strong class='color-f'>energy</strong><br><strong>40%</strong> passive <strong class='color-f'>energy</strong> generation",
description: "<strong>+200</strong> maximum <strong class='color-f'>energy</strong><br><strong>33%</strong> passive <strong class='color-f'>energy</strong> generation",
// description: "reduce <strong class='color-defense'>defense</strong> by <strong>66%</strong><br>you <strong>no longer</strong> passively regenerate <strong class='color-f'>energy</strong>",
maxCount: 1,
count: 0,

View File

@@ -1,27 +1,25 @@
******************************************************** NEXT PATCH **************************************************
level: subway
replaces gauntlet just before the final boss
gauntlet moved to community map pool
subway todo:
add a few more stations
balance difficulty
find bugs
surface plasmons does 50% more damage
elasticity renamed nitinol because I bought some nitinol wire and it's neat
entanglement power up no longer shows guns or fields you already have
disabled minimal HUD for training levels
reaction inhibitor 12->11% mob max health reduction
spawn.bodyRect() now can add blocks mid level without any extra code
I think I found all the bugs this causes, but let me know if any blocks added mid game aren't colliding
community map - clock update:
visual overhaul,live lighting, remove pendulum overlap, move with pendulum if you stand in it, debris, trap exit only opens after completing the fight, moving elements now freeze while using time dilation
added a random station in subway
a few bug fixes
*********************************************************** TODO *****************************************************
mob non-combat behaviors, like Rain World
gathering
blocks
eating blocks to heal?
power ups
eating power ups and ejecting them on death
flocking
grouping near mobs
keeping distance from mobs
sharing velocity with other mobs: boids
wander
random walk with a bias towards the player
play
fight other mobs
consider increasing the base player horizontal movement
maybe only increase ground movement, air control seems fine
@@ -30,7 +28,6 @@ level: subway - a map that uses the train level element and line of sight graphi
station theme ideas:
portals
teleport to far away rooms
slime
map elements that alternate between positions
buttons and doors
boss
@@ -1152,14 +1149,6 @@ level Boss: fractal Sierpiński triangle
they spawn once at the start of the level
if a version dies, one can be replaced every ten seconds by the largest version
give mobs more animal-like behaviors like rain world
mobs play, look for food, explore
mobs some times aren't aggressive
when low on life or after taking a large hit
mobs can fight each other
this might be hard to code
isolated mobs try to group up
mob: wall mounted guns / lasers
not part of randomized mob pool, customized to each level