Created
April 28, 2019 21:09
-
-
Save kunukn/c61c7d8f97475ec9f60a5a4e9261228d to your computer and use it in GitHub Desktop.
Nature of Code 2.5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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