1
0
mirror of https://gitlab.com/MisterBiggs/Resume.git synced 2025-07-26 00:01:24 +00:00

clean up code

This commit is contained in:
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);
}