phetsims / collision-lab

"Collision Lab" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
6 stars 4 forks source link

Implement Return Masses button #90

Closed brandonLi8 closed 4 years ago

brandonLi8 commented 4 years ago
brandonLi8 commented 4 years ago

@arouinfar, after thinking about it, I'm wondering why you decided to call it "Return Masses"

In the simulation, they are called "balls", like in: image and the button displays "return Balls" in the flash version.

Anyways, for now, I'll go with "Return Masses," but I was just wondering what the rationale behind this name was.

brandonLi8 commented 4 years ago

I've finished the "Return Masses" button in the commits above (in master).

After playing around with it, which works great for most cases, I think that we might need to rethink its functionality.

One interaction that doesn't seem right is by turning off the reflecting border and allowing the balls to leave the play area. The button pops up as expected. Then pause the sim and play it again, which resaves a new state of the Ball. Then pressing the button returns the ball to the last saved state (restarting), which is out of bounds.

Assigning @arouinfar for comment.

Edit: one way we could do this is to reset the position of the Balls to the same position at the start of the sim, but restart the mass and velocity to the most recently saved state. Or we could only save the states of the Balls if the Balls are inside the Pool table.

arouinfar commented 4 years ago

@brandonLi8 great questions.

I'm wondering why you decided to call it "Return Masses"

That's likely a holdover from an older design. For consistency, I think it's better to use "Return Balls" instead.

Then pause the sim and play it again, which resaves a new state of the Ball. Then pressing the button returns the ball to the last saved state (restarting), which is out of bounds.

Why does pausing the sim save the state in this case? We aren't saving the state when pausing in other situations, and I don't think we'd want to do it here, either.

Or we could only save the states of the Balls if the Balls are inside the Pool table.

I'd still like clarification about my comment above, but only saving the state if the balls are in bounds sounds reasonable to me.

brandonLi8 commented 4 years ago

Why does pausing the sim save the state in this case? We aren't saving the state when pausing in other situations, and I don't think we'd want to do it here, either.

@arouinfar Oh no, pausing the sim doesn't save states. What I meant was pausing, and then playing the sim again. The way restarting works in the code is every time the user presses the play button (from pause to play), the states of the balls are saved. When restart is pressed, the balls are set to the most recent save.

brandonLi8 commented 4 years ago

In the commits above, I renamed "Return Masses" to "Return Balls" and I only save the states of the Balls that have any part of the Ball inside of the Pool table. Now, pressing the restart button and the return balls button guarantees that the ball positions return to somewhere inside of the pool table.

Back to @arouinfar to review in master or in https://phet-dev.colorado.edu/html/collision-lab/1.0.0-dev.17/phet/collision-lab_en_phet.html. Close if there is nothing else that needs to be done.

arouinfar commented 4 years ago

Looks good in master @brandonLi8