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:
11
p5/mover.js
11
p5/mover.js
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user