1
0
mirror of https://gitlab.com/MisterBiggs/Resume.git synced 2025-06-15 17:06:39 +00:00

clean up code

This commit is contained in:
Anson 2023-10-30 20:35:00 -06:00
parent 10b6b8cf43
commit 89d589e23f
2 changed files with 15 additions and 23 deletions

View File

@ -6,14 +6,14 @@
// https://editor.p5js.org/codingtrain/sketches/MkLraatd
class Mover {
constructor(x, y, vx, vy, m) {
this.pos = createVector(x, y);
constructor(mass, color_value) {
this.pos = createVector(Math.random() * width, Math.random()*height);
this.maxSpeed = 10;
this.vel = createVector(vx, vy);
this.vel = createVector(0, 0);
this.acc = createVector(0, 0);
this.mass = m;
this.mass = mass;
this.r = sqrt(this.mass) * 1;
this.col = color(255);
this.col = color(color_value);
}
mouse_mass() {
@ -36,6 +36,7 @@ class Mover {
let distanceSq = constrain(force.magSq(), 10, 1000);
let G = 3;
let strength = (G * this.mass * other.mass) / distanceSq;
force.setMag(strength);
other.applyForce(force);
}

View File

@ -22,25 +22,16 @@ function setup() {
if (params.has("gay")) {
console.log('The "gay" parameter exists in the URL.');
movers[0] = new Mover(0, 0, 5, -5, 50);
movers[0].col = color("#D12229");
movers[1] = new Mover(width / 5, height / 5, -5, -5, 50);
movers[1].col = color("#F68A1E");
movers[2] = new Mover((2 * width) / 5, (2 * height) / 5, -5, -5, 50);
movers[2].col = color("#FDE01A");
movers[3] = new Mover((3 * width) / 5, (3 * height) / 5, -5, -5, 50);
movers[3].col = color("#007940");
movers[4] = new Mover((4 * width) / 5, (4 * height) / 5, -5, -5, 50);
movers[4].col = color("#24408E");
movers[5] = new Mover(width, height, -5, -5, 50);
movers[5].col = color("#732982");
movers[0] = new Mover(50, "#D12229");
movers[1] = new Mover(50, "#F68A1E");
movers[2] = new Mover(50, "#FDE01A");
movers[3] = new Mover(50, "#007940");
movers[4] = new Mover(50, "#24408E");
movers[5] = new Mover(50, "#732982");
} else {
movers[0] = new Mover(10, 10, 5, -5, 50);
movers[0].col = color("red");
movers[1] = new Mover(width / 2, height / 2, -5, -5, 60);
movers[1].col = color("white");
movers[2] = new Mover(width - 10, height - 10, -5, -5, 40);
movers[2].col = color("blue");
movers[0] = new Mover(50,"red");
movers[1] = new Mover(60,"white");
movers[2] = new Mover(40,"blue");
}
background(0);