Skip to content

Commit

Permalink
Adding assertions for #273
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Feb 28, 2017
1 parent ca8a545 commit b0bf845
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions js/make-a-ten/common/model/PaperNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,15 @@ define( function( require ) {
step: function( dt ) {
if ( !this.userControlledProperty.value ) {
var currentPosition = this.positionProperty.value;
assert && assert( currentPosition.isFinite() );
assert && assert( this.destination.isFinite() );

// perform any animation
var distanceToDestination = currentPosition.distance( this.destination );
if ( distanceToDestination > dt * MakeATenConstants.ANIMATION_VELOCITY ) {
// Move a step toward the destination.
var stepVector = this.destination.minus( currentPosition ).setMagnitude( MakeATenConstants.ANIMATION_VELOCITY * dt );
assert && assert( stepVector.isFinite() );
this.positionProperty.value = currentPosition.plus( stepVector );

}
Expand Down Expand Up @@ -164,6 +167,8 @@ define( function( require ) {
* immediately set the position to be the same as the destination.
*/
setDestination: function( destination, animate ) {
assert && assert( destination.isFinite() );

this.destination = destination;

if ( animate ) {
Expand Down

0 comments on commit b0bf845

Please sign in to comment.