Skip to content

Commit

Permalink
n-gon
Browse files Browse the repository at this point in the history
  • Loading branch information
landgreen committed Jun 13, 2024
1 parent 9ad0993 commit ccd8d8a
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 155 deletions.
Binary file added n-gon/img/working mass.webp
Binary file not shown.
8 changes: 4 additions & 4 deletions n-gon/js/bullet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3312,8 +3312,8 @@ const b = {
const distB = Vector.magnitude(Vector.sub(this.position, b.position))
return distA < distB ? a : b
})
if (found && m.energy > 0.05) {
m.energy -= 0.05
if (found && m.energy > 0.041) {
m.energy -= 0.04
//remove the body and spawn a new drone
Composite.remove(engine.world, found)
body.splice(body.indexOf(found), 1)
Expand Down Expand Up @@ -3552,8 +3552,8 @@ const b = {
const distB = Vector.magnitude(Vector.sub(this.position, b.position))
return distA < distB ? a : b
})
if (found && m.energy > 0.05) {
m.energy -= 0.1
if (found && m.energy > 0.091) {
m.energy -= 0.09
//remove the body and spawn a new drone
Composite.remove(engine.world, found)
body.splice(body.indexOf(found), 1)
Expand Down
13 changes: 3 additions & 10 deletions n-gon/js/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,8 @@ function collisionChecks(event) {
if (m.immuneCycle < m.cycle + m.collisionImmuneCycles) m.immuneCycle = m.cycle + m.collisionImmuneCycles; //player is immune to damage for 30 cycles
//extra kick between player and mob //this section would be better with forces but they don't work...
let angle = Math.atan2(player.position.y - mob[k].position.y, player.position.x - mob[k].position.x);
Matter.Body.setVelocity(player, {
x: player.velocity.x + 8 * Math.cos(angle),
y: player.velocity.y + 8 * Math.sin(angle)
});
Matter.Body.setVelocity(mob[k], {
x: mob[k].velocity.x - 8 * Math.cos(angle),
y: mob[k].velocity.y - 8 * Math.sin(angle)
});

Matter.Body.setVelocity(player, { x: player.velocity.x + 8 * Math.cos(angle), y: player.velocity.y + 8 * Math.sin(angle) });
Matter.Body.setVelocity(mob[k], { x: mob[k].velocity.x - 8 * Math.cos(angle), y: mob[k].velocity.y - 8 * Math.sin(angle) });
if (tech.isAnnihilation && !mob[k].shield && !mob[k].isShielded && !mob[k].isBoss && mob[k].isDropPowerUp && m.energy > 0.1 && mob[k].damageReduction > 0) {
m.energy -= 0.1 //* Math.max(m.maxEnergy, m.energy) //0.33 * m.energy
if (m.immuneCycle === m.cycle + m.collisionImmuneCycles) m.immuneCycle = 0; //player doesn't go immune to collision damage
Expand Down Expand Up @@ -250,7 +243,7 @@ function collisionChecks(event) {
if (mob[k].isShielded) dmg *= 0.7

mob[k].damage(dmg, true);
if (tech.isBlockPowerUps && !mob[k].alive && mob[k].isDropPowerUp && m.throwCycle > m.cycle) {
if (tech.isBlockPowerUps && !mob[k].alive && mob[k].isDropPowerUp && Math.random() < 0.5) {
options = ["coupling", "boost", "heal", "research"]
if (!tech.isEnergyNoAmmo) options.push("ammo")
powerUps.spawn(mob[k].position.x, mob[k].position.y, options[Math.floor(Math.random() * options.length)]);
Expand Down
18 changes: 11 additions & 7 deletions n-gon/js/level.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ const level = {
// requestAnimationFrame(() => { tech.giveTech("optical amplifier") });
// for (let i = 0; i < 1; ++i) tech.giveTech("combinatorial optimization")
// tech.giveTech("Newtons 2nd law")
// for (let i = 0; i < 1; ++i) tech.giveTech("lens")
// for (let i = 0; i < 1; ++i) tech.giveTech("tungsten carbide")
// for (let i = 0; i < 1; ++i) tech.giveTech("nitinol")
// for (let i = 0; i < 1; ++i) tech.giveTech("reaction mass")
// for (let i = 0; i < 1; ++i) tech.giveTech("working mass")
// for (let i = 0; i < 1; ++i) tech.giveTech("buckling")
// requestAnimationFrame(() => { for (let i = 0; i < 10; i++) b.orbitBot(m.pos, false) });
// requestAnimationFrame(() => { for (let i = 0; i < 1; i++) tech.giveTech("ersatz bots") });
// for (let i = 0; i < 1; i++) tech.giveTech("tungsten carbide")
Expand All @@ -57,11 +56,11 @@ const level = {
// for (let i = 0; i < 1; i++) powerUps.directSpawn(-50, -70, "difficulty", false);
// for (let i = 0; i < 100; i++) powerUps.directSpawn(1750, -500, "coupling");
// spawn.mapRect(575, -700, 25, 425); //block mob line of site on testing
// level.yingYang();
// level.testing();

// for (let i = 0; i < 1; ++i) spawn.laserLayer(1400, -500)
// for (let i = 0; i < 1; ++i) spawn.snakeSpitBoss(1400, -500)
// Matter.Body.setPosition(player, { x: -200, y: -3330 });
// for (let i = 0; i < 4; ++i) spawn.ghoster(1300, -500 + 100 * Math.random())
// for (let i = 0; i < 4; ++i) spawn.sucker(1300, -500 + 100 * Math.random())
// spawn.hopper(1900, -500)
// spawn.zombie(-3000, -500 + 300 * Math.random(), 30, 5, "white") // zombie(x, y, radius, sides, color)
// for (let i = 0; i < 5; ++i) spawn.starter(1000 + 1000 * Math.random(), -500 + 300 * Math.random())
Expand Down Expand Up @@ -4235,7 +4234,6 @@ const level = {
powerUps.addResearchToLevel() //needs to run after mobs are spawned
},
towers() {
// simulation.enableConstructMode() //remove this!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// simulation.isHorizontalFlipped = true
level.announceMobTypes()
const isFlipped = (simulation.isHorizontalFlipped && Math.random() < 0.33) ? true : false
Expand Down Expand Up @@ -4448,6 +4446,12 @@ const level = {
spawn.bodyRect(8975, -1575, 50, 50, 0.2);
spawn.bodyRect(5725, -1700, 125, 175, 0.2);
spawn.bodyRect(6850, -1725, 150, 200, 0.2);
spawn.bodyRect(500, -400, 100, 50, 0.3);
spawn.bodyRect(6025, 1050, 100, 50, 0.2);
spawn.bodyRect(6000, -800, 75, 200, 0.2);
spawn.bodyRect(6775, -75, 125, 75, 0.5);
spawn.bodyRect(7200, 1300, 50, 200, 0.5);


//mobs
spawn.randomMob(5700, -75, 0);
Expand Down
Loading

0 comments on commit ccd8d8a

Please sign in to comment.