Last active
November 1, 2016 18:08
-
-
Save raduGaspar/a48c9ec4fddbbd3fbdbab46d094056d0 to your computer and use it in GitHub Desktop.
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
| export default class VerletModel { | |
| constructor(x=0, y=0) { | |
| this.previousX = x; | |
| this.previousY = y; | |
| this.xPos = x; | |
| this.yPos = y; | |
| } | |
| get vx() { | |
| return this.xPos - this.previousX; | |
| } | |
| set vx(value) { | |
| this.previousX = this.xPos - value; | |
| } | |
| get vy() { | |
| return this.yPos - this.previousY; | |
| } | |
| set vy(value) { | |
| this.previousY = this.yPos - value; | |
| } | |
| set x(value) { | |
| this.previousX = value - this.vx; | |
| this.xPos = value; | |
| } | |
| get x() { | |
| return this.xPos; | |
| } | |
| set y(value) { | |
| this.previousY = value - this.vy; | |
| this.yPos = value; | |
| } | |
| get y() { | |
| return this.yPos; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment