phetsims / balloons-and-static-electricity

"Balloons and Static Electricity" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/balloons-and-static-electricity
GNU General Public License v3.0
6 stars 10 forks source link

(Sound) Long rub sound at wall when using J+W shortcut #493

Closed terracoda closed 3 years ago

terracoda commented 3 years ago

While testing #486, I noticed a long rub sound if I jump the balloon to the wall with J+W.

To reproduce

  1. grab balloon
  2. gets some charge on balloon
  3. use alt input and J+W to jump grabbed balloon from Sweater to Wall in one go.

You should hear a long rub sound when balloon hits the wall.

jbphet commented 3 years ago

Nice catch @terracoda. I haven't done any testing with the hot keys, so I hadn't run into this.

The root cause of the issue is that the "rub sound" referred to in the title was being triggered by a combination of the balloon's smoothed drag speed and some logic that tests whether the balloon is in contact with the wall or the sweater. In this particular case, the smoothed drag speed gets very high because of the instantaneous movement of the balloon from the sweater to the wall, and then the balloon is in contact with the wall, so the sound is generated, and it takes a while to taper off due to the very high speed used in the calculation. I've changed the code to only trigger the rubbing sound for the wall when the balloon is moving vertically, and this prevents the sound from being played in the jump scenario described above.

I feel like this change is beneficial for other reasons as well, since now we don't get a rubbing sound as soon as the balloon hits the wall, so that sound no longer overlaps with the 'bump' sound.

jbphet commented 3 years ago

This is fixed, and I reviewed it with @Ashton-Morris, and he is on board with the revised behavior. Closing.