Skip to content

Commit

Permalink
Use joist random, see #64
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Feb 13, 2018
1 parent 985f587 commit 657c534
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion js/friction/model/FrictionModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ define( function( require ) {

// choose a random atom from the current row and evaporate it
var currentEvaporationRow = this.toEvaporate[ this.toEvaporate.length - 1 ];
var atomNode = currentEvaporationRow.splice( Math.floor( Math.random() * currentEvaporationRow.length ), 1 )[ 0 ];
var atomNode = currentEvaporationRow.splice( Math.floor( phet.joist.random.nextDouble() * currentEvaporationRow.length ), 1 )[ 0 ];
if ( atomNode ) {
atomNode.evaporate();
this.evaporationEmitter.emit();
Expand Down
9 changes: 5 additions & 4 deletions js/friction/view/magnifier/AtomNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define( function( require ) {
var Image = require( 'SCENERY/nodes/Image' );
var inherit = require( 'PHET_CORE/inherit' );
var Node = require( 'SCENERY/nodes/Node' );
var Util = require( 'DOT/Util' );
var Vector2 = require( 'DOT/Vector2' );

// constants
Expand Down Expand Up @@ -92,8 +93,8 @@ define( function( require ) {

// update atom's position based on vibration and center position
model.newStepProperty.link( function() {
self.currentX = self.x0 + model.amplitudeProperty.get() * ( Math.random() - 0.5 );
self.currentY = self.y0 + model.amplitudeProperty.get() * ( Math.random() - 0.5 );
self.currentX = self.x0 + model.amplitudeProperty.get() * ( phet.joist.random.nextDouble() - 0.5 );
self.currentY = self.y0 + model.amplitudeProperty.get() * ( phet.joist.random.nextDouble() - 0.5 );
} );
}

Expand All @@ -119,9 +120,9 @@ define( function( require ) {

this.isEvaporated = true;

var evaporationDestinationX = this.x0 + 4 * this.model.width * ( Math.round( Math.random() ) - 0.5 );
var evaporationDestinationX = this.x0 + 4 * this.model.width * ( Util.roundSymmetric( phet.joist.random.nextDouble() ) - 0.5 );
var dx = ( evaporationDestinationX - this.x0 ) / STEPS;
var evaporationDestinationY = this.y0 + Math.random() * 1.5 * this.getYrange();
var evaporationDestinationY = this.y0 + phet.joist.random.nextDouble() * 1.5 * this.getYrange();
var dy = ( evaporationDestinationY - this.y0 ) / STEPS;

// create and attach the evaporation motion handler
Expand Down

0 comments on commit 657c534

Please sign in to comment.