Skip to content

Instantly share code, notes, and snippets.

@kunukn
Created April 28, 2019 21:09
Show Gist options
  • Select an option

  • Save kunukn/c61c7d8f97475ec9f60a5a4e9261228d to your computer and use it in GitHub Desktop.

Select an option

Save kunukn/c61c7d8f97475ec9f60a5a4e9261228d to your computer and use it in GitHub Desktop.
Nature of Code 2.5
class Mover {
constructor({ mass = 1, size = 40 } = {}) {
this.mass = mass;
this.location = new Vector();
this.velocity = new Vector();
this.acceleration = new Vector();
this.size = size;
}
applyForce = v => {
let f = Vector.div(v, this.mass);
this.acceleration.add(f);
};
update = () => {
this.location.add(this.velocity);
this.velocity.add(this.acceleration);
this.acceleration.mult(0);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment