im trying to make a program with scratch similar to pong, except when the ball is hit it would produce a sound, using [blocks]<play note( <{ note }> )for( <{ X }> )secss>[/blocks]. i'm trying to make it so when hit, the note would continue playing until hit again by the other paddle, however the time it takes to hit one to the other side varies, depending on how long the gaming session lasts. the tone of the sound will also be a random number from 36 to 84. the problem is when i play the note for X seconds, it loops over and over again, because i dont have a definite variable for the X seconds. how can i get the sound to continue to play; without looping itself; until it hits the other paddle?
example of the problem, the numbers represent how long the sound plays, right now its at 0.5s
ball is hit, 0.5, 0.5, 0.5, 0.5 ball is hit again, 0.5, 0.5, 0.5, 0.4 etc.
what i want it to do:
ball is hit, 2, ball is hit again, 1.9
i've tried everything to try and fix this, please help.
Offline
try having <repeat until><touching[ other sprite]
play note note for .5 beats
Offline
that would work but as the game progresses the ball also gets slower and faster depending on how its hit, so it could take like 2 seconds to reach the other side or if directly hit it would take about 0.5, so if it's 2 seconds it will play the note 4 times
Offline
Here is an approach that uses the Stop All Sounds block to chop a long note off when it is time to change to a new note. It has a bit of lag to it but it's the best I've been able to come up with so far.
http://scratch.mit.edu/projects/Paddle2SeeFixIt/431745
Offline