Skip to content

Commit

Permalink
Implement soccer ball overlap constant - see #175
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-blackman committed May 9, 2023
1 parent a86a1d2 commit 89b95d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions js/common/CAVConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const CAVConstants = {
NUMBER_OF_OBJECTS: 15, // number of objects in the play area on each screen
CHECKBOX_TEXT_MAX_WIDTH: 107,

SOCCER_BALL_OVERLAP: 0.1,

// the top checkboxes are left aligned with the play area checkboxes, so their max width is smaller to accommodate
// for the accordion box margin
PLOT_TYPE_PROPERTY: new EnumerationProperty( CAVQueryParameters.plotType === 'dotPlot' ? PlotType.DOT_PLOT : PlotType.LINE_PLOT, {
Expand Down
4 changes: 2 additions & 2 deletions js/common/model/CAVSceneModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export default class CAVSceneModel extends PhetioObject implements TModel {
soccerBall.animation = null;
}
soccerBall.positionProperty.value = new Vector2( soccerBall.valueProperty.value!, position );
position += CAVObjectType.SOCCER_BALL.radius * 2;
position += CAVObjectType.SOCCER_BALL.radius * 2 * ( 1 - CAVConstants.SOCCER_BALL_OVERLAP );
} );

this.stackChangedEmitter.emit();
Expand Down Expand Up @@ -440,7 +440,7 @@ export default class CAVSceneModel extends PhetioObject implements TModel {
const targetIndex = otherObjectsInStack.length;

const diameter = CAVObjectType.SOCCER_BALL.radius * 2;
const targetPositionY = targetIndex * diameter + CAVObjectType.SOCCER_BALL.radius;
const targetPositionY = targetIndex * diameter * ( 1 - CAVConstants.SOCCER_BALL_OVERLAP ) + CAVObjectType.SOCCER_BALL.radius;

const animationSlowdownFactor = CAVQueryParameters.slowAnimation ? 10 : 1;
const animationTime = animationSlowdownFactor * 0.06 * this.getStackAtLocation( value ).length;
Expand Down

0 comments on commit 89b95d1

Please sign in to comment.