Created
February 10, 2019 12:00
-
-
Save jfraboni/a9e3cd04402754919b6a20f6e5c8cc8d to your computer and use it in GitHub Desktop.
Snippet: Update a body's position and rotation
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
/** | |
* Updates the x and y properties of a body based on its | |
* velocityX and velocityY, and, updates the rotation of | |
* a body based on its rotationalVelocity. | |
* | |
* @param {Object} body: The body must be an Object | |
* with x, y, rotation, velocityX, velocityY, and | |
* rotationalVelocity properties. | |
*/ | |
updatePosition(body) { | |
body.x += body.velocityX; | |
body.y += body.velocityY; | |
body.rotation += body.rotationalVelocity; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment