Skip to content

Commit

Permalink
Correct Direction.id values. phetsims/masses-and-springs#359
Browse files Browse the repository at this point in the history
  • Loading branch information
Denz1994 committed May 11, 2020
1 parent 03a39ab commit 09a56a9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions js/common/model/Direction.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,32 @@ import Vector2 from '../../../../dot/js/Vector2.js';
import Enumeration from '../../../../phet-core/js/Enumeration.js';
import buildAMolecule from '../../buildAMolecule.js';

// constants
const DirectionOrientation = Enumeration.byKeys( [ 'NORTH', 'EAST', 'SOUTH', 'WEST' ] );

class DirectionValue {
/**
* @param {Vector2} vector
* @param {string} id
*/
constructor( vector ) {
constructor( vector, id ) {

// @public {Vector2}
this.vector = vector;

// @public {number}
this.id = id;

// @public {DirectionValue}
this.opposite = null;
}
}

// Declare cardinal direction values
const NORTH = new DirectionValue( new Vector2( 0, 1 ) );
const SOUTH = new DirectionValue( new Vector2( 0, -1 ) );
const EAST = new DirectionValue( new Vector2( 1, 0 ) );
const WEST = new DirectionValue( new Vector2( -1, 0 ) );
const NORTH = new DirectionValue( new Vector2( 0, 1 ), DirectionOrientation.NORTH );
const SOUTH = new DirectionValue( new Vector2( 0, -1 ), DirectionOrientation.SOUTH );
const EAST = new DirectionValue( new Vector2( 1, 0 ), DirectionOrientation.EAST );
const WEST = new DirectionValue( new Vector2( -1, 0 ), DirectionOrientation.WEST );

// Declare opposites
NORTH.opposite = SOUTH;
Expand Down

0 comments on commit 09a56a9

Please sign in to comment.