Skip to content

Commit

Permalink
Moved all methods that had been attached directly to the prototype to…
Browse files Browse the repository at this point in the history
… the 'inherit' call, see #5.
  • Loading branch information
jbphet committed Jul 15, 2013
1 parent 7c074bb commit 908b092
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
43 changes: 21 additions & 22 deletions js/common/model/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,30 @@ define( function( require ) {
} );
}

inherit( PropertySet, Particle );

// Step function, moves towards destination if not currently there.
Particle.prototype.step = function( dt ) {
if ( !this.userControlled ) {
var distanceToDestination = this.position.distance( this.destination );
if ( distanceToDestination > dt * this.velocity ) {
// Move a step toward the destination.
this.position = this.position.plus( this.destination.minus( this.position ).normalized().timesScalar( this.velocity * dt ) );
inherit( PropertySet, Particle, {
step : function( dt ) {
if ( !this.userControlled ) {
var distanceToDestination = this.position.distance( this.destination );
if ( distanceToDestination > dt * this.velocity ) {
// Move a step toward the destination.
this.position = this.position.plus( this.destination.minus( this.position ).normalized().timesScalar( this.velocity * dt ) );
}
else if ( distanceToDestination > 0 ) {
// Less than one time step away, so just go to the destination.
this.position = this.destination;
}
}
else if ( distanceToDestination > 0 ) {
// Less than one time step away, so just go to the destination.
this.position = this.destination;
}
}
};
},

Particle.prototype.moveImmediatelyToDestination = function() {
this.position = this.destination;
};
moveImmediatelyToDestination: function() {
this.position = this.destination;
},

Particle.prototype.setPositionAndDestination = function( newPosition ) {
this.destination = newPosition;
this.moveImmediatelyToDestination();
};
setPositionAndDestination : function( newPosition ) {
this.destination = newPosition;
this.moveImmediatelyToDestination();
}
} );

return Particle;
} );
16 changes: 8 additions & 8 deletions js/common/view/PeriodicTableCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ define( function( require ) {
}

// Inherit from Node.
inherit( Node, PeriodicTableCell );

PeriodicTableCell.prototype.setHighlighted = function( highLighted ) {
this.cell.fill = highLighted ? this.highlightedFill : this.normalFill;
this.cell.stroke = highLighted ? 'red' : 'black';
this.cell.lineWidth = highLighted ? 2 : 1;
this.label.fontWeight = highLighted ? 'bold' : 'normal';
};
inherit( Node, PeriodicTableCell, {
setHighlighted: function( highLighted ) {
this.cell.fill = highLighted ? this.highlightedFill : this.normalFill;
this.cell.stroke = highLighted ? 'red' : 'black';
this.cell.lineWidth = highLighted ? 2 : 1;
this.label.fontWeight = highLighted ? 'bold' : 'normal';
}
} );

return PeriodicTableCell;
} );
7 changes: 4 additions & 3 deletions js/game/model/BAAGameModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ define( function( require ) {
// Inherit from base class and define the methods for this object.
inherit( PropertySet, BAAGameModel, {

// Step function necessary to be used as a model in the Joist framework.
step: function( dt ) {
},

// Start a new game.
startSubGame: function( subGameType ) {
console.log( 'startGame called, sub game subGameType = ' + subGameType );
Expand Down Expand Up @@ -93,8 +97,5 @@ define( function( require ) {

} );

BAAGameModel.prototype.step = function( dt ) {
};

return BAAGameModel;
} );

0 comments on commit 908b092

Please sign in to comment.